Hideki Tanaka
/
MPR121_GR-PEACH
mpr121_test
Fork of MPR121_HelloWorld by
main.cpp
- Committer:
- hidekich1
- Date:
- 2017-10-15
- Revision:
- 4:3d8d61d68c76
- Parent:
- 3:ec2067fd8d0c
File content as of revision 4:3d8d61d68c76:
#include "mbed.h" #include "MPR121.h" Serial pc(USBTX, USBRX); DigitalOut myled(LED1); I2C i2c(P1_3, P1_2); InterruptIn irq(P10_12); MPR121 touch_pad(i2c, irq, MPR121::ADDR_VSS); /* #if defined TARGET_LPC1768 || TARGET_LPC11U24 I2C i2c(p28, p27); InterruptIn irq(p26); MPR121 touch_pad(i2c, irq, MPR121::ADDR_VSS); #elif defined TARGET_KL25Z I2C i2c(PTC9, PTC8); InterruptIn irq(PTA5); MPR121 touch_pad(i2c, irq, MPR121::ADDR_VSS); #else #error TARGET NOT TESTED #endif */ int main() { touch_pad.init(); touch_pad.enable(); // touch_pad.registerDump(pc); while(1) { if(touch_pad.isPressed()) { uint16_t button_val = touch_pad.buttonPressed(); pc.printf("button = 0x%04x\n", button_val); myled = (button_val>0) ? 1 : 0; } } }