Last active
July 30, 2019 00:37
-
-
Save futureshocked/01d7c6dbb27a61e2fc08d83f316720f7 to your computer and use it in GitHub Desktop.
This sketch demonstrates how to use the Grove touch sensor. The touch sensor is a digital device (i.e. it can be "on" or "off" only).
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
| /* 03.030 - Grove touch sensor | |
| This sketch demonstrates how to use the Grove touch sensor. | |
| The touch sensor is a digital device (i.e. it can be "on" or "off" only). | |
| Components | |
| ---------- | |
| - Grove Base Shield | |
| - An Arduino Uno compatible board (such as Arduino/Genuino Uno or Seeeduino) | |
| - Grove Touch Sensor | |
| - One Grove cable | |
| IDE | |
| --- | |
| Arduino IDE | |
| Libraries | |
| --------- | |
| - | |
| Connections | |
| ----------- | |
| Use a Grove cable to connect the temperature module to Base Shield connector D2. | |
| Other information | |
| ----------------- | |
| - Use this sketch along side the video lecture 03.030 of Grove For Busy People | |
| - Original example sketch location: http://wiki.seeedstudio.com/Grove-Touch_Sensor/ | |
| - Grove component: https://txplo.re/63d60 | |
| Github Gist | |
| ----------- | |
| <script src="https://gist.github.com/futureshocked/01d7c6dbb27a61e2fc08d83f316720f7.js"></script> | |
| https://gist.github.com/futureshocked/01d7c6dbb27a61e2fc08d83f316720f7 | |
| For course information, please go to https://techexplorations.com/product/grove-for-busy-people/ | |
| Created on July 5 2019 by Peter Dalmaris | |
| */ | |
| const int touchPin = 4; // digital pin 4 is on Grove connector D4 | |
| const int ledPin = 13; // the number of the build-in LED pin | |
| void setup() { | |
| pinMode(touchPin, INPUT); | |
| pinMode(ledPin, OUTPUT); | |
| } | |
| void loop() { | |
| int sensorValue = digitalRead(touchPin); | |
| if (sensorValue == HIGH) | |
| { | |
| digitalWrite(ledPin, HIGH); | |
| } | |
| else | |
| { | |
| digitalWrite(ledPin, LOW); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment