Datatypes:
type | bytes | range | GCC type |
char | 1 | -128 to 127 | signed char |
byte | 1 | 0 to 255 | unsigned char |
int | 2 | -32768 to 32767 | signed short |
unsigned int | 2 | 0 to 65535 | unsigned short |
long | 4 | -2147483648 to 2147483647 | signed int |
unsigned long | 4 | 0 to 4294967295 | unsigned int |
float | 4 | -3.4028235E+38 to 3.4028235E+38 | float |
double | 4 | (reduced to float) | float |
Blink:
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(1000); // wait for a second
}
Simple serial communication:
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
byte inByte = Serial.read();
Serial.println("recvd ");
}
}