Kanamex

S02Practica-MonitorSerial

Jun 23rd, 2021
545
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int push1 = 3;
  2. int push2 = 4;
  3. int push3 = 5;
  4. int value_p1 = 0;
  5. int value_p2 = 0;
  6. int value_p3 = 0;
  7. int value_p4 = 0;
  8. int value_p5 = 0;
  9. int value_p6 = 0;
  10. int azul = 6;
  11. int verde = 7;
  12. int rojo = 8;
  13. void setup() {
  14. Serial.begin(9600);
  15. pinMode(push1, INPUT);
  16. pinMode(push2, INPUT);
  17. pinMode(push3, INPUT);
  18. pinMode(azul,OUTPUT);
  19. pinMode(verde,OUTPUT);
  20. pinMode(rojo,OUTPUT);
  21. }
  22. void loop() {
  23. value_p1 = digitalRead (push1);
  24. value_p2 = digitalRead (push2);
  25. value_p3 = digitalRead (push3);
  26. value_p4 = digitalRead (push3);
  27. value_p5 = digitalRead (push3);
  28. value_p6 = digitalRead (push3);
  29. if(value_p1 == HIGH){
  30. digitalWrite(rojo, HIGH);
  31. digitalWrite(verde,LOW);
  32. digitalWrite(azul,LOW);
  33. Serial.println("Rojo");
  34. delay(1000);
  35. }
  36. if(value_p2 == HIGH){
  37. digitalWrite(verde, HIGH);
  38. digitalWrite(rojo,LOW);
  39. digitalWrite(azul,LOW);
  40. Serial.println("Verde");
  41. delay(1000);
  42. }
  43. if(value_p3 == HIGH){
  44. digitalWrite(azul, HIGH);
  45. digitalWrite(verde,LOW);
  46. digitalWrite(rojo,LOW);
  47. Serial.println("Azul");
  48. delay(1000);
  49. }
  50. if(value_p4 == HIGH){
  51. digitalWrite(azul, HIGH);
  52. digitalWrite(verde,LOW);
  53. digitalWrite(rojo,HIGH);
  54. Serial.println("Magenta");
  55. delay(1000);
  56. }
  57. if(value_p5 == HIGH){
  58. digitalWrite(azul, HIGH);
  59. digitalWrite(verde,HIGH);
  60. digitalWrite(rojo,LOW);
  61. Serial.println("Cian");
  62. delay(1000);
  63. }
  64. if(value_p6 == HIGH){
  65. digitalWrite(azul, HIGH);
  66. digitalWrite(verde,HIGH);
  67. digitalWrite(rojo,HIGH);
  68. Serial.println("Blanco");
  69. delay(1000);
  70. }
  71. }
RAW Paste Data