Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int buttonPin1 = 3;
- int buttonPin2 = 4;
- int motorPin1 = 5; //PWM ~
- int motorPin2 = 6; //PWM ~
- int buttonState1 = 0;
- int buttonState2 = 0;
- void setup() {
- Serial.begin(9600);
- pinMode(buttonPin1, INPUT_PULLUP);
- pinMode(buttonPin2, INPUT_PULLUP);
- pinMode(motorPin1, OUTPUT);
- pinMode(motorPin2, OUTPUT);
- digitalWrite(motorPin1, LOW);
- digitalWrite(motorPin2, LOW);
- }
- void loop() {
- buttonState1 = digitalRead(buttonPin1);
- buttonState2 = digitalRead(buttonPin2);
- Serial.print(buttonState1);
- Serial.print(" ");
- Serial.println(buttonState2);
- if (buttonState1 == 0) {
- Serial.println("UP");
- digitalWrite(motorPin1, LOW);
- digitalWrite(motorPin2, HIGH);
- delay(60000);
- }
- if (buttonState2 == 0) {
- Serial.println("DOWN");
- digitalWrite(motorPin2, LOW);
- digitalWrite(motorPin1, HIGH);
- delay(60000);
- }
- else {
- Serial.println("Stop");
- digitalWrite(motorPin1, HIGH);
- digitalWrite(motorPin2, HIGH);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement