Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. /*
  2. DigitalReadSerial
  3. Reads a digital input on pin 2, prints the result to the serial monitor
  4.  
  5. This example code is in the public domain.
  6. */
  7.  
  8. // digital pin 2 has a pushbutton attached to it. Give it a name:
  9. int tiltA = 2;
  10. int tiltB = 3;
  11. int tiltC = 4;
  12.  
  13. // the setup routine runs once when you press reset:
  14. void setup() {
  15. // initialize serial communication at 9600 bits per second:
  16. Serial.begin(9600);
  17. // make the pushbutton's pin an input:
  18. pinMode(tiltA, INPUT);
  19. pinMode(tiltB, INPUT);
  20. pinMode(tiltC, INPUT);
  21. }
  22.  
  23. // the loop routine runs over and over again forever:
  24. void loop() {
  25. // read the input pin:
  26. int tiltAstate = digitalRead(tiltA);
  27. int tiltBstate = digitalRead(tiltB);
  28. int tiltCstate = digitalRead(tiltC);
  29. // print out the state of the button:
  30. Serial.println(tiltAstate);
  31. Serial.println(tiltBstate);
  32. Serial.println(tiltCstate);
  33. delay(1000); // delay in between reads for stability
  34. }
  35.  
  36. //FIN
  37.  
  38. void setup() {
  39. Serial.begin(10600);
  40. pinMode(13, OUTPUT);
  41. pinMode(12, OUTPUT);
  42. pinMode(11, OUTPUT);
  43. pinMode(10, OUTPUT);
  44. pinMode(9, OUTPUT);
  45.  
  46. }
  47.  
  48. void loop() {
  49.  
  50. int pot = analogRead(A5);
  51. Serial.println(pot);
  52. delay(1);
  53.  
  54. if (pot > 0 && pot < 205) {
  55.  
  56. digitalWrite(12, LOW);
  57. digitalWrite(11, LOW);
  58. digitalWrite(10, LOW);
  59. digitalWrite(9, LOW);
  60.  
  61. digitalWrite(13, HIGH);
  62. delay(2);
  63. }
  64. else if (pot > 205 && pot < 410) {
  65.  
  66. digitalWrite(13, LOW);
  67. digitalWrite(11, LOW);
  68. digitalWrite(10, LOW);
  69. digitalWrite(9, LOW);
  70.  
  71. digitalWrite(12, HIGH);
  72. delay(2);
  73. }
  74.  
  75. else if (pot > 410 && pot < 615) {
  76.  
  77. digitalWrite(13, LOW);
  78. digitalWrite(12, LOW);
  79. digitalWrite(10, LOW);
  80. digitalWrite(9, LOW);
  81.  
  82. digitalWrite(11, HIGH);
  83. delay(2);
  84. }
  85.  
  86. else if (pot > 615 && pot < 920) {
  87.  
  88. digitalWrite(13, LOW);
  89. digitalWrite(12, LOW);
  90. digitalWrite(11, LOW);
  91. digitalWrite(9, LOW);
  92.  
  93. digitalWrite(10, HIGH);
  94. delay(2);
  95. }
  96.  
  97. else if (pot > 920 && pot <= 1024) {
  98.  
  99. digitalWrite(13, LOW);
  100. digitalWrite(12, LOW);
  101. digitalWrite(11, LOW);
  102. digitalWrite(10, LOW);
  103.  
  104. digitalWrite(9, HIGH);
  105. delay(2);
  106. }
  107.  
  108.  
  109.  
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement