Difference between revisions of "Touch Sensor Module"
| Line 1: | Line 1: | ||
[[File:Touch sensor.jpg]] | [[File:Touch sensor.jpg]] | ||
| + | |||
| + | |||
| + | == Sample == | ||
| + | |||
| + | <syntaxhighlight lang="c"> | ||
| + | int TouchPin=9; | ||
| + | int ledPin=11; | ||
| + | void setup() { | ||
| + | pinMode(TouchPin, INPUT); | ||
| + | pinMode(ledPin,OUTPUT); | ||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | int sensorValue = digitalRead(TouchPin); | ||
| + | if(sensorValue==1) | ||
| + | { | ||
| + | digitalWrite(ledPin,HIGH); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | digitalWrite(ledPin,LOW); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | </syntaxhighlight> | ||
== Schematics == | == Schematics == | ||
*[https://s3.amazonaws.com/linksprite/LinkerKit/Touch+Sensor.pdf Schematics] | *[https://s3.amazonaws.com/linksprite/LinkerKit/Touch+Sensor.pdf Schematics] | ||
Revision as of 12:49, 25 April 2013
Sample
<syntaxhighlight lang="c"> int TouchPin=9; int ledPin=11; void setup() { pinMode(TouchPin, INPUT); pinMode(ledPin,OUTPUT); }
void loop() { int sensorValue = digitalRead(TouchPin); if(sensorValue==1) { digitalWrite(ledPin,HIGH); } else { digitalWrite(ledPin,LOW); } }
</syntaxhighlight>
