ARDUINO TUTORIAL – PROGETTO 2 – INTERFACCIA PER ASTRONAVE

ARDUINO TUTORIAL – PROGETTO 2 – INTERFACCIA PER ASTRONAVE

IN QUESTO PROGETTO COSTRUIREMO QUALCOSA CHE POTREBBE ESSE UN INTERFACCIA DI UN ASTRONAVE. REALIZZEREMO UN PANNELLO DI CONTROLLO CON UN PULSANTE E DELLE LUCI CHE SI ACCENDERANNO QUANDO SI SCHIACCIA IL PULSANTE.
 
 
 
 
 
 
INGREDIENTI :
 
ARDUINO UNO
 
BREADBOARD
 
5 CAVI
 
3 LED
 
3 RESISTENZE 220 OHM
 
1 PULSANTE 
 
1 RESISTENZA 10 KILO OHM
 
SKETCH:
 
int switchstate = 0;
 
void setup(){
 
  pinMode(3,OUTPUT);
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
 
  
  pinMode(2,INPUT);
}
 
void loop(){
  switchstate = digitalRead(2);
  if (switchstate == LOW) {
    digitalWrite(3, HIGH); // turn the green LED on pin 3 on
    digitalWrite(4, LOW);  // turn the red LED on pin 4 off
    digitalWrite(5, LOW);  // turn the red LED on pin 5 off
  }
  else {
    digitalWrite(3, LOW);  // turn the green LED on pin 3 off
    digitalWrite(4, LOW);  // turn the red LED on pin 4 off
    digitalWrite(5, HIGH); // turn the red LED on pin 5 on
    
    delay(250);
    digitalWrite(4, HIGH); // turn the red LED on pin 4 on
    digitalWrite(5, LOW);  // turn the red LED on pin 5 off
   
    delay(250);
  }
}
BUON DIVERTIMENTO!!!!!!!!!

Una risposta a “ARDUINO TUTORIAL – PROGETTO 2 – INTERFACCIA PER ASTRONAVE”

  1. Ciao, ho recentemente acquistato il kit, il progetto 2 è il primo progetto con il codice.
    Ho costruito il circuito e caricato lo sketch.
    Appena carica i led rossi lampeggiano ad intermittenza ed il verde è acceso fisso.
    Questo mi lascia intuire che siamo nell’else ma il verde dovrebbe essere LOW (quindi spento, corretto?).
    Se premo il pulsante non capita nulla.
    Ho sbagliato il circuito?
    Grazie

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *