This is some awesome robot code

Dependencies:   mbed-rtos mbed QEI

Fork of ICRSEurobot13 by Thomas Branch

Committer:
madcowswe
Date:
Sun Apr 14 17:22:20 2013 +0000
Revision:
66:f1d75e51398d
Obstacle avoidance working smoothly, fairly hacked motion-ai communication of override

Who changed what in which revision?

UserRevisionLine numberNew contents of line
madcowswe 66:f1d75e51398d 1 #include "mbed.h"
madcowswe 66:f1d75e51398d 2
madcowswe 66:f1d75e51398d 3 class AvoidDstSensor{
madcowswe 66:f1d75e51398d 4 private:
madcowswe 66:f1d75e51398d 5 AnalogIn ain;
madcowswe 66:f1d75e51398d 6
madcowswe 66:f1d75e51398d 7 public:
madcowswe 66:f1d75e51398d 8 AvoidDstSensor(PinName analoginpin) : ain(analoginpin){}
madcowswe 66:f1d75e51398d 9
madcowswe 66:f1d75e51398d 10 float Raw(){return ain;}
madcowswe 66:f1d75e51398d 11
madcowswe 66:f1d75e51398d 12 float Distanceincm(){
madcowswe 66:f1d75e51398d 13 float d = ((1.0f/ain)-0.5f)*(1.0f/0.11f);
madcowswe 66:f1d75e51398d 14 d = (d < 10 || d > 50)? -1:d;
madcowswe 66:f1d75e51398d 15 return d;
madcowswe 66:f1d75e51398d 16 }
madcowswe 66:f1d75e51398d 17 };