...using arduino. If you don't click on the link, it's a toy car made to follow along walls as if there's a race track. One sensor looking front, another looking to the right, and the code for it is basically if something in front then turn left and go to main, if something closer than x cm to the right then turn left and go to main, if nothing in front and something closer than 70 cm to the right then drive ahead and go to main, if nothing to the right closer than x cm then turn right and go to main.
I'm waiting on an order or relays, I have some great sensors, I'm mostly into mechanics side of making a robot (good with tools, metals, I just prefer building in general) but a friend showed me this and it seemed simple enough, I just want it as a project. I'm not too great at programming though I understand basics of C and such, I was taught in python. This site recommends and gives instructions for picaxe but I have an arduino board already on me and I'm told it's easier using that. I'm at a uni with an amazing roboclub so I have good access to things. Can someone help out a bit just with how I'd hook this up and the programming?
Thanks, I mean I've been using the arduino tutorial but I'm using 2 hc-sr04 sensors. I've read around and they say to divide by 15 to get the cm measurement. I've been trying to find some help with that but can't.
this pertains directly to the sensors you are using, and has a link to download the library for those sensors. One of the functions helps you find the distance in cm...
void loop()
{
cm = ultrasonic.Ranging(CM);
cm_1 = ultrasonicside.Ranging(CM);
if (cm < 30)
{
turnRight()
}
if (cm_1 < 30)
{
turnLeft()
}
if ((cm > 30) and (cm_1 < 70))
{
driveAhead()
}
if (cm_1 > 70)
{
turnRight()
}
but I'm just not sure how to write just regular functions. I guess I can just edit the motors within, though I'm just trying to keep the code simple for me.