![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
SSD541_HW5.1
Fork of kl46z_slider_v1 by
main.cpp
- Committer:
- eseifert
- Date:
- 2016-09-14
- Revision:
- 1:c3cfa0fd8ad7
- Parent:
- 0:04499bc54bee
File content as of revision 1:c3cfa0fd8ad7:
#include "mbed.h" #include "TSISensor.h" #include "SLCD.h" #define TSILIMIT 0.99 #define LCDCHARLEN 10 #define DATAINTERVAL 0.01 #define PROGNAME "kl46z_slider_test_v1\n\r" SLCD slcd; //define LCD display Serial pc(USBTX, USBRX); float tsidata; void LCDMess(char *lMess) { slcd.Home(); slcd.clear(); slcd.printf(lMess); } Timer WaitTimer; int main(void) { char lcdData[LCDCHARLEN]; PwmOut gled(LED_GREEN); PwmOut rled(LED_RED); pc.printf(PROGNAME); TSISensor tsi; WaitTimer.start(); WaitTimer.reset(); while (true) { WaitTimer.start(); tsidata = tsi.readPercentage(); if (tsidata > TSILIMIT) { gled = 0.0; rled = 0.0; } else { if(WaitTimer > DATAINTERVAL){ pc.printf("\n Position %f\n\r", tsidata); sprintf (lcdData,"%0.4f",tsidata); LCDMess(lcdData); gled = tsidata; rled = 1.0 - tsidata; WaitTimer.reset(); } } } }