I'm really sorry for not getting back with you sooner.
This sounds like a really cool project!
I'm trying to modify the funduino robot code so that the robot I have built follows LED's on a light grid I've constructed, I'm new to arduino and am struggling how to implement this in the code. I have modified the robot so that it has a chassis mounted LDR which is fed into an analogue pin on the UNO board, I'm not entirely sure how to implement this in the code though?
Can you explain what you mean by a "light grid"? Maybe post a pic if you have one?
You're talking about a photoresistor like the one below, right?
How did you wire it to the Arduino? Connecting the photoresistor directly from 5V or GND to the analog input pin will not allow you to measure the change in light intensity. What you'll have to do is use the LDR to make a voltage divider whose output will vary with the resistance of the LDR. Like this:
As explained in this tutorial.
That way, when the intensity of light changes, the output of the voltage divider (going to the analog input) will change, which you can monitor in your program.
After wiring your circuit like that, you can test the photoresistor with code like this:
int analogPin = 1;
int photoresistorValue = 0;
photoresistorValue = analogRead(analogPin);
Verify it works correctly (you should see the value changing with the intensity of the light), and then you can determine what threshold values to use in your state machine.
If possible I want to add an argument which dictates that when the LDR receives a set threshold from the the LED light source it will activate set movements before resetting to receive the next light value, I also need to keep the distance sensor as the LED light grid is built on a table with walls that stop the robot from riding over the edge.
If anyone can help me with this I'd be extremely grateful
Are you still wanting to use the ultrasonic sensor to avoid obstacles?
What kind of pre-programmed movements are you wanting the robot to execute when it drives over an LED?