Sprint One / NervousPuppySprintOne

Dependencies:   C12832 Servo mbed-rtos-edited mbed

Fork of NervousPuppy by Sean Doyle

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers nervousPuppy.cpp Source File

nervousPuppy.cpp

00001 #include "nervousPuppy.h"
00002 
00003 /**
00004  *  Constructor - contains running loop
00005  */
00006  
00007 Servo tilt(p21);
00008 Servo rotate(p22);      
00009 AnalogIn ainLeft(p15);
00010 AnalogIn ainRight(p16);
00011 
00012 C12832 lcd(p5, p7, p6, p8, p11);
00013 
00014 
00015 nervousPuppy::nervousPuppy(){
00016     rotation = 0;
00017     int pos = 1000;
00018     rotate.Enable(1000,20000);
00019     while(1){
00020         
00021 
00022         float x = 100*ainRight.read();
00023         float y = 100*ainLeft.read();
00024         
00025 
00026         lcd.cls();
00027         lcd.locate(0,3);
00028         lcd.printf("x = %f",x);
00029         lcd.printf(" y = %f",y);
00030         
00031         
00032         if(y > 3.5 && x < 3.5){
00033             lcd.printf("rotating by ,%f",pos);
00034             pos += 50;
00035             rotate.SetPosition(pos);
00036         }else if(x > 3.5 && y < 3.5){
00037             lcd.printf("rotating by ,%f", pos);
00038             pos -= 50;
00039             rotate.SetPosition(pos);
00040         }
00041         
00042     }
00043 }
00044 
00045 
00046 
00047 int main(){
00048     nervousPuppy();
00049 }