RC SERVO FOR KL46Z modificado con slider
Dependencies: SLCD Servo mbed tsi_sensor
Fork of SERVOCONTROL by
Diff: main.cpp
- Revision:
- 3:5b33be4b1a5a
- Parent:
- 2:3604d4f17475
--- a/main.cpp Tue Jul 22 18:39:01 2014 +0000 +++ b/main.cpp Sat Jan 03 03:57:15 2015 +0000 @@ -1,24 +1,50 @@ #include "mbed.h" #include "Servo.h" +#include "tsi_sensor.h" +#define LCDLEN 10 +#include "SLCD.h" + +/* This defines will be replaced by PinNames soon */ +#if defined (TARGET_KL25Z) || defined (TARGET_KL46Z) +#define ELEC0 9 +#define ELEC1 10 +#elif defined (TARGET_KL05Z) +#define ELEC0 9 +#define ELEC1 8 +#else +#error TARGET NOT DEFINED +#endif +TSIAnalogSlider tsi(ELEC0, ELEC1, 40); Servo s1(PTA13); - +SLCD slcd; //define LCD display +void LCDMessNoDwell() +{ + float value = tsi.readPercentage(); + char buffer[10]; -AnalogIn p1(PTB0); + slcd.Home(); + slcd.clear(); + slcd.printf(buffer, "%f",tsi.readPercentage()); +} -int main() { + +int main() +{ + + + //char lcdData[LCDLEN]; while(1) { - - /* s1.write(0); - wait(1.0); - s1.write(1); - wait(1.0); - -*/ - - s1=p1; - printf(" %f \r",p1.read()); - + float valor=0; + slcd.clear(); // All segments off + slcd.Home(); // sets next charater to posistion 0 (start) + valor=tsi.readPercentage(); + PwmOut led(LED_GREEN); + led = 1.0 - (valor*2); + s1.write(valor); + slcd.printf(" %2.2f",valor*10); + wait(0.1); + } }