Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
documentation:microcontroleurs:arduino:modules:tactile_sensors:index [2021/08/02 17:49] – [TACTILE SENSOR MODULE (KY-036)] f1sls | documentation:microcontroleurs:arduino:modules:tactile_sensors:index [2024/10/12 11:11] (Version actuelle) – [ARDUINO WIRING] f1sls | ||
---|---|---|---|
Ligne 9: | Ligne 9: | ||
{{: | {{: | ||
===== ARDUINO WIRING ===== | ===== ARDUINO WIRING ===== | ||
+ | {{: | ||
===== CODE ===== | ===== CODE ===== | ||
+ | ==== EXAMPLE #1 ==== | ||
+ | <code cpp> | ||
+ | // Arduino and KY-036 module | ||
+ | |||
+ | void setup () | ||
+ | { | ||
+ | pinMode (13, OUTPUT); // built-in LED pin set to output | ||
+ | pinMode (8, INPUT); // module digital output connected to Arduino pin 8 | ||
+ | Serial.begin(9600); | ||
+ | } | ||
+ | |||
+ | void loop () | ||
+ | { | ||
+ | // display analog and digital values to serial | ||
+ | Serial.print(" | ||
+ | Serial.print(analogRead(A0)); | ||
+ | |||
+ | Serial.print(" | ||
+ | |||
+ | if (digitalRead(8) == HIGH) { | ||
+ | Serial.println(" | ||
+ | digitalWrite (13, HIGH); // if module value is higher than threshold, | ||
+ | // switch-On built-in LED | ||
+ | } | ||
+ | else { | ||
+ | Serial.println(" | ||
+ | digitalWrite (13, LOW); | ||
+ | } | ||
+ | |||
+ | delay(100); // wait 100 milliSeconds | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||