go_away

Author Topic: c program for sonar for atmega8  (Read 4025 times)

0 Members and 1 Guest are viewing this topic.

Offline loboTopic starter

  • Jr. Member
  • **
  • Posts: 21
  • Helpful? 0
c program for sonar for atmega8
« on: October 01, 2008, 12:00:19 AM »
I was wondering if someone already posted a program in c for atmega8 to use for the parallax sonar.
I have two sonars and would like to write or paste a c program to uilize both for object avoidance.

thanks guys in advance.

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
Re: c program for sonar for atmega8
« Reply #1 on: October 01, 2008, 05:42:50 AM »
If you search for Ping, you'll find it.
Check out the uBotino robot controller!

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: c program for sonar for atmega8
« Reply #2 on: October 01, 2008, 12:42:18 PM »
Click the link in my signature

Offline fendi

  • Beginner
  • *
  • Posts: 5
  • Helpful? 0
Re: c program for sonar for atmega8
« Reply #3 on: October 19, 2008, 10:15:02 AM »
this is my example program using parallax in atmega16.


           
void parallax(void)
{
start:
      t=1;   
      DDRB.0=1;//set PORTB.0 as output n pull up
      PORTB.0=1;
      delay_us(5);
      PORTB.0=0;  //set PORT B.0 as input
      DDRB.0=0;
      PORTB.0=1 ;
     
      for(i=0;i<1050;i++) //if there is no echo recive till i=1050 go to start
        {
        if(PINB.0==1)//recive echo
        goto coun;
        }
goto start;   
coun:
        if(PINB.0==0)
        goto hitung;
        t=t+1 ;
        delay_us(1);
goto coun;
hitung:       
        s=340*1000000*t/2     //count the distance in m
        delay_ms(10);
return;
}

 


Get Your Ad Here