Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1.  
  2.  
  3. int stato = LOW;
  4. int old_stato = LOW;
  5. int counter = 0;
  6. void setup() {
  7. // put your setup code here, to run once:
  8. pinMode(2,OUTPUT);
  9. pinMode(3,OUTPUT);
  10. pinMode(4,OUTPUT);
  11. pinMode(5,OUTPUT);
  12. pinMode(11,INPUT);
  13. Serial.begin(9600); //Inizializzazione porta seriale
  14. Serial.println("INIZIO");
  15. pinMode(13,OUTPUT); //Accensione in caso di pressione led
  16. }
  17.  
  18. void loop() {
  19. // put your main code here, to run repeatedly:
  20. int i;
  21. //Serial.print("Il contatore e' ");
  22. //Serial.println(counter,DEC);
  23. stato = digitalRead(11);
  24.  
  25. if(stato == HIGH){
  26. digitalWrite(13,HIGH);
  27. }else if(stato == LOW){
  28. digitalWrite(13,LOW);
  29. }
  30.  
  31.  
  32.  
  33. if(old_stato != stato && stato == HIGH){
  34. counter++;
  35. Serial.print("Incremento a ");
  36. Serial.println(counter,DEC);
  37. }
  38. old_stato = stato;
  39.  
  40. for(i = 0;i < 4;i++){
  41. if(counter % 4 == i){
  42. digitalWrite(2+i,HIGH);
  43. }else{
  44. digitalWrite(2+i,LOW);
  45. }
  46. }
  47.  
  48.  
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement