Skip to content

Instantly share code, notes, and snippets.

@jueti
Created May 31, 2018 08:57
Show Gist options
  • Save jueti/24273bb2f51ea0a45a5433506f16b01c to your computer and use it in GitHub Desktop.
Save jueti/24273bb2f51ea0a45a5433506f16b01c to your computer and use it in GitHub Desktop.
Arduino: type convertion, convert a DEC to int
int incomingByte = 0; // for incoming serial data
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment