Line Following Robot Shield! + code

So after 3 versions of this shield I have finally decided to keep the 3rd version, yes it can be improved but it functions and that's what is important. So without further ado here are the pictures:

another picture

I have the printable pcb design if anyone wants it just say it.

So here is how it works:

It takes readings from the photocells about the brightness on each side of the tape. if the brightness goes low (with black tape) then the corresponding motor on that side that went low also goes low (slows down). that means the other wheel now turns the whole robot back to where it should be.

Follow the first picture to see where to connect the sensors and LED's (to light up the ground), and the motors. The +5v pin in the middle is for testing purposes and you definitely do NOT want to use it while your arduino has an external power supply because this will put ALOT of stress on the voltage regulator.

The external pins gnd and +vcc are for the external power to the motors. This is where you can hook up a battery (maybe 6v).
SO you will need a battery for the arduino board and a battery for the motors.

Here is the code, if there are any questions just ask!

int Lm = 10; // left motor
int Rm = 9; // right motor

int lval = 0; 
int rval = 0;
int lval2;
int rval2;
int lval3;
int rval3;

int LED1 = 2; 
int LED2 = 3;

void setup() {  
  
pinMode(LED1, OUTPUT);   
pinMode(LED2, OUTPUT); 
  pinMode(Lm, OUTPUT);     
  pinMode(Rm, OUTPUT);   


 
}

void loop() {
   digitalWrite(LED1,HIGH);
 digitalWrite(LED2,HIGH);
  
  lval = analogRead(0); //reads sensor pin, in this case A0
rval = analogRead(1);  // reads A1
 
 lval2 = map(lval, 0, 1023, 0, 255);   
 rval2 = map(rval, 0, 1023, 0, 255);
 

 rval3 = rval2+(64);
 lval3 = lval2+(80);
 
 analogWrite(Rm,rval3); //spins the right motor with the value of rval3
analogWrite(Lm,lval3); 
  

 }

Is there anyway you could make a little track for your line follower and take a video of it?
Then maybe post it to youtube or vimeo and put a link here 8)

This could be very nice little project :slight_smile:

MCmuffin:
Is there anyway you could make a little track for your line follower and take a video of it?
Then maybe post it to youtube or vimeo and put a link here 8)

This could be very nice little project :slight_smile:

yes! I can do that but I need to tweak the coding and finish the robot body but when I'm done my other projects I will definitely try and make a youtube video of it

What transistors/FETs did you use (can't see model or manufacturer in the pictures)?
and do you mind attaching a photo of your pcb design so I can make a schematic for it?
I'll put the ready schematic here later and Eagle file so anyone can easily make their own pcb for it.

I'm doing this project right now. Thanks to you :slight_smile:

MCmuffin:
What transistors/FETs did you use (can't see model or manufacturer in the pictures)?
and do you mind attaching a photo of your pcb design so I can make a schematic for it?
I'll put the ready schematic here later and Eagle file so anyone can easily make their own pcb for it.

I'm doing this project right now. Thanks to you :slight_smile:

yesyes! by all means ! Here is a PCB design and the MOSFET's I am using are the IRFZ44V but I'm sure you can use any equivalent one.

I'ts a PDF file with multiple copies of the design so as to not waste paper: