Society of Robots - Robot Forum
Software => Software => Topic started by: corwin01 on December 01, 2009, 03:58:11 AM
-
I'm trying to write a program in C to have my robot solve a maze. It has 2 servos and 3 IR sensors. Using an ATmega8 28-pin chip.
I have absolutely no idea how I'm supposed to reference my servos or sensors in my program, and the examples that I've seen (search for here) don't really shed any light on it.
So anyone have some good advice or a nice tutorial on how I can handle these issues?
-
this may have something in it but i have
hope it helps or is relevant
http://neonatus.net/C/index.html (http://neonatus.net/C/index.html)
-
Check all of the SoR tutorials, there are clues in them:
http://www.societyofrobots.com/robot_tutorial_index.shtml (http://www.societyofrobots.com/robot_tutorial_index.shtml)
This one will help to map your sensors to the environment:
http://www.societyofrobots.com/programming_wavefront.shtml (http://www.societyofrobots.com/programming_wavefront.shtml)
And one on using IR range finders:
http://www.societyofrobots.com/sensors_sharpirrange.shtml (http://www.societyofrobots.com/sensors_sharpirrange.shtml)
-
I should be more specific.
I have my algorithm ready in pseudo code. I know how to program.
Its just the commands I need to use to tell my robot what to do.
Example (someone elses code here)
#define sensor_port PORTD
#define sensor_pin PIND
#define sensor_ddr DDRD
int forward()
{
PORTD&=~(_BV(Motor_L1)); //turn Off PD6
PORTD|=_BV(Motor_L2)|_BV(Motor_R2)|_BV(Motor_R1); //turn On PD7, PD4 and PD5
return 0;
}
int reverse()
{
PORTD&=~(_BV(Motor_L2)); //turn Off PD7
PORTD|=_BV(Motor_L1)|_BV(Motor_R1)|_BV(Motor_R2); //turn On PD6, PD5 and PD4
return 0;
}
What is _BV?
I realize that most of this is specific to what I connect to which pins, but theres a bunch of stuff in code snippets I've seen that just confuses me.
-
What confuses you?
Most of the answers you are looking for are in the datasheet of you MC.