View Single Post
  #1   Spotlight this post!  
Unread 24-03-2006, 21:39
jeffmorris jeffmorris is offline
Registered User
no team
 
Join Date: Sep 2005
Location: staten island, ny
Posts: 62
jeffmorris is on a distinguished road
Radio Control and Ultrasonic Sensor

I wrote a program using Easy C 2.0 that lets me control a car using radio control until the ultrasonic sensor detects that the car is going to crash into something and stops the motors so that the car doesn't crash into something. One problem: because the value of the sensor reading is still under 20 after the motors are stopped, I can't control the car using radio control. Any suggestions?

Code:
#include "Main.h"

void main ( void )
{
      int loop = 1; 
      int ultrasonic; 

      //Connect Input Wire to Digital Output 11
      //Connect Output wire to Interrupt 1
      //Near = 2, Far = 100
      StartUltrasonic ( 1 , 11 ) ; // interrupt 1= output label on sensor, DO11=input label on sensor
      while ( loop == 1 )
      {
            ultrasonic = GetUltrasonic ( 1 , 11 ) ;
            if ( ultrasonic > 20 )
            {
                  Arcade2 ( 0 , 2 , 4 , 3 , 2 , 0 , 0 ) ;
            }
            else
            {
                  SetMotor ( 2 , 127 ) ;
                  SetMotor ( 3 , 127 ) ;
            }
      }
}
Reply With Quote