Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. int ledAmarelo = 9;
  2. int ledAzul = 8;
  3. int leds[4] = {ledVermelho, ledVerde, ledAmarelo, ledAzul};
  4. int b1 = 3;
  5. int b2 = 4;
  6. int b3 = 5;
  7. int b4 = 6;
  8.  
  9.  
  10. int buzzer = 7;
  11.  
  12. int estadoBotao1 = 0;
  13. int estadoBotao2 = 0;
  14. int estadoBotao3 = 0;
  15. int estadoBotao4 = 0;
  16. int botaoPressionado = 0;
  17.  
  18. int sorteador(){
  19. return random(0,4);
  20. }
  21.  
  22. void setup(){
  23. pinMode(ledVermelho, OUTPUT);
  24. pinMode(ledVerde, OUTPUT);
  25. pinMode(ledAmarelo, OUTPUT);
  26. pinMode(ledAzul, OUTPUT);
  27. pinMode(b1, INPUT);
  28. pinMode(b2, INPUT);
  29. pinMode(b3, INPUT);
  30. pinMode(b4, INPUT);
  31. pinMode(buzzer, OUTPUT);
  32. }
  33.  
  34. void loop(){
  35. int numSorteado = sorteador();
  36. for(int i=0;i<1;i++){
  37. tone(buzzer,294);
  38. digitalWrite(leds[numSorteado],HIGH);
  39. delay(500);
  40. noTone(buzzer);
  41. digitalWrite(leds[numSorteado],LOW);
  42. delay(100);
  43. }
  44. }
  45.  
  46. for(int i=0;i<1;i++){
  47. tone(buzzer,294);
  48. digitalWrite(leds[numSorteado],HIGH);
  49. delay(500);
  50. noTone(buzzer);
  51. digitalWrite(leds[numSorteado],LOW);
  52. delay(100); }
  53.  
  54. for(int i=0;i<"Quantidade de leds iguais ou algo que vai definir a contagem";i++){
  55. tone(buzzer,294);
  56. digitalWrite(leds[numSorteado],HIGH);
  57. delay(500);
  58. noTone(buzzer);
  59. digitalWrite(leds[numSorteado],LOW);
  60. delay(100);
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement