proportional

Dependencies:   Motor mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "Motor.h"
00003 Serial pc(USBTX,USBRX);//allows communication through the USB
00004 AnalogIn range(p19);
00005 float height;
00006 float rv;
00007 float dh;
00008 float ds;
00009 float er;
00010 float k=0.15;
00011 Motor m(p26, p29, p30);
00012 int main()
00013 {
00014     
00015     m.speed(0);
00016     while(1){
00017         rv=range;
00018         height=(-75.7457492123552*pow(rv,2))+(90.6774745565381*rv)+(-4.00358328437282);
00019     pc.printf("%f,%f\n",rv,height);
00020     pc.printf("Enter desired height\n");
00021     pc.scanf("%f",&dh);
00022         er=dh-height;
00023         ds=k*er;
00024         m.speed(ds);
00025     
00026    
00027    
00028        } 
00029     }