servo
Dependencies: Servo mbed tsi_sensor SLCD
Revision 1:854f2f39affd, committed 2016-03-22
- Comitter:
- sim2egor
- Date:
- Tue Mar 22 17:00:58 2016 +0000
- Parent:
- 0:f5fd64350b21
- Commit message:
- ALL NEW
Changed in this revision
SLCD.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f5fd64350b21 -r 854f2f39affd SLCD.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SLCD.lib Tue Mar 22 17:00:58 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Sissors/code/SLCD/#ef2b3b7f1b01
diff -r f5fd64350b21 -r 854f2f39affd main.cpp --- a/main.cpp Wed Mar 02 17:43:46 2016 +0000 +++ b/main.cpp Tue Mar 22 17:00:58 2016 +0000 @@ -1,21 +1,60 @@ -#include "mbed.h" + #include "mbed.h" #include "tsi_sensor.h" #include "Servo.h" +#include "SLCD.h" //для FRDM-46Z slider #define ELEC0 9 #define ELEC1 10 -DigitalOut gpo(D0); +//DigitalOut gpo(D0); +//DigitalOut gpo(D1); +//Servo myservo(D0); +SLCD slcd; +InterruptIn sw2(SW1); Servo myservo(D0); +PwmOut led(D1); +int Flag=0; +void sw2_release(void) +{ + Flag=1; +} + int main() { - PwmOut led(LED_GREEN); - TSIAnalogSlider tsi(ELEC0, ELEC1, 40); - + int angle =30; +// TSIAnalogSlider tsi(ELEC0, ELEC1, 40); + float delay1= 0.02f; + sw2.rise(&sw2_release); while (true) { - led = 1.0 - tsi.readPercentage(); - myservo=1.0- tsi.readPercentage(); - wait(0.2f); + for(int i=0; i<100;i++) + { + if(Flag) goto a1; + led = 1.0 - i/100; + for( int j=0; j<=angle; j++) + { + myservo.position((float)j); + wait(delay1); + } + + for( int j=angle; j>=-angle; j--) + { + myservo.position((float)j); + slcd.Home(); + slcd.printf("%d",j); + + wait(delay1); + } + for( int j=-angle; j<=0; j++) + { + myservo.position((float)j); + wait(delay1); + } + + } + } +a1: myservo.position(0.0f); + while (1){ + }; } \ No newline at end of file