View Single Post
  #12   Spotlight this post!  
Unread 14-01-2013, 14:31
DjScribbles DjScribbles is offline
Programming Mentor
AKA: Joe S
FRC #2474 (Team Excel)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Niles MI
Posts: 284
DjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to behold
Re: Programming ultrasonic rangefinders

You would instance it much like you would a jaguar, or any other device.

Code:
#include "AnalogRangeFinder.h"

#define ANALOG_CHANNEL_FOR_SONAR 1

class Robot2012 : public IterativeRobot
{
   AnalogRangeFinder sonar;
   public:
   Robot2012(void):sonar(ANALOG_CHANNEL_FOR_SONAR)
   {
   }

   void AutonomousPeriodic(void)
   {
       float distance = sonar.GetRangeInches();
   }
}

START_ROBOT_CLASS(Robot2012);
Reply With Quote