Git Product home page Git Product logo

line-follower-robot's Introduction

Line Follower Robot

This Arduino project provides a modularized approach for controlling a robot using PID-based line following with sensor feedback.

Components

1. Motors

  • Attributes:

    • normal_speed: Normal speed of the motors.
    • min_speed: Minimum allowable speed.
    • max_speed: Maximum allowable speed.
    • Pins for left and right motor control (left_in1, left_in2, left_en, right_in1, right_in2, right_en).
  • Methods:

    • initialize(): Sets up the motor control pins.
    • set_motor(int in1, int in2, int en, int speed): Controls individual motors.
    • get_direction(int speed): Determines motor direction.
    • normalize_speed(int speed): Ensures speed stays within defined limits.
    • drive(int speed_difference, bool debug): Drives the robot with a speed difference between left and right motors.

2. PID (Proportional-Integral-Derivative) Controller

  • Attributes:

    • KP: Proportional gain.
    • KI: Integral gain.
    • KD: Derivative gain.
    • last_proportional, integral: Trackers for PID calculations.
  • Methods:

    • calculate_speed_difference(int proportional): Computes the speed difference using PID control.

3. Sensors

  • Attributes:

    • threshold: Threshold value for line detection.
    • sensors_count: Number of sensors.
    • sensor_pins: Array of pins for individual sensors.
    • errors: Array of error values corresponding to different line positions.
    • previous_error: Tracks the previous error value.
  • Methods:

    • calculate_error(): Calculates the error based on sensor readings.
    • on_line(int sensor_pin): Checks if a sensor is on the line.
    • get_line_position(): Determines the position of the line based on sensor readings.

Settings

User-configurable settings for threshold, sensor count, sensor pins, errors, motor speeds, PID gains, debugging, and delay time.

Implementation

  1. Initialize Components:

    • Set up motor control and serial communication.
    • Adjust PID and sensor settings.
  2. Main Loop:

    • Continuously calculate sensor error.
    • Use PID controller to determine speed difference.
    • Drive the motors accordingly.
  3. Debugging:

    • Optionally print error and speed difference values to Serial for debugging purposes.

line-follower-robot's People

Contributors

navidadelpour avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.