diff --git "a/IOT(Internet of Things)/Basic/Arduino_Line_Follower_Robot/Circuit design Arduino_line_follower_robot - Tinkercad - Personal - Microsoft\342\200\213 Edge 2024-05-15 23-03-21.mp4" "b/IOT(Internet of Things)/Basic/Arduino_Line_Follower_Robot/Circuit design Arduino_line_follower_robot - Tinkercad - Personal - Microsoft\342\200\213 Edge 2024-05-15 23-03-21.mp4" new file mode 100644 index 000000000..5c16731a0 Binary files /dev/null and "b/IOT(Internet of Things)/Basic/Arduino_Line_Follower_Robot/Circuit design Arduino_line_follower_robot - Tinkercad - Personal - Microsoft\342\200\213 Edge 2024-05-15 23-03-21.mp4" differ diff --git a/IOT(Internet of Things)/Basic/Arduino_Line_Follower_Robot/Images/circuit.png.png b/IOT(Internet of Things)/Basic/Arduino_Line_Follower_Robot/Images/circuit.png.png new file mode 100644 index 000000000..a7aaa98e0 Binary files /dev/null and b/IOT(Internet of Things)/Basic/Arduino_Line_Follower_Robot/Images/circuit.png.png differ diff --git a/IOT(Internet of Things)/Basic/Arduino_Line_Follower_Robot/Images/robo.png.png b/IOT(Internet of Things)/Basic/Arduino_Line_Follower_Robot/Images/robo.png.png new file mode 100644 index 000000000..205eee4dc Binary files /dev/null and b/IOT(Internet of Things)/Basic/Arduino_Line_Follower_Robot/Images/robo.png.png differ diff --git a/IOT(Internet of Things)/Basic/Arduino_Line_Follower_Robot/code.ino/code.ino.ino b/IOT(Internet of Things)/Basic/Arduino_Line_Follower_Robot/code.ino/code.ino.ino new file mode 100644 index 000000000..e0360134d --- /dev/null +++ b/IOT(Internet of Things)/Basic/Arduino_Line_Follower_Robot/code.ino/code.ino.ino @@ -0,0 +1,82 @@ +#define LEFT_SENSOR 3 // pin connected to the left sensor +#define RIGHT_SENSOR 4 // pin connected to the right sensor + +#define Motor14 1 // pin connected to motor 1 (control pin 1) +#define Motor15 0 // pin connected to motor 1 (control pin 2) +#define Motor17 5 // pin connected to motor 2 (control pin 1) +#define Motor18 6 // pin connected to motor 2 (control pin 2) + +void setup() { + // Set Timer 0 for PWM (Pulse Width Modulation) used for motor speed control + TCCR0B = TCCR0B & B11111000 | B00000010; + + // Start serial communication for debugging (optional) + Serial.begin(9600); + + // Set sensor pins as inputs + pinMode(LEFT_SENSOR, INPUT); + pinMode(RIGHT_SENSOR, INPUT); + + // Set motor control pins as outputs + pinMode(Motor14, OUTPUT); + pinMode(Motor15, OUTPUT); + pinMode(Motor17, OUTPUT); + pinMode(Motor18, OUTPUT); +} + +void loop() { + int leftSensorValue = analogRead(LEFT_SENSOR); // Read analog value from left sensor + int rightSensorValue = analogRead(RIGHT_SENSOR); // Read analog value from right sensor + + // Print sensor readings for debugging (optional) + Serial.print("LEFT_SENSOR = "); + Serial.println(leftSensorValue); + + Serial.print("RIGHT_SENSOR = "); + Serial.println(rightSensorValue); + + // Call the rotation function to control motor movement based on sensor readings + rotation(leftSensorValue, rightSensorValue); +} + +void rotation(int leftValue, int rightValue) { + // Forward (both sensors see white - high sensor readings) + if (leftValue >= 800 && rightValue >= 800) { + digitalWrite(Motor14, HIGH); + digitalWrite(Motor15, LOW); + digitalWrite(Motor17, HIGH); + digitalWrite(Motor18, LOW); // Set motors to move forward + } + + // Right turn (left sensor sees black - low sensor reading, right sensor sees white) + else if (leftValue <= 800 && rightValue >= 800) { + digitalWrite(Motor14, LOW); + digitalWrite(Motor15, HIGH); + digitalWrite(Motor17, HIGH); + digitalWrite(Motor18, LOW); // Set motors to turn right + } + + // Left turn (left sensor sees white, right sensor sees black) + else if (leftValue >= 800 && rightValue <= 800) { + digitalWrite(Motor14, HIGH); + digitalWrite(Motor15, LOW); + digitalWrite(Motor17, LOW); + digitalWrite(Motor18, HIGH); // Set motors to turn left + } + + // Stop (both sensors see black - low sensor readings) + else { + digitalWrite(Motor14, LOW); + digitalWrite(Motor15, LOW); + digitalWrite(Motor17, LOW); + digitalWrite(Motor18, LOW); // Stop motors + delay(400); // Wait for 400 milliseconds + + // Short forward movement to help escape from a centered position + digitalWrite(Motor14, HIGH); + digitalWrite(Motor15, LOW); + digitalWrite(Motor17, HIGH); + digitalWrite(Motor18, LOW); // Short forward movement + delay(400); // Wait for 400 milliseconds + } +} diff --git a/IOT(Internet of Things)/Basic/Arduino_Line_Follower_Robot/readme.md b/IOT(Internet of Things)/Basic/Arduino_Line_Follower_Robot/readme.md new file mode 100644 index 000000000..6920dabd5 --- /dev/null +++ b/IOT(Internet of Things)/Basic/Arduino_Line_Follower_Robot/readme.md @@ -0,0 +1,13 @@ +# Line Follower Robot using Arduino + +-> This project involves creating a line-following robot using an Arduino microcontroller. + +-> The robot follows a predefined path or line on the ground using infrared sensors to detect the line and make necessary adjustments in its movement. + +# Circuit Diagram +[Image](Images/circuit.png.png) + +# Demonstration [Video](https://geuac-my.sharepoint.com/:v:/g/personal/21022109_geu_ac_in/EXHbhFVZHbhPhkgSunn_W1EB5jz8xyH8o5IU7j8TXhfC2Q) + +# Implementation [Video](https://geuac-my.sharepoint.com/:v:/g/personal/21022109_geu_ac_in/EfzswFv9-M1Nu_r0viun3TIBGBUgg-pNA1_6fYiQuPa0tA) + diff --git a/IOT(Internet of Things)/README.md b/IOT(Internet of Things)/README.md index 2a260b01b..8b3cc81f5 100644 --- a/IOT(Internet of Things)/README.md +++ b/IOT(Internet of Things)/README.md @@ -25,6 +25,7 @@ | 13. | [Arduino PIR Motion Sensor](https://github.com/Kushal997-das/Project-Guidance/tree/main/IOT(Internet%20of%20Things)/Basic/Arduino_PIR_Motion_Sensor) | 14. | [Arduino RGB Mixing](https://github.com/Kushal997-das/Project-Guidance/tree/main/IOT(Internet%20of%20Things)/Basic/Arduino_RGB_Mixing)| 15. | [Arduino Serial Monitor](https://github.com/Kushal997-das/Project-Guidance/tree/main/IOT(Internet%20of%20Things)/Basic/Arduino_Serial_Monitor) | 16. | [Arduino Servo Motor](https://github.com/Kushal997-das/Project-Guidance/tree/main/IOT(Internet%20of%20Things)/Basic/Arduino_Servo_Motor) | 17. | [Arduino Stress Sensor](https://github.com/Kushal997-das/Project-Guidance/tree/main/IOT(Internet%20of%20Things)/Basic/Arduino_Stress_Sensor) | 18. | [Arduino Temperature Sensor](https://github.com/Kushal997-das/Project-Guidance/tree/main/IOT(Internet%20of%20Things)/Basic/Arduino_Temperature_Sensor) | 19. | [Arduino Traffic Light Simulator](https://github.com/Kushal997-das/Project-Guidance/tree/main/IOT(Internet%20of%20Things)/Basic/Arduino_TrafficLight_Simulator) | 20. | [Arduino UltraSonic Sensor](https://github.com/Kushal997-das/Project-Guidance/tree/main/IOT(Internet%20of%20Things)/Basic/Arduino_UltraSonic_Sensor) | 21. | [Multi Arduino Knight Rider Lights](https://github.com/Kushal997-das/Project-Guidance/tree/main/IOT(Internet%20of%20Things)/Basic/Multi%20Arduino%20Knight%20Rider%20Lights) +| 22. | [Arduino_Line_Follower_Robot](https://github.com/deedGhost/Project-Guidance/tree/main/IOT(Internet%20of%20Things)/Basic/Arduino_Line_Follower_Robot) ## Level 2: Intermediate 🚀