Convert touch slider to 4 touch buttons. Tested with FRDM-KL25Z built-in slider. Only 2 (TSIO) pins used to create 4 buttons.
Dependencies: TouchButton mbed
main.cpp
- Committer:
- virajjayaweera
- Date:
- 2013-07-13
- Revision:
- 1:16968eb482c8
- Parent:
- 0:381e7d9f3724
File content as of revision 1:16968eb482c8:
/* FRDM-KL25Z built-in touch slider is converted to a 4 touch buttons
*************************
* * * * *
* 1 * 2 * 3 * 4 *
* * * * *
*************************
* key 1 will lihght Red LED
* key 2 will lihght Green LED
* key 3 will lihght Blue LED
* key 4 will lihght White LED (R+G+B)
*/
#include "mbed.h"
#include "TouchButton.h"
DigitalOut myled1(LED1);
DigitalOut myled2(LED2);
DigitalOut myled3(LED3);
int main(void) {
TouchButton TButton;
int key=0;
while (true)
{
key=TButton.PresedButton();
if(key==0)
{
myled1 = 1;
myled2 = 1;
myled3 = 1;
}
else if(key==1)
{
myled1 = 1;
myled2 = 1;
myled3 = 0;
wait(0.1);
}
else if(key==2)
{
myled1 = 1;
myled2 = 0;
myled3 = 1;
wait(0.1);
}
else if(key==3)
{
myled1 = 0;
myled2 = 1;
myled3 = 1;
wait(0.1);
}
else
{
myled1 = 0;
myled2 = 0;
myled3 = 0;
wait(0.1);
}
}
}