Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- DigitalReadSerial
- Reads a digital input on pin 2, prints the result to the serial monitor
- This example code is in the public domain.
- */
- // digital pin 2 has a pushbutton attached to it. Give it a name:
- int FDCTiltUp = A0;
- int FDCTiltDown = A1;
- int FDCPanLinks = A2;
- int FDCPanRechts = A3;
- int MotorPanLinks = 12;
- int MotorPanRechts = 11;
- int MotorTiltUp = 10;
- int MotorTiltDown = 9;
- // the setup routine runs once when you press reset:
- void setup() {
- // initialize serial communication at 9600 bits per second:
- Serial.begin(115200);
- // make the pushbutton's pin an input:
- pinMode(FDCTiltUp, INPUT);
- pinMode(FDCTiltDown, INPUT);
- pinMode(FDCPanLinks, INPUT);
- pinMode(FDCPanRechts, INPUT);
- pinMode(MotorTiltUp, OUTPUT);
- pinMode(MotorTiltUp, OUTPUT);
- pinMode(MotorPanLinks, OUTPUT);
- pinMode(MotorPanRechts, OUTPUT);
- digitalWrite(MotorTiltUp, LOW);
- digitalWrite(MotorTiltUp, LOW);
- digitalWrite(MotorPanLinks, LOW);
- digitalWrite(MotorPanRechts, LOW);
- }
- // the loop routine runs over and over again forever:
- void loop() {
- // read the input pin:
- // int buttonState = digitalRead(FDCpandown);
- // print out the state of the button:
- Serial.print(digitalRead(FDCTiltUp));
- Serial.print(digitalRead(FDCTiltDown));
- Serial.print(digitalRead(FDCPanLinks));
- Serial.println(digitalRead(FDCPanRechts));
- delay(1); // delay in between reads for stability
- // while (digitalRead(FDCPanLinks) == 1) {
- // digitalWrite(MotorPanLinks, HIGH);
- // delay(200);
- // digitalWrite(MotorPanLinks, LOW );
- // delay(200);
- // }
- //
- //
- // while (digitalRead(FDCPanRechts) == 1) {
- // digitalWrite(MotorPanRechts, HIGH);
- // delay(200);
- // digitalWrite(MotorPanRechts, LOW );
- // delay(200);
- // }
- ////////////
- while (digitalRead(FDCTiltUp) == 1) {
- digitalWrite(MotorTiltUp, HIGH);
- delay(2);
- digitalWrite(MotorTiltUp, LOW );
- delay(2);
- }
- while (digitalRead(FDCTiltDown) == 1) {
- digitalWrite(MotorTiltDown, HIGH);
- delay(2);
- digitalWrite(MotorTiltDown, LOW );
- delay(2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment