![](/media/cache/profiles/6c18d13e9a2e04855a83a6ce1a9117fe.jpg.50x50_q85.jpg)
tsi_slider - an example for the tsi_sensor library. Read the capacitive touch slider of the FRDM-KL25Z board and control the power of the green LED accordingly.
/ tsi_slider - an example for the tsi_sensor library
- Read the capacitive touch slider of the FRDM-KL25Z board
- and control the power of the green LED accordingly.
- Hardware requirements:
- - Freescale FRDM-KL25Z board
- /
main.cpp@0:fe50a5288858, 2015-11-03 (annotated)
- Committer:
- icserny
- Date:
- Tue Nov 03 07:14:14 2015 +0000
- Revision:
- 0:fe50a5288858
First version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
icserny | 0:fe50a5288858 | 1 | /** tsi_slider - an example for the tsi_sensor library |
icserny | 0:fe50a5288858 | 2 | * |
icserny | 0:fe50a5288858 | 3 | * Read the capacitive touch slider of the FRDM-KL25Z board |
icserny | 0:fe50a5288858 | 4 | * and control the power of the green LED accordingly. |
icserny | 0:fe50a5288858 | 5 | * |
icserny | 0:fe50a5288858 | 6 | * Hardware requirements: |
icserny | 0:fe50a5288858 | 7 | * - Freescale FRDM-KL25Z board |
icserny | 0:fe50a5288858 | 8 | */ |
icserny | 0:fe50a5288858 | 9 | |
icserny | 0:fe50a5288858 | 10 | #include "mbed.h" |
icserny | 0:fe50a5288858 | 11 | #include "tsi_sensor.h" |
icserny | 0:fe50a5288858 | 12 | |
icserny | 0:fe50a5288858 | 13 | int main(void) { |
icserny | 0:fe50a5288858 | 14 | PwmOut led(LED_GREEN); //Configure PWM output for the green LED |
icserny | 0:fe50a5288858 | 15 | TSIAnalogSlider tsi(PTB16,PTB17,40);//Configure for the FRDM-KL25Z slider |
icserny | 0:fe50a5288858 | 16 | while (true) { |
icserny | 0:fe50a5288858 | 17 | float s = tsi.readPercentage(); //Read slider status |
icserny | 0:fe50a5288858 | 18 | led = 1.0 - s; //Control LED power |
icserny | 0:fe50a5288858 | 19 | wait(0.1); //wait a little... |
icserny | 0:fe50a5288858 | 20 | } |
icserny | 0:fe50a5288858 | 21 | } |