#include <avr/pgmspace.h>
char buffer [5];
word serialCount;
void setup(void)
{
Serial.begin(38400);
Serial.println("\nPress space bar .");
// while (Serial.read() != 32) delay(1); // Wait for space
}
const int mydata[10][10] PROGMEM = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', 'A',
'1', '1', '2', '3', '4', '5', '6', '7', '8', 'B',
'2', '1', '2', '3', '4', '5', '6', '7', '8', 'C',
'3', '1', '2', '3', '4', '5', '6', '7', '8', 'D',
'4', '1', '2', '3', '4', '5', '6', '7', '8', 'E',
'5', '1', '2', '3', '4', '5', '6', '7', '8', 'F',
'6', '1', '2', '3', '4', '5', '6', '7', '8', 'G',
'7', '1', '2', '3', '4', '5', '6', '7', '8', 'H',
'8', '1', '2', '3', '4', '5', '6', '7', '8', 'I',
'9', '1', '2', '3', '4', '5', '6', '7', '8', 'Z' };
void loop(void) {
int i,j;
byte n;
Serial.println("\nData by Rows.");
for (i=0; i < 100;i++) {
// Serial.println(" ");
if ((i %8)==0) Serial.print("|");
if ((i %16)==0) Serial.println("");
n = pgm_read_byte_near(i);
// Serial.print(n, HEX);
Serial.print(" ");
sprintf(buffer, "%02x", n);
Serial.print(buffer);
serialCount++;
// Serial.print("\t");
}
Serial.println(" ");
Serial.println("\nData by Columns.");
for (i=0; i < 10; i++) {
Serial.println(" ");
for (j=0; j < 10; j++) {
n = pgm_read_word_near(&mydata[j][i]);
Serial.print(n, BYTE);
}
}
Serial.println(" "); setup(); Serial.println(" "); //start over
}
Tuesday, November 1, 2011
PROGMEM example
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment