v12345vtm

linksrectspan

Apr 30th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 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 FDCTiltUp = A0;
  10. int FDCTiltDown = A1;
  11. int FDCPanLinks = A2;
  12. int FDCPanRechts = A3;
  13. int MotorPanLinks = 12;
  14. int MotorPanRechts = 11;
  15. int MotorTiltUp = 10;
  16. int MotorTiltDown = 9;
  17.  
  18. // the setup routine runs once when you press reset:
  19. void setup() {
  20. // initialize serial communication at 9600 bits per second:
  21. Serial.begin(115200);
  22. // make the pushbutton's pin an input:
  23. pinMode(FDCTiltUp, INPUT);
  24. pinMode(FDCTiltDown, INPUT);
  25. pinMode(FDCPanLinks, INPUT);
  26. pinMode(FDCPanRechts, INPUT);
  27.  
  28. pinMode(MotorTiltUp, OUTPUT);
  29. pinMode(MotorTiltUp, OUTPUT);
  30. pinMode(MotorPanLinks, OUTPUT);
  31. pinMode(MotorPanRechts, OUTPUT);
  32.  
  33.  
  34. digitalWrite(MotorTiltUp, LOW);
  35. digitalWrite(MotorTiltUp, LOW);
  36. digitalWrite(MotorPanLinks, LOW);
  37. digitalWrite(MotorPanRechts, LOW);
  38.  
  39.  
  40. }
  41.  
  42. // the loop routine runs over and over again forever:
  43. void loop() {
  44. // read the input pin:
  45. // int buttonState = digitalRead(FDCpandown);
  46. // print out the state of the button:
  47. Serial.print(digitalRead(FDCTiltUp));
  48. Serial.print(digitalRead(FDCTiltDown));
  49. Serial.print(digitalRead(FDCPanLinks));
  50. Serial.println(digitalRead(FDCPanRechts));
  51. delay(1); // delay in between reads for stability
  52.  
  53.  
  54.  
  55.  
  56. while (digitalRead(FDCPanLinks) == 1) {
  57. digitalWrite(MotorPanLinks, HIGH);
  58. delay(2);
  59. digitalWrite(MotorPanLinks, LOW );
  60. delay(2);
  61. }
  62.  
  63.  
  64. while (digitalRead(FDCPanRechts) == 1) {
  65. digitalWrite(MotorPanRechts, HIGH);
  66. delay(2);
  67. digitalWrite(MotorPanRechts, LOW );
  68. delay(2);
  69. }
  70.  
  71. ////////////
  72.  
  73. // while (digitalRead(FDCTiltUp) == 1) {
  74. // digitalWrite(MotorTiltUp, HIGH);
  75. // delay(2);
  76. // digitalWrite(MotorTiltUp, LOW );
  77. // delay(2);
  78. // }
  79. //
  80. //
  81. // while (digitalRead(FDCTiltDown) == 1) {
  82. // digitalWrite(MotorTiltDown, HIGH);
  83. // delay(2);
  84. // digitalWrite(MotorTiltDown, LOW );
  85. // delay(2);
  86. // }
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93. }
Advertisement
Add Comment
Please, Sign In to add comment