NewArduinoCheatsheet 1
NewArduinoCheatsheet 1
Program Flow / Control Pin Configuration - INPUT vs OUTPUT Data \ Variable Types
/* Each Arduino Sketch must contain the pinMode(pin, INPUT/OUTPUT/INPUT_PULLUP); const (indicates a constant data type)
following two functions */ void (null data type)
OUTPUT Control int (integer -32,768 to 32,767)
void setup() float (floating point / decimal numbers)
digitalWrite(pin, val); // val: HIGH or LOW arrayName[] – list of elements (any type)
{
analogWrite(pin, val); // val: 0 to 255. String (array of characters)
// runs only once.
}
tone(pin, freq); // freq in Hertz
void loop() System constants / functions
tone(pin, freq, duration); //duration in ms
{
noTone(pin); // stop tone on pin HIGH / LOW
// runs repeatedly.
OUTPUT / INPUT / INPUT_PULLUP
}
Reading INPUTs millis(); //returns # of milliseconds
delay(time_millis); // pauses program in ms buttonPress = digitalRead(pin); // any pin micros(); //returns # of microseconds
delayMicroseconds(time_micros); //pause s sensorVal = analogRead(pin); // A0-A5 pins