Go Down

Topic: Modified Ascii Table example (Read 699 times) previous topic - next topic

Kevin Marinelli

I modified the example ASCII Table program by Nicholas Zambetti to let me do some additional experiments with the looping structure, data conversion and blinking an LED at the same time. It is nice to have some visual feedback that the program is running properly when learning how to use the USBtty to monitor the ASCII output.

I notice that after downloading Arduino-0016 today, that the AsciiTable example that is distributed with was modified by Tom Igoe in a similar manner to mine except for the looping structure changes and the flashing LED.  Hopefully people will like this variant.

// ASCII Table Kv2
// Original by Nicholas Zambetti
// Modified version by Kevin Marinelli

void setup()
 pinMode(0, OUTPUT);  // Set up pin 0 to operate the LED.
 digitalWrite(0, HIGH);  // Turn the LED on.
 delay(500);                // Wait a bit.
 digitalWrite(0, LOW);  // Turn the LED off.
 delay(20);                 // Wait a bit so that the flash of the LED turning
                                 // off is visible to the eye.
 // prints title with ending line break
 Serial.println("ASCII Table ~ Character Map");

 // wait for the long string to be sent

unsigned char number = 33; // first visible character '!' is #33

void loop()

 digitalWrite(0, HIGH);            // Turn on the LED attached to pin 0.
 Serial.print(number, BYTE);    // prints ASCII character represented by number, first will be '!'
 Serial.print(", dec: ");
 Serial.print(number,DEC);          // prints value as string in decimal (base 10)
 Serial.print(", hex: ");
 Serial.print(number, HEX);     // prints value as string in hexadecimal (base 16)
 Serial.print(", oct: ");
 Serial.print(number, OCT);     // prints value as string in octal (base 8)
 Serial.print(", bin: ");
 Serial.println(number, BIN);   // prints value as string in binary (base 2)      
                                           // also prints ending line break  
 digitalWrite(0, LOW);          //Turn off the LED attached to pin 0.
 delay(20); // allow some time for the Serial data to be sent.
                 // It is important that the delay is AFTER the LED turns off;
                 // Otherwise, the LED only turns off for a few microseconds,
                 // which is not going to be visible.

 if( number==0)
     number=33; // Start the loop back at the first printable character.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131