-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Description
The following code (a modified version of ascii table to include a blink to a led) will 100% hang without any output to serial at the first Serial.print().
Works fine on 1.2.0
/*
ASCII table
Prints out byte values in all possible formats:
- as raw binary values
- as ASCII-encoded decimal, hex, octal, and binary values
For more on ASCII, see http://www.asciitable.com and http://en.wikipedia.org/wiki/ASCII
The circuit: No external hardware needed.
created 2006
by Nicholas Zambetti <http://www.zambetti.com>
modified 9 Apr 2012
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/ASCIITable
*/
void setup() {
pinMode(PD12, OUTPUT);
digitalWrite(PD12, HIGH);
//Initialize serial and wait for port to open:
Serial.begin(9600);
digitalWrite(PD12, LOW);
// prints title with ending line break
//Serial.println("ASCII Table ~ Character Map");
//digitalWrite(PD12, LOW);
}
// first visible ASCIIcharacter '!' is number 33:
int thisByte = 33;
// you can also write ASCII characters in single quotes.
// for example, '!' is the same as 33, so you could also use this:
// int thisByte = '!';
void loop() {
static long last = millis();
if (millis() - last > 1000){
digitalWrite(PD12, LOW);
if (millis() - last > 2000){
digitalWrite(PD12, HIGH);
last = millis();
}
}
// prints value unaltered, i.e. the raw binary version of the byte.
// The Serial Monitor interprets all bytes as ASCII, so 33, the first number,
// will show up as '!'
Serial.write(thisByte);
Serial.print(", dec: ");
// prints value as string as an ASCII-encoded decimal (base 10).
// Decimal is the default format for Serial.print() and Serial.println(),
// so no modifier is needed:
Serial.print(thisByte);
// But you can declare the modifier for decimal if you want to.
// this also works if you uncomment it:
// Serial.print(thisByte, DEC);
Serial.print(", hex: ");
// prints value as string in hexadecimal (base 16):
Serial.print(thisByte, HEX);
Serial.print(", oct: ");
// prints value as string in octal (base 8);
Serial.print(thisByte, OCT);
Serial.print(", bin: ");
// prints value as string in binary (base 2) also prints ending line break:
Serial.println(thisByte, BIN);
// if printed last visible character '~' or 126, stop:
if (thisByte == 126) { // you could also use if (thisByte == '~') {
// This loop loops forever and does nothing
thisByte = 33;
}
// go on to the next character
thisByte++;
}