//ASCII table
/*
* Instituto Tecnologico de Tijuana
* Depto de Sistemas y Computación
* Ing. En Sistemas Computacionales
* Autor : Gabriel San Roman Castillo Gabriel nickname: 1GAB0
* Programa: ASCII table
* Fecha de revisión: 25/10/2023
* Objetivo del programa: Ejecutar el ejemplo de arduino ASCII table
*/
// ---------------------------------------
// Solution on .ino
// ---------------------------------------
void setup() {
//Initialize serial and wait for port to open:
Serial1.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// prints title with ending line break
Serial1.println("ASCII Table ~ Character Map");
}
// 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() {
// 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 '!'
Serial1.write(thisByte);
Serial1.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:
Serial1.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);
Serial1.print(", hex: ");
// prints value as string in hexadecimal (base 16):
Serial1.print(thisByte, HEX);
Serial1.print(", oct: ");
// prints value as string in octal (base 8);
Serial1.print(thisByte, OCT);
Serial1.print(", bin: ");
// prints value as string in binary (base 2) also prints ending line break:
Serial1.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
while (true) {
continue;
}
}
// go on to the next character
thisByte++;
}