Simple demo reads the KL46Z's touch device and displays the value on the LCD

Dependencies:   SLCD mbed tsi_sensor

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "SLCD.h"
00003 #include "tsi_sensor.h"
00004 
00005 // Very simple program to read the analog slider and print its value
00006 // on the LCD. Also flashes the RED led.
00007 // -- Al Williams
00008 
00009 /* This defines will be replaced by PinNames soon */
00010 #if defined (TARGET_KL25Z) || defined (TARGET_KL46Z)
00011   #define ELEC0 9
00012   #define ELEC1 10
00013 #elif defined (TARGET_KL05Z)
00014   #define ELEC0 9
00015   #define ELEC1 8
00016 #else
00017   #error TARGET NOT DEFINED
00018 #endif
00019 
00020     TSIAnalogSlider tsi(ELEC0, ELEC1, 40);
00021     
00022         
00023 
00024 DigitalOut gpo(D0);
00025 DigitalOut led(LED_RED);
00026 
00027 
00028     SLCD slcd;
00029 int main()
00030 {
00031     while (true) {
00032         float f=tsi.readPercentage();
00033         slcd.printf("%1.3f",f);
00034         led = !led; // toggle led
00035         wait(0.2f);
00036     }
00037 }