Primera prueba...

Dependencies:   SLCD Servo mbed tsi_sensor

Committer:
juanjosecastillo
Date:
Sat Jan 03 03:53:02 2015 +0000
Revision:
0:6d8690fad6a1
Falta...

Who changed what in which revision?

UserRevisionLine numberNew contents of line
juanjosecastillo 0:6d8690fad6a1 1 #include "mbed.h"
juanjosecastillo 0:6d8690fad6a1 2 #include "Servo.h"
juanjosecastillo 0:6d8690fad6a1 3 #include "tsi_sensor.h"
juanjosecastillo 0:6d8690fad6a1 4 #define LCDLEN 10
juanjosecastillo 0:6d8690fad6a1 5 #include "SLCD.h"
juanjosecastillo 0:6d8690fad6a1 6
juanjosecastillo 0:6d8690fad6a1 7 /* This defines will be replaced by PinNames soon */
juanjosecastillo 0:6d8690fad6a1 8 #if defined (TARGET_KL25Z) || defined (TARGET_KL46Z)
juanjosecastillo 0:6d8690fad6a1 9 #define ELEC0 9
juanjosecastillo 0:6d8690fad6a1 10 #define ELEC1 10
juanjosecastillo 0:6d8690fad6a1 11 #elif defined (TARGET_KL05Z)
juanjosecastillo 0:6d8690fad6a1 12 #define ELEC0 9
juanjosecastillo 0:6d8690fad6a1 13 #define ELEC1 8
juanjosecastillo 0:6d8690fad6a1 14 #else
juanjosecastillo 0:6d8690fad6a1 15 #error TARGET NOT DEFINED
juanjosecastillo 0:6d8690fad6a1 16 #endif
juanjosecastillo 0:6d8690fad6a1 17 TSIAnalogSlider tsi(ELEC0, ELEC1, 40);
juanjosecastillo 0:6d8690fad6a1 18
juanjosecastillo 0:6d8690fad6a1 19 Servo s1(PTA13);
juanjosecastillo 0:6d8690fad6a1 20 SLCD slcd; //define LCD display
juanjosecastillo 0:6d8690fad6a1 21
juanjosecastillo 0:6d8690fad6a1 22
juanjosecastillo 0:6d8690fad6a1 23
juanjosecastillo 0:6d8690fad6a1 24
juanjosecastillo 0:6d8690fad6a1 25 int main() {
juanjosecastillo 0:6d8690fad6a1 26
juanjosecastillo 0:6d8690fad6a1 27 float valor=0;
juanjosecastillo 0:6d8690fad6a1 28 //char lcdData[LCDLEN];
juanjosecastillo 0:6d8690fad6a1 29 while(1) {
juanjosecastillo 0:6d8690fad6a1 30 //s1.write(tsi.readPercentage());
juanjosecastillo 0:6d8690fad6a1 31
juanjosecastillo 0:6d8690fad6a1 32
juanjosecastillo 0:6d8690fad6a1 33
juanjosecastillo 0:6d8690fad6a1 34 //LCDMessNoDwell();
juanjosecastillo 0:6d8690fad6a1 35 //slcd.printf( "%f",tsi.readPercentage());
juanjosecastillo 0:6d8690fad6a1 36
juanjosecastillo 0:6d8690fad6a1 37 slcd.clear(); // All segments off
juanjosecastillo 0:6d8690fad6a1 38 slcd.Home(); // sets next charater to posistion 0 (start)
juanjosecastillo 0:6d8690fad6a1 39 //valor=tsi.readPercentage();
juanjosecastillo 0:6d8690fad6a1 40 PwmOut led(LED_GREEN);
juanjosecastillo 0:6d8690fad6a1 41 valor=tsi.readPercentage();
juanjosecastillo 0:6d8690fad6a1 42 if (valor < 10)
juanjosecastillo 0:6d8690fad6a1 43 {
juanjosecastillo 0:6d8690fad6a1 44 //valor=0.5;
juanjosecastillo 0:6d8690fad6a1 45 led = 1.0 - 0.5;
juanjosecastillo 0:6d8690fad6a1 46 s1.write(0.5);
juanjosecastillo 0:6d8690fad6a1 47 slcd.printf("%2.2f",0.5);
juanjosecastillo 0:6d8690fad6a1 48 }
juanjosecastillo 0:6d8690fad6a1 49 else
juanjosecastillo 0:6d8690fad6a1 50 {
juanjosecastillo 0:6d8690fad6a1 51
juanjosecastillo 0:6d8690fad6a1 52 led = 1.0 - valor;
juanjosecastillo 0:6d8690fad6a1 53 s1.write(valor);
juanjosecastillo 0:6d8690fad6a1 54 slcd.printf("%2.2f",valor);
juanjosecastillo 0:6d8690fad6a1 55
juanjosecastillo 0:6d8690fad6a1 56 }
juanjosecastillo 0:6d8690fad6a1 57
juanjosecastillo 0:6d8690fad6a1 58
juanjosecastillo 0:6d8690fad6a1 59 wait(0.1);
juanjosecastillo 0:6d8690fad6a1 60 }
juanjosecastillo 0:6d8690fad6a1 61 }