Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int stato = LOW;
- int old_stato = LOW;
- int counter = 0;
- void setup() {
- // put your setup code here, to run once:
- pinMode(2,OUTPUT);
- pinMode(3,OUTPUT);
- pinMode(4,OUTPUT);
- pinMode(5,OUTPUT);
- pinMode(11,INPUT);
- Serial.begin(9600); //Inizializzazione porta seriale
- Serial.println("INIZIO");
- pinMode(13,OUTPUT); //Accensione in caso di pressione led
- }
- void loop() {
- // put your main code here, to run repeatedly:
- int i;
- //Serial.print("Il contatore e' ");
- //Serial.println(counter,DEC);
- stato = digitalRead(11);
- if(stato == HIGH){
- digitalWrite(13,HIGH);
- }else if(stato == LOW){
- digitalWrite(13,LOW);
- }
- if(old_stato != stato && stato == HIGH){
- counter++;
- Serial.print("Incremento a ");
- Serial.println(counter,DEC);
- }
- old_stato = stato;
- for(i = 0;i < 4;i++){
- if(counter % 4 == i){
- digitalWrite(2+i,HIGH);
- }else{
- digitalWrite(2+i,LOW);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement