//Fab Academy 2020 - Fab Lab León //Button + LED //SAMDino //SAMD11C // //Original code:Neil Gershenfeld 12/8/19 // This work may be reproduced, modified, distributed, // performed, and displayed for any purpose, but must // acknowledge this project. Copyright is retained and // must be preserved. The work is provided as is; no // warranty is provided, and users accept all liability. // //This is a modified code made by José Alegría based in // the original by Neil Gershenfeld and Adrián Torres. const int ledPin1 = 2;//first light const int buttonPin1 = 4;// first button pin int buttonState1 = 0;//initial state of the button const int ledPin2 = 8;//second light const int buttonPin2 = 5;// second button pin int buttonState2 = 0;//initial state of the button void setup() { //declaration of inputs and outputs pinMode(ledPin1, OUTPUT); pinMode(buttonPin1, INPUT); pinMode(ledPin2, OUTPUT); pinMode(buttonPin2, INPUT); } void loop() { buttonState1 = digitalRead(buttonPin1);// we read the state of the button buttonState2 = digitalRead(buttonPin2); if (buttonState1 == HIGH) { //if we press the button digitalWrite(ledPin1, HIGH); } else { //if we don't press the button digitalWrite(ledPin1, LOW); } if (buttonState2 == LOW) { //if we press the button digitalWrite(ledPin2, HIGH); } else { //if we don't press the button digitalWrite(ledPin2, LOW); } delay(1000); }