#include Adafruit_FreeTouch qt_0 = Adafruit_FreeTouch(A0, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE); Adafruit_FreeTouch qt_1 = Adafruit_FreeTouch(A1, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE); Adafruit_FreeTouch qt_6 = Adafruit_FreeTouch(A6, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE); Adafruit_FreeTouch qt_7 = Adafruit_FreeTouch(A7, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE); Adafruit_FreeTouch qt_8 = Adafruit_FreeTouch(A8, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE); Adafruit_FreeTouch qt_9 = Adafruit_FreeTouch(A9, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE); Adafruit_FreeTouch qt_10 = Adafruit_FreeTouch(A10, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE); #include uint8_t Key2;//pin2 bike sensor in void setup() { Keyboard.begin(); Serial.begin(115200); // initialize digital pin LED_BUILTIN as an output. pinMode(LED_BUILTIN, OUTPUT); pinMode(2, INPUT_PULLUP);//pin2 bike sensor in qt_0.begin(); qt_1.begin(); qt_6.begin(); qt_7.begin(); qt_8.begin(); qt_9.begin(); qt_10.begin(); } int qt_Threshold = 850; void loop() { Key2 = digitalRead(2);//pin2 bike sensor_in int qt0 = 0; int qt1 = 0; int qt6 = 0; int qt7 = 0; int qt8 = 0; int qt9 = 0; int qt10 = 0; qt0 = qt_0.measure(); qt1 = qt_1.measure(); qt6 = qt_6.measure(); qt7 = qt_7.measure(); qt8 = qt_8.measure(); qt9 = qt_9.measure(); qt10 = qt_10.measure(); /* Xiao |USB-C| |A0_qt0| |5V| |A1_qt1| |GND| |A2_bike| |3V3| |A3| |A10_qt10| |A4| |A9_qt9| |A5| |A8_qt8| |A6_qt6| |A7_qt7| */ if (Key2 == LOW ) { //pin2 bike sensor_in // XIAO: LOW means On = key pressed Key3_act(); } if (qt0 >= qt_Threshold) { Serial.print("qt0: "); Serial.println(qt0); Key2_act(); } if (qt1 >= qt_Threshold) { Serial.print("qt1: "); Serial.println(qt1); Key1_act(); } if (qt6 >= qt_Threshold) { Serial.print("qt6: "); Serial.println(qt6); Key3_act(); } if (qt7 >= qt_Threshold) { Serial.print("qt7: "); Serial.println(qt7); Key0_act(); } if (qt8 >= qt_Threshold) { Serial.print("qt8: "); Serial.println(qt8); Key1_act(); } if (qt9 >= qt_Threshold) { Serial.print("qt9: "); Serial.println(qt9); Key4_act(); } if (qt10 >= qt_Threshold) { Serial.print("qt10: "); Serial.println(qt10); Key3_act(); } //delay(100); } void Key0_act() { // <- Keyboard.press(KEY_RIGHT_ARROW); delay(400); Keyboard.releaseAll(); digitalWrite(LED_BUILTIN, LOW);// XIAOでは、LOW = On KeyRelease(); } void Key1_act() { // -> Keyboard.press(KEY_LEFT_ARROW); delay(400); Keyboard.releaseAll(); digitalWrite(LED_BUILTIN, LOW); KeyRelease(); } void Key2_act() { // down arrow Keyboard.press(KEY_DOWN_ARROW); delay(400); Keyboard.releaseAll(); digitalWrite(LED_BUILTIN, LOW); KeyRelease(); } void Key3_act() { // up arrow Keyboard.press(KEY_UP_ARROW); delay(200); Keyboard.releaseAll(); digitalWrite(LED_BUILTIN, LOW); KeyRelease(); } void Key4_act() { // feedback Keyboard.press(KEY_LEFT_CTRL); Keyboard.press(KEY_LEFT_SHIFT); Keyboard.write('f'); Keyboard.releaseAll(); digitalWrite(LED_BUILTIN, LOW); KeyRelease(); } void KeyRelease() { Keyboard.releaseAll(); delay(500); digitalWrite(LED_BUILTIN, HIGH);// XIAO HIGH = Off } /*Example Keyboard.write('a'); //press and release 'a' key uint8_t Multiple[3]= {'1','2','3'}; Keyboard.write(Multiple,3); //multiple keys sequentially from a buffer Keyboard.print("456"); //print a string Keyboard.println("789"); //print another string with a line Keyboard.press(KEY_LEFT_SHIFT); //hold down the shift Keyboard.println("a uppercase sentence"); //this will be all caps Keyboard.release(KEY_LEFT_SHIFT);//release the shift Keyboard.println ("back to lowercase"); Keyboard.press(KEY_LEFT_SHIFT); //press shift Keyboard.println("1234"); //some text Keyboard.releaseAll(); //release all Keyboard.println("1234"); //not shifted Keyboard.print("A mistake"); //will attempt to erase this delay(1000); Keyboard.press(KEY_LEFT_CTRL); //will attempt control-z Keyboard.write('z'); Keyboard.releaseAll(); //release the control key */