So I have 3 switches
(Switch 1: inspectionready, Switch 2:stopmotor, Switch 3:inspection stop)
so when switch 1 is pushed
motor will rotate clockwise
if switch 2 is pushed stop motor
if switch 1 is pushed again
motor will rotate clockwise
then motor stop
finally is switch 3 is pushed program will end.
i am having trouble with making switch one to make the motor turn clock wise
then stop when switch 2 is pressed
then when switch 1 is pressed again motor will turn counter clockwise
then stop when switch 2 is pressed*********
please help i am a newb...i have looked a bunch of examples....
const int inspectready = 2;
const int stopmotor = 3;
const int inspectstop = 4;
const int camera = 9;
const int light = 10;
const int motorcw = 11;
const int motorccw = 12;
// variables will change:
int startbutton = 0; // variable for reading the pushbutton status
int inspectiondone = 0;
int motorstop = 0;
void setup() {
pinMode(inspectready, INPUT);
pinMode(stopmotor, INPUT);
pinMode(inspectstop, INPUT);
pinMode(camera, OUTPUT);
pinMode(light, OUTPUT);
pinMode(motorcw, OUTPUT);
pinMode(motorccw, OUTPUT);
}
void loop(){
startbutton = digitalRead(inspectready);
motorstop = digitalRead(stopmotor);
inspectiondone = digitalRead(inspectstop);
while(inspectiondone == LOW){
while (startbutton = HIGH){
if(startbutton = HIGH){
digitalWrite(camera, HIGH);
digitalWrite(light, HIGH);
digitalWrite(motorcw, HIGH);
}
while (startbutton == HIGH) {
if (startbutton == HIGH){
digitalWrite(camera, HIGH);
digitalWrite(light, HIGH);
digitalWrite(motorccw, HIGH);
}
else if (motorstop == HIGH) {
digitalWrite(camera, LOW);
digitalWrite(light, LOW);
digitalWrite(motorcw, LOW);
digitalWrite(motorccw, LOW);
}}
}}
}