Salvatore "Sal" Testa /@saltesta14
March 15, 2014
Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. -Arduino.cc
buttons, accelerometers, heat sensors, switches, photo resistors
LEDs, motors, speakers
void setup()
{
// put your setup code here, to run once:
}
void loop()
{
// put your main code here, to run repeatedly:
}
int RED_LED = 13;
void setup()
{
pinMode(RED_LED, OUTPUT); // set the 13 pin to output
digitalWrite(RED_LED, HIGH); // set the 13 pin high
}
void loop()
{
}
int RED_LED = 13;
void setup()
{
pinMode(RED_LED, OUTPUT);
}
void loop()
{
digitalWrite(RED_LED, HIGH); // turn the light on
delay(1000); // wait 1000 milliseconds
digitalWrite(RED_LED, LOW); // turn the light off
delay(1000); // wait 1000 milliseconds
}
void party() {
digitalWrite(RED_LED, HIGH);
delay(1000);
digitalWrite(RED_LED, LOW);
delay(1000);
}
// ... some other code
party();
party();
party();
// ... some more code
int max(int num1, num2) {
...
}
int avg(int[] nums) {
...
}
void goToCrawlStop(int collegeNumber) {
...
}
if (statement) {
// this code only gets called
// if statement is true
}
int max(int num1, num2) {
if(num1 > num2) {
return num1;
} else {
return num2;
}
}
int LED = 10;
int BUTTON = 3;
void setup() {
pinMode(LED, OUTPUT);
pinMode(BUTTON, INPUT); // input mode
}
void loop() {
int readVal = digitalRead(BUTTON); // read the button
if(readVal == HIGH){
digitalWrite(LED, HIGH); // on if the button is down
} else {
digitalWrite(LED, LOW); // off otherwise
}
}