Fixed Sonar
Dependencies: C12832 Servo mbed-rtos-edited mbed
Fork of NervousPuppy by
nervousPuppy.cpp
- Committer:
- SeanDoyle
- Date:
- 2015-01-28
- Revision:
- 7:8b2cf5e6e888
- Parent:
- 6:f854aa2f41e2
File content as of revision 7:8b2cf5e6e888:
#include "nervousPuppy.h" /** * Constructor - contains running loop */ Servo tilt(p21); Servo rotate(p22); AnalogIn ainLeft(p15); AnalogIn ainRight(p16); C12832 lcd(p5, p7, p6, p8, p11); nervousPuppy::nervousPuppy(){ rotation = 0; int pos = 1000; rotate.Enable(1000,20000); while(1){ float x = 100*ainRight.read(); float y = 100*ainLeft.read(); lcd.cls(); lcd.locate(0,3); lcd.printf("x = %f",x); lcd.printf(" y = %f",y); if(y > 3.5 && x < 3.5){ lcd.printf("rotating by ,%f",pos); pos += 50; rotate.SetPosition(pos); }else if(x > 3.5 && y < 3.5){ lcd.printf("rotating by ,%f", pos); pos -= 50; rotate.SetPosition(pos); } } } int main(){ nervousPuppy(); }