Paso 3: código
Copia el siguiente código y pegar el siguiente código en el IDE de Arduino y luego seleccione un puerto COM adecuado y subir el código al Linkit.
const int buttonPin = 2; // the number of the pushbutton pinconst int ledPin = 13; // the number of the LED pin const int led2Pin = 12; const int led3Pin = 11; const int led4Pin = 10; // the number of the LED pin const int led5Pin = 9; const int led6Pin = 7; const int led7Pin = 6; // the number of the LED pin const int led8Pin = 5; const int led9Pin = 4; const int led10Pin = 3; const int speakerOut = 1;// variables will change: int buttonState = 0; // variable for reading the pushbutton status int tastyTimeVariable = 0; // my time variable that has 1 added int i; int n;void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); pinMode(led2Pin, OUTPUT); pinMode(led3Pin, OUTPUT); pinMode(led4Pin, OUTPUT); pinMode(led5Pin, OUTPUT); pinMode(led6Pin, OUTPUT); pinMode(led7Pin, OUTPUT); pinMode(led8Pin, OUTPUT); pinMode(led9Pin, OUTPUT); pinMode(led10Pin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); pinMode(speakerOut, OUTPUT); delay(3000); }void loop(){ // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); // check if the pushbutton is pressed. // if it is, the buttonState is HIGH: if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(ledPin, HIGH); } else { } delay(1000); buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(led2Pin, HIGH); } else { } delay(1000);buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(led3Pin, HIGH); } else { } delay(1000); buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(led4Pin, HIGH); } else { } delay(1000); buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(led5Pin, HIGH); } else { } delay(1000); buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(led6Pin, HIGH); } else { } delay(1000); buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(led7Pin, HIGH); } else { } delay(1000); buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(led8Pin, HIGH); } else { } delay(1000);buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(led9Pin, HIGH); } else { } delay(1000);buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(led10Pin, HIGH); } else { } delay(1000); digitalWrite(led10Pin, LOW); digitalWrite(led9Pin, LOW); digitalWrite(led8Pin, LOW); digitalWrite(led7Pin, LOW); digitalWrite(led6Pin, LOW); digitalWrite(led5Pin, LOW); digitalWrite(led4Pin, LOW); digitalWrite(led3Pin, LOW); digitalWrite(led2Pin, LOW); digitalWrite(ledPin, LOW);delay(1000);if (tastyTimeVariable == 0) { }else if (tastyTimeVariable == 1) { digitalWrite (ledPin, HIGH); delay(300L * 1000L); for (i=0; i < 20; i++) { analogWrite(speakerOut,128); delay(250); digitalWrite(speakerOut, LOW); delay(250); } } else if (tastyTimeVariable == 2) { digitalWrite (led2Pin, HIGH); digitalWrite (ledPin, HIGH); delay(300L * 1000L); digitalWrite (led2Pin, LOW); delay(300L * 1000L); for (i=0; i < 20; i++) { analogWrite(speakerOut,128); delay(250); digitalWrite(speakerOut, LOW); delay(250); } //sound alarm }else if (tastyTimeVariable == 3) { digitalWrite (led3Pin, HIGH); digitalWrite (led2Pin, HIGH); digitalWrite (ledPin, HIGH); delay(300L * 1000L); digitalWrite (led3Pin, LOW); delay(300L * 1000L); digitalWrite (led2Pin, LOW); delay(300L * 1000L); for (i=0; i < 20; i++) { analogWrite(speakerOut,128); delay(250); digitalWrite(speakerOut, LOW); delay(250); } //sound alarm } else if (tastyTimeVariable == 4) { digitalWrite (led4Pin, HIGH); digitalWrite (led3Pin, HIGH); digitalWrite (led2Pin, HIGH); digitalWrite (ledPin, HIGH); delay(300L * 1000L); digitalWrite (led4Pin, LOW); delay(300L * 1000L); digitalWrite (led3Pin, LOW); delay(300L * 1000L); digitalWrite (led2Pin, LOW); delay(300L * 1000L); for (i=0; i < 20; i++) { analogWrite(speakerOut,128); delay(250); digitalWrite(speakerOut, LOW); delay(250); } //sound alarm } else if (tastyTimeVariable == 5) { digitalWrite (led5Pin, HIGH); digitalWrite (led4Pin, HIGH); digitalWrite (led3Pin, HIGH); digitalWrite (led2Pin, HIGH); digitalWrite (ledPin, HIGH); delay(300L * 1000L); digitalWrite (led5Pin, LOW); delay(300L * 1000L); digitalWrite (led4Pin, LOW); delay(300L * 1000L); digitalWrite (led3Pin, LOW); delay(300L * 1000L); digitalWrite (led2Pin, LOW); delay(300L * 1000L); for (i=0; i < 20; i++) { analogWrite(speakerOut,128); delay(250); digitalWrite(speakerOut, LOW); delay(250); } //sound alarm } else if (tastyTimeVariable == 6) { digitalWrite (led6Pin, HIGH); digitalWrite (led5Pin, HIGH); digitalWrite (led4Pin, HIGH); digitalWrite (led3Pin, HIGH); digitalWrite (led2Pin, HIGH); digitalWrite (ledPin, HIGH); delay(300L * 1000L); digitalWrite (led6Pin, LOW); delay(300L * 1000L); digitalWrite (led5Pin, LOW); delay(300L * 1000L); digitalWrite (led4Pin, LOW); delay(300L * 1000L); digitalWrite (led3Pin, LOW); delay(300L * 1000L); digitalWrite (led2Pin, LOW); delay(300L * 1000L); for (i=0; i < 20; i++) { analogWrite(speakerOut,128); delay(250); digitalWrite(speakerOut, LOW); delay(250); } //sound alarm } else if (tastyTimeVariable == 7) { digitalWrite (led7Pin, HIGH); digitalWrite (led6Pin, HIGH); digitalWrite (led5Pin, HIGH); digitalWrite (led4Pin, HIGH); digitalWrite (led3Pin, HIGH); digitalWrite (led2Pin, HIGH); digitalWrite (ledPin, HIGH); delay(300L * 1000L); digitalWrite (led7Pin, LOW); delay(300L * 1000L); digitalWrite (led6Pin, LOW); delay(300L * 1000L); digitalWrite (led5Pin, LOW); delay(300L * 1000L); digitalWrite (led4Pin, LOW); delay(300L * 1000L); digitalWrite (led3Pin, LOW); delay(300L * 1000L); digitalWrite (led2Pin, LOW); delay(300L * 1000L); for (i=0; i < 20; i++) { analogWrite(speakerOut,128); delay(250); digitalWrite(speakerOut, LOW); delay(250); } //sound alarm } else if (tastyTimeVariable == 8) { digitalWrite (led8Pin, HIGH); digitalWrite (led7Pin, HIGH); digitalWrite (led6Pin, HIGH); digitalWrite (led5Pin, HIGH); digitalWrite (led4Pin, HIGH); digitalWrite (led3Pin, HIGH); digitalWrite (led2Pin, HIGH); digitalWrite (ledPin, HIGH); delay(300L * 1000L); digitalWrite (led8Pin, LOW); delay(300L * 1000L); digitalWrite (led7Pin, LOW); delay(300L * 1000L); digitalWrite (led6Pin, LOW); delay(300L * 1000L); digitalWrite (led5Pin, LOW); delay(300L * 1000L); digitalWrite (led4Pin, LOW); delay(300L * 1000L); digitalWrite (led3Pin, LOW); delay(300L * 1000L); digitalWrite (led2Pin, LOW); delay(300L * 1000L); //sound alarm } else if (tastyTimeVariable == 9) { digitalWrite (led9Pin, HIGH); digitalWrite (led8Pin, HIGH); digitalWrite (led7Pin, HIGH); digitalWrite (led6Pin, HIGH); digitalWrite (led5Pin, HIGH); digitalWrite (led4Pin, HIGH); digitalWrite (led3Pin, HIGH); digitalWrite (led2Pin, HIGH); digitalWrite (ledPin, HIGH); delay(300L * 1000L); digitalWrite (led9Pin, LOW); delay(300L * 1000L); digitalWrite (led8Pin, LOW); delay(300L * 1000L); digitalWrite (led7Pin, LOW); delay(300L * 1000L); digitalWrite (led6Pin, LOW); delay(300L * 1000L); digitalWrite (led5Pin, LOW); delay(300L * 1000L); digitalWrite (led4Pin, LOW); delay(300L * 1000L); digitalWrite (led3Pin, LOW); delay(300L * 1000L); digitalWrite (led2Pin, LOW); delay(300L * 1000L); //sound alarm } else if (tastyTimeVariable == 10) { digitalWrite (led10Pin, HIGH); digitalWrite (led9Pin, HIGH); digitalWrite (led8Pin, HIGH); digitalWrite (led7Pin, HIGH); digitalWrite (led6Pin, HIGH); digitalWrite (led5Pin, HIGH); digitalWrite (led4Pin, HIGH); digitalWrite (led3Pin, HIGH); digitalWrite (led2Pin, HIGH); digitalWrite (ledPin, HIGH); delay(300L * 1000L); digitalWrite (led10Pin, LOW); delay(300L * 1000L); digitalWrite (led9Pin, LOW); delay(300L * 1000L); digitalWrite (led8Pin, LOW); delay(300L * 1000L); digitalWrite (led7Pin, LOW); delay(300L * 1000L); digitalWrite (led6Pin, LOW); delay(300L * 1000L); digitalWrite (led5Pin, LOW); delay(300L * 1000L); digitalWrite (led4Pin, LOW); delay(300L * 1000L); digitalWrite (led3Pin, LOW); delay(300L * 1000L); digitalWrite (led2Pin, LOW); delay(300L * 1000L); for (i=0; i < 20; i++) { analogWrite(speakerOut,128); delay(250); digitalWrite(speakerOut, LOW); delay(250); } //sound alarm } else if (tastyTimeVariable > 10) { } }