ttp223_touch_test.ino 826 B

12345678910111213141516171819202122232425262728293031323334
  1. #include "BluetoothSerial.h"
  2. BluetoothSerial SerialBT;
  3. #define PIN_IO 12
  4. int touch_val = 0;
  5. void setup() {
  6. // put your setup code here, to run once:
  7. pinMode(PIN_IO,INPUT);
  8. pinMode(LED_BUILTIN, OUTPUT);
  9. Serial.begin(115200);
  10. SerialBT.begin("brakeMonitor");
  11. Serial.println("The brake monitor is ready. Connect via bluetooth");
  12. }
  13. void loop() {
  14. // put your main code here, to run repeatedly:
  15. touch_val = digitalRead(PIN_IO);
  16. digitalWrite(LED_BUILTIN,touch_val);
  17. SerialBT.println("Brake Status:");
  18. if(touch_val == HIGH){
  19. SerialBT.println(" X");
  20. SerialBT.println(" XXX");
  21. SerialBT.println(" XXXXX");
  22. SerialBT.println(" XXXXXXX");
  23. SerialBT.println(" XXXXXXXXX");
  24. SerialBT.println(" X");
  25. }else{
  26. SerialBT.println("GRINCH");
  27. }
  28. delay(500);
  29. }