/* Example Sketch for a TellyMate Shield */ /* Random Characters */ /* Simple helper functions */ #define CHAR_ESC "\x1B" void cursor_move( uint8_t row , uint8_t col ) { // Yrc Serial.print( CHAR_ESC "Y" ) ; Serial.print((unsigned char)(32 + row)) ; Serial.print((unsigned char)(32 + col)) ; } void cursor_show( bool show ) { // e or f Serial.print( CHAR_ESC ) ; Serial.print( show?'e':'f' ) ; } void screen_clear( void ) { // E Serial.print( CHAR_ESC "E" ); } /* The actual sketch */ void setup() { Serial.begin( 57600 ) ; // set to 57600 baud screen_clear() ; cursor_show( false ) ; // turn the cursor off } void loop() { //move the cursor to a random place on the screen. cursor_move( random( 25 ) , random( 38 ) ) ; // print a random character. Characters below 31 need special handling, so (for simplicity) use values between 32 and 255 Serial.print( (unsigned char) random( 32, 256 ) ) ; // the (unsigned char) cast ensures that the int returned by random() is treated as a char when passed to Serial.print(). // without the cast, the Serial.print function will display the int value as a number on the screen rather than the character with that value. }