Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int back_motor_low = 8;
- int back_motor_high = 9;
- int back_motor_enable = 10;
- int front_motor_low = 13;
- int front_motor_high = 12;
- int front_motor_enable = 11;
- int IR_sensor_IS471F_pin = 2;
- int sensor_status = 0;
- void front_motor_turn_left()
- {
- digitalWrite(front_motor_low, HIGH);
- digitalWrite(front_motor_high, LOW);
- digitalWrite(front_motor_enable, HIGH);
- }
- void front_motor_turn_right()
- {
- digitalWrite(front_motor_low, LOW);
- digitalWrite(front_motor_high, HIGH);
- digitalWrite(front_motor_enable, HIGH);
- }
- void front_motor_turn_off()
- {
- digitalWrite(front_motor_enable, LOW);
- }
- void back_motor_run()
- {
- digitalWrite(back_motor_enable, HIGH);
- }
- void back_motor_stop()
- {
- digitalWrite(back_motor_enable, LOW);
- }
- void setup() {
- pinMode(IR_sensor_IS471F_pin, INPUT);
- pinMode(back_motor_low, OUTPUT);
- pinMode(back_motor_high, OUTPUT);
- pinMode(back_motor_enable, OUTPUT);
- pinMode(front_motor_low, OUTPUT);
- pinMode(front_motor_high, OUTPUT);
- pinMode(front_motor_enable, OUTPUT);
- digitalWrite(back_motor_low, HIGH);
- digitalWrite(back_motor_high, LOW);
- digitalWrite(back_motor_enable, LOW);
- digitalWrite(front_motor_low, HIGH);
- digitalWrite(front_motor_high, LOW);
- digitalWrite(front_motor_enable, LOW);
- }
- void loop() {
- sensor_status = digitalRead(IR_sensor_IS471F_pin);
- back_motor_run();
- if (sensor_status == HIGH)
- {
- front_motor_turn_left();
- }
- else
- {
- front_motor_turn_right();
- }
- }
Add Comment
Please, Sign In to add comment