Here's an easy project which creates a wirelessly programmable message board. It uses XBee modules to provide a wireless serial link between your computer and the device. You interact with it via a simple menu system. There are no buttons (other than the reset button, which is hidden) on the device.
Remove these ads by
Signing UpStep 1: What's It All About
The following programming concepts are demonstrated:
- creating a simple menu system using the serial interface
- accepting and validating strings and integers via the serial interface
- retrieving strings from flash memory using progmem
- storing and retrieving strings in external EEPROM using a simple data structure
- storing configuration data in the onboard EEPROM
- displaying static and scrolling text on a parallel interface LCD (or LCD compatible display)
- measuring an analog value, in this case light levels










































Visit Our Store »
Go Pro Today »




This is probably really clear, but arduino's API changed over time,
the correct way of doing this would be:
void clearAndHome()
{
Serial.write(27);
Serial.print("[2J"); // clear screen
Serial.write(27); // ESC
Serial.print("[H"); // cursor to home
}
Anyone has a tip on which terminal (for OSX) program actually understands these commands? I've tried coolTerm, which doesn't seem to understand this.
Zterm any good? and goSerial? Thanks!
I have updated the code so that a Serial.println-type function can be used with "inline" FLASH-stored strings. So, basically, you have code that has a print function and strings where you would expect them in the code, only at compile time they get stored in FLASH and read-from FLASH at execution-time via PROGMEM.
Perhaps at some point Serial.print/println will be rewritten to use prog_uchar instead of char, and then PSTR will be able to provide a pointer it can use directly. But, this method works fine.
You need to use flash memory more. It looks like you know how but you are still using the "Serial.print", which is going to eat up a lot of RAM.
Use stdio.h , so you can use printf_P
http://www.nongnu.org/avr-libc/user-manual/group__avr__stdio.html
together with avr/pgmspace.h, you can call functions such as
printf_P(PSTR("This string will take no RAM at all"));
take a look at http://www.nongnu.org/avr-libc/user-manual/group__avr__eeprom.html
It provides functions for most common datatypes. And for custom datatypes like a struct, simply pass in a pointer to eeprom_write_block, and the length should just be "sizeof" the struct