ttp223_usb_serial.ino 383 B

12345678910111213141516171819202122
  1. #define PIN_IO 12
  2. int touch_val = 0;
  3. void setup() {
  4. pinMode(PIN_IO,INPUT);
  5. pinMode(LED_BUILTIN, OUTPUT);
  6. Serial.begin(115200);
  7. }
  8. void loop() {
  9. touch_val = digitalRead(PIN_IO);
  10. digitalWrite(LED_BUILTIN,touch_val);
  11. if(touch_val == HIGH){
  12. Serial.println("BS=1");
  13. Serial.write(1);
  14. }else{
  15. Serial.println("BS=0");
  16. Serial.write(1);
  17. }
  18. delay(1000);
  19. }