a simple library to control an animatronic head
Diff: Alex.cpp
- Revision:
- 0:8474cbec06bd
- Child:
- 1:c5edd3b18b79
diff -r 000000000000 -r 8474cbec06bd Alex.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Alex.cpp Sun Dec 12 14:15:07 2010 +0000 @@ -0,0 +1,55 @@ +#include "Alex.h" +Serial pc(USBTX, USBRX); // tx, rx => serialize mBed with the pc +PwmOut Led(LED1); + +Alex::Alex(SRF05 s, Servo e, Servo m, Servo l, Servo r):S(s), E(e), M(m), L(l), R(r) +{ +} +Alex::~Alex() +{ +} +void Alex::TestHead() +{ + Led=1; + wait(0.02); + Led=0; +} +int Alex::Testpresence() +{ + if((S.read()==0)||(S.read()>=500)){return 0;}//if presence is too close, return 0 + if(S.read()>=40){return 1;}//if presence is too far, return 1 + if((S.read()>=0)&&(S.read()<=40)){return 2;}//if presence is between O and 40cm, return 2 + return 0; +} +void Alex::Move_eyes(int valuee) +{ + for(int i=0; i<valuee; i++) + { + E=i; + wait(0.1); + } +} +void Alex::Move_mouth(int valuem) +{ + for(int i=0; i<valuem; i++) + { + M=i; + wait(0.1); + } +} +void Alex::Move_leaning(int valuel) +{ + for(int i=0; i<valuel; i++) + { + L=i; + wait(0.1); + } +} +void Alex::Move_rotation(int valuer) +{ + for(int i=0; i<valuer; i++) + { + R=i; + wait(0.1); + } +} \ No newline at end of file