ARDUINO
ARDUINO
INTRODUCTION
At Contoso, we empower organizations to foster collaborative
thinking to further drive workplace innovation. By closing the loop
and leveraging agile frameworks, we help business grow organically
and foster a consumer-first mindset.
THE CODE EXPLAINED
• // - comment serves as our little notes
• void setup() - tells Arduino that the next block of code will be a
function name setup()
BUTTON IS PRESSED
// Turn on LED while the button is pressed
const int LED = 13; // the pin for the LED
const int BUTTON = 7; // the input pin where the
// pushbutton is connected
int val = 0; // val will be used to store the state
// of the input pin
void setup() {
pinMode(LED, OUTPUT); // tell Arduino LED is an output
pinMode(BUTTON, INPUT); // and BUTTON is an input
}
void loop(){
val = digitalRead(BUTTON); // read input value and store it
// check whether the input is HIGH (button pressed)
if (val == HIGH) {
digitalWrite(LED, HIGH); // turn LED ON
} else {
digitalWrite(LED, LOW);
}
}