Introduction
What we need and connection
For this tutorial we will need:
- Arduino UNO
- Grove Base Shield
- Touch Sensor
- LED (Connect Grove-LED to port D4 of Grove-Base Shield)
The code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | const int TouchPin=3; const int ledPin=4; void setup() { pinMode(TouchPin, INPUT); pinMode(ledPin,OUTPUT); } void loop() { int sensorValue = digitalRead(TouchPin); if(sensorValue==1) { digitalWrite(ledPin,HIGH); } else { digitalWrite(ledPin,LOW); } } |
Download the code from here and open it with Arduino IDE.
|
|
Well done!
You have successfully completed one more Arduino Grove tutorial.
I hope you liked this, let me know in the comments.
I hope you liked this, let me know in the comments.