go_away

Author Topic: Need help starting out  (Read 1064 times)

0 Members and 1 Guest are viewing this topic.

Offline corwin01Topic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
Need help starting out
« 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?

Offline Joker94

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: Need help starting out
« Reply #1 on: December 01, 2009, 05:03:12 AM »
this may have something in it but i have

hope it helps or is relevant

http://neonatus.net/C/index.html

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 98
Re: Need help starting out
« Reply #2 on: December 01, 2009, 09:47:19 AM »
Check all of the SoR tutorials, there are clues in them:
 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

And one on using IR range finders:
http://www.societyofrobots.com/sensors_sharpirrange.shtml
« Last Edit: December 01, 2009, 09:53:05 AM by waltr »

Offline corwin01Topic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
Re: Need help starting out
« Reply #3 on: December 01, 2009, 02:30:43 PM »
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.

Offline chelmi

  • Supreme Robot
  • *****
  • Posts: 496
  • Helpful? 15
Re: Need help starting out
« Reply #4 on: December 01, 2009, 02:41:31 PM »
What confuses you?

Most of the answers you are looking for are in the datasheet of you MC.

 


Get Your Ad Here