//define pins #define light1 5 #define light2 4 #define touch 8 #define PWM12 5 #define PWM11 6 #define PWM21 9 #define PWM22 10 const int blackl= 550; const int blackr= 500; //initiate touch counter int counttouch = 0; int lastbutstate = 0; void setup() { //Set up pin output/ input pinMode(18, INPUT); pinMode(19, INPUT); pinMode(touch, INPUT); pinMode(PWM12, OUTPUT); pinMode(PWM11, OUTPUT); pinMode(PWM22, OUTPUT); pinMode(PWM21, OUTPUT); //one side of the motor driver output to low digitalWrite(PWM11, LOW); digitalWrite(PWM21, LOW); //set up connection speed Serial.begin(9600); } void move() { //set speeds of whiles int full = 240; int slow = 0; //light sensors variables and constants long lightsenl; long lightsenr; //read light sensors lightsenl = analogRead(light2); lightsenr = analogRead(light1); Serial.println(lightsenl); //if the right light sensor read black //if the left light sensor reads black if(blackr= delayt) { // the button is pushed if (reading != 0) { //record the time time = millis(); //add one to the touch counter counttouch += 1; //if the button is pushed the first time if (counttouch ==1) { //while the touch sensor is pushed while( reading != 0) { //read the touch sensor and move reading = digitalRead(touch); move(); } } //when the touch counter is pushed the second time while(counttouch==2) { //set up timer till shut off if (millis()-time >=delayt ) { //shut off motor analogWrite(PWM21,0); analogWrite(PWM11,0); analogWrite(PWM12,0); analogWrite(PWM22,0); } } } } }