Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
circuito.io team
Published

Light Painting Line Follower

Line followers follow lines, right? But what if you put some LEDs on top and use long exposure? Well, you get this!

IntermediateFull instructions provided8 hours5,654
Light Painting Line Follower

Things used in this project

Hardware components

Arduino Pro Mini 328 - 5V/16MHz
SparkFun Arduino Pro Mini 328 - 5V/16MHz
×1
DC motor (generic)
×2
L298N Motor Drive Board Module
×1
IR Infrared Line Track Follower Sensor TCRT5000
×3
SparkFun Neo Pixel Ring
×1

Software apps and online services

circuito.io
circuito.io

Story

Read more

Custom parts and enclosures

Hood for line follower

Code

Light Painting Line Follower

Arduino
Replace the original void loop () from the circuito.io reply, with the code below. You need the original code for the libraries.
void loop() {
  bool irLineFollow1Var = digitalRead(IRLINEFOLLOW1_PIN_OUT);
  bool irLineFollow2Var = digitalRead(IRLINEFOLLOW2_PIN_OUT);
  bool irLineFollow3Var = digitalRead(IRLINEFOLLOW3_PIN_OUT);

  //Serial.print(irLineFollow1Var);Serial.print("\t");Serial.print(irLineFollow2Var); Serial.print("\t");Serial.println(irLineFollow3Var);
  //delay(300);

  if (irLineFollow1Var && !irLineFollow2Var && irLineFollow3Var)
  {
    Serial.println("Straight");
    dcMotor.setMotorA(100, 1);
    dcMotor.setMotorB(100, 1);
  }
  else if (irLineFollow1Var && !irLineFollow2Var && !irLineFollow3Var)
  {
    Serial.println("Left");
    dcMotor.setMotorA(100, 1);
    dcMotor.setMotorB(70, 1);
  }
  else if (!irLineFollow1Var && !irLineFollow2Var && irLineFollow3Var)
  {
    Serial.println("Right");
    dcMotor.setMotorA(70, 1);
    dcMotor.setMotorB(100, 1);
  }
  else if (irLineFollow1Var && irLineFollow2Var && !irLineFollow3Var)
  {
    Serial.println("Strong Left");
    dcMotor.setMotorA(70, 0);
    dcMotor.setMotorB(100, 1);
  }
  else if (!irLineFollow1Var && irLineFollow2Var && irLineFollow3Var)
  {
    Serial.println("Strong Right");
    dcMotor.setMotorA(100, 1);
    dcMotor.setMotorB(70, 0);
  }
  else if (irLineFollow1Var && irLineFollow2Var && irLineFollow3Var)
  {
    Serial.println("Straight");
    dcMotor.setMotorA(100, 1);
    dcMotor.setMotorB(100, 1);
  }
  else
  {
    Serial.println("Stop");
    dcMotor.setMotorA(70, 1);
    dcMotor.setMotorB(70, 1);
  }




}

Credits

circuito.io team

circuito.io team

29 projects • 601 followers
Circuito.io is an online platform that generates wiring and code for Arduino projects. Want to know more? Visit http://circuito.io

Comments