Created
August 7, 2020 14:19
-
-
Save ksasao/0aa735e854026b59d03d864d00af5c30 to your computer and use it in GitHub Desktop.
Touch sensor test for M5Atom. see https://twitter.com/ksasao/status/1291737731232493568
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Touch sensor test for M5Atom | |
| // see https://twitter.com/ksasao/status/1291737731232493568 | |
| #include<M5Atom.h> | |
| void set_led(uint8_t r, uint8_t g, uint8_t b){ | |
| int color = (g << 16) | (r << 8) | b; | |
| M5.dis.drawpix(0, color); | |
| delay(30); | |
| } | |
| void setup() { | |
| M5.begin(true,false,true); | |
| } | |
| void loop() { | |
| int sum = 0; | |
| for(int i=0; i<100;i++){ | |
| sum += touchRead(33); | |
| delay(1); | |
| } | |
| if(sum > 3300){ | |
| set_led(0,0,0); | |
| }else if(sum > 3050){ | |
| set_led(255,0,0); | |
| }else if(sum > 2700){ | |
| set_led(0,0,255); | |
| }else{ | |
| set_led(255,255,255); | |
| } | |
| Serial.println(sum); | |
| M5.update(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment