{"id":21532940,"url":"https://github.com/ahmed-maher77/line_follower_robot","last_synced_at":"2026-04-28T13:39:06.427Z","repository":{"id":189775470,"uuid":"681282450","full_name":"Ahmed-Maher77/Line_Follower_Robot","owner":"Ahmed-Maher77","description":"An autonomous robot capable of accurately following a designated path, including sharp turns and interruptions. Designed a lightweight, 3D-printed chassis and implemented optimized PID control with infrared sensors for precise and efficient navigation.","archived":false,"fork":false,"pushed_at":"2025-09-11T15:14:53.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-11T18:29:20.747Z","etag":null,"topics":["3d-printing","arduino","battery","c-programming","c-programming-language","chassis","competition","competitive-programming","embeded-systems","ir-sensor","line-follower-robot","motor-driver","motors","pid-control","robotics","robotics-programming","sensors","spacers"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ahmed-Maher77.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-21T17:10:22.000Z","updated_at":"2025-09-11T15:14:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"ae74f032-50e2-4db2-83be-80b0e3f2e391","html_url":"https://github.com/Ahmed-Maher77/Line_Follower_Robot","commit_stats":null,"previous_names":["ahmed-maher77/line_follower_robot"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Ahmed-Maher77/Line_Follower_Robot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahmed-Maher77%2FLine_Follower_Robot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahmed-Maher77%2FLine_Follower_Robot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahmed-Maher77%2FLine_Follower_Robot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahmed-Maher77%2FLine_Follower_Robot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ahmed-Maher77","download_url":"https://codeload.github.com/Ahmed-Maher77/Line_Follower_Robot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahmed-Maher77%2FLine_Follower_Robot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32383782,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T11:25:28.583Z","status":"ssl_error","status_checked_at":"2026-04-28T11:25:05.435Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d-printing","arduino","battery","c-programming","c-programming-language","chassis","competition","competitive-programming","embeded-systems","ir-sensor","line-follower-robot","motor-driver","motors","pid-control","robotics","robotics-programming","sensors","spacers"],"created_at":"2024-11-24T02:22:56.010Z","updated_at":"2026-04-28T13:39:06.421Z","avatar_url":"https://github.com/Ahmed-Maher77.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Line Follower Robot — Competition-Ready (Arduino + PID)\n\nAn autonomous robot that follows a black line on a white track using infrared reflectance sensors and differential drive. This repo contains two control approaches:\n\n-   Basic 2-sensor bang-bang controller: `main.ino` (quick start)\n-   Advanced 5-sensor PID controller: `main_pid.ino` (smooth, fast, handles sharp turns and gaps)\n\n\u003cimg src=\"https://github.com/user-attachments/assets/f8b9dc49-7659-4a4f-b744-30bac331643e\" alt=\"How to Make Line Follower Robot Using Arduino\" width=\"400\"\u003e\n\n### How it works\n\nInfrared sensors emit IR light and measure reflectance from the surface. White reflects more, black reflects less. The controller estimates the line position and adjusts motor speeds to keep the robot centered.\n\n---\n\n## Hardware\n\n-   **MCU**: Arduino Uno (ATmega328P) or Nano\n-   **Motor driver**: L298N (or L293D; wiring identical PWM/IN logic)\n-   **Motors**: 2× TT/DC gear motors with wheels\n-   **Sensors**:\n    -   Basic: 2× digital IR line sensors (left/right)\n    -   Advanced: 5× analog IR reflectance sensors (array)\n-   **Power**: 2S Li-ion/LiPo (7.4V) or 6×AA pack; separate motor/logic rails recommended\n-   **Chassis**: lightweight acrylic or 3D-printed; ball caster\n-   **Misc**: jumpers, spacers, switch, battery holder\n\n\u003e Tip: For competitions, prefer a 5–8 sensor analog array and a rigid, light chassis.\n\n\u003cimg src=\"https://github.com/Ahmed-Maher77/Line_Follower_Robot/assets/112467034/a40691a1-ee9a-449c-bcaa-9fada22d6df6\" alt=\"line follower robot - hardware\"\u003e\n\n---\n\n## Wiring\n\n### Motors and driver (both sketches)\n\n-   `ENABLE_LEFT_MOTOR` → L298N ENA (PWM) → Arduino D5\n-   `LEFT_MOTOR_PIN1/PIN2` → L298N IN1/IN2 → Arduino D9/D10\n-   `ENABLE_RIGHT_MOTOR` → L298N ENB (PWM) → Arduino D6\n-   `RIGHT_MOTOR_PIN1/PIN2` → L298N IN3/IN4 → Arduino D7/D8\n-   Motor outputs: L298N OUT1–OUT2 → left motor, OUT3–OUT4 → right motor\n-   Power: Motor VIN (battery), +5V logic to Arduino 5V, common GND\n\n### Sensors\n\n-   Basic (digital):\n    -   Right sensor DO → Arduino D11 (`IR_SENSOR_RIGHT`)\n    -   Left sensor DO → Arduino D12 (`IR_SENSOR_LEFT`)\n    -   VCC 5V, GND common; trim pots adjust thresholds\n-   Advanced (analog 5×):\n    -   S0..S4 → Arduino `A0..A4` (`SENSOR_0..SENSOR_4`)\n    -   VCC 5V, GND common\n\n---\n\n## Firmware\n\n### 1) Basic two-sensor control (bang-bang)\n\nFile: `main.ino`\n\nBehavior:\n\n-   Both white → drive straight\n-   Right sees black → steer right\n-   Left sees black → steer left\n-   Both black → stop (e.g., junction/finish)\n\nTweak `MOTOR_SPEED` to set base speed.\n\n### 2) Advanced five-sensor PID control\n\nFile: `main_pid.ino`\n\nFeatures:\n\n-   Automatic sensor calibration on startup (3s)\n-   Weighted average line position (0..4000)\n-   PID correction for smooth, fast tracking\n-   Line-loss handling that steers back towards last seen direction\n\nKey parameters:\n\n-   `BASE_SPEED` (default 150), `MAX_SPEED` (255)\n-   PID gains: `Kp`, `Ki`, `Kd`\n-   `CALIBRATION_TIME_MS` (default 3000)\n\nUpload either sketch as-is depending on your hardware.\n\n---\n\n## PID Tuning (quick guide)\n\n1. Start with `Ki = 0`, moderate `BASE_SPEED` (120–160).\n2. Increase `Kp` until it oscillates, then back off ~20%.\n3. Raise `Kd` to damp oscillations and improve cornering.\n4. Add small `Ki` only if there’s consistent bias/drift.\n\nSymptoms:\n\n-   Wobble → decrease `Kp` or increase `Kd`\n-   Slow response → increase `Kp`\n-   Corner overshoot → increase `Kd` or reduce `BASE_SPEED`\n\n---\n\n## Build and Run\n\n1. Assemble hardware per wiring above.\n2. Place robot over the track; ensure strong contrast (matte black line on matte white).\n3. Upload `main.ino` for a quick test, then `main_pid.ino` for competition performance.\n4. With PID sketch, on power-up it calibrates for ~3s. Slowly move the robot across the line during this period.\n5. Adjust gains and `BASE_SPEED` to your track.\n\n---\n\n## Repository Structure\n\n-   `main.ino` — basic digital 2-sensor controller\n-   `main_pid.ino` — advanced analog 5-sensor PID controller\n-   `README.md` — documentation, wiring, tuning\n\n---\n\n## Troubleshooting\n\n-   Robot veers consistently: check sensor heights (2–3 mm), parallelism, and add `Ki` slightly.\n-   Random jitter: ensure clean power, common ground, decouple with 100 µF near driver.\n-   Misses sharp turns: increase `Kd`, or raise `BASE_SPEED` slightly for better angular authority.\n-   Loses line on gaps: ensure line contrast; the sketch biases towards last known direction.\n\n---\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmed-maher77%2Fline_follower_robot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahmed-maher77%2Fline_follower_robot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmed-maher77%2Fline_follower_robot/lists"}