Unverified Commit 961c73e3 authored by Luan Banh's avatar Luan Banh Committed by GitHub
Browse files

follow the line with hall sensor

parent 17d40e56
......@@ -63,12 +63,16 @@ Wheels w = {WheelLeftF, WheelLeftB, WheelRightF, WheelRightB};
Speeds s = {FWD_SPD, BCK_SPD, LFT_SPD, RGT_SPD, RT_CW_SPD, RT_CCW_SPD};
MotorControl motors(w, s);
const int hallSensor = A1;
const int pedestrianLed = 6;
void stateControl(uint8_t c);
void bootSequence();
void detect();
void setup() {
//attachInterrupt(digitalPinToInterrupt(sensorLeds), detect, CHANGE);
pinMode(pedestrianLed, OUTPUT);
Serial.begin(9600);
Serial.println("Follow the Line Color"); // so I can keep track of what is loaded
Serial.println("Bot is OFF");
......@@ -196,6 +200,15 @@ void stateControl()
Serial.println("Searching for path");
state = SEARCH;
}
int person = analogRead(hallSensor);
if (person >= 399) {
Serial.println("Pedestrian detected");
state = STOP;
digitalWrite(pedestrianLed, HIGH);
} else {
digitalWrite(pedestrianLed, LOW);
}
delay(5); //slow loop to allow for change in state
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment