Skip to content

Commit 18108ef

Browse files
Example with touch sensor added
1 parent c72fbed commit 18108ef

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

examples/touch_to_open/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# touch_to_open
2+
3+
touch the touch senso to make the servo move 90 degree
4+
5+
## Hardware Required
6+
7+
* Arduino Board
8+
* Servo Motor
9+
* Hook-up wires
10+
* touch sensor
11+
12+
## Circuit
13+
14+
Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to the 5V pin on the Arduino board. The ground wire is typically black or brown and should be connected to a ground pin on the board. The signal pin is typically yellow, orange or white and should be connected to pin 9 on the board.
15+
16+
![](images/Touch_to_open_BB.JPG)
17+
18+
(Images developed using Fritzing. For more circuit examples, see the [Fritzing project page](http://fritzing.org/projects/))
19+
20+
## Schematic
21+
22+
![](images/Touch_to_open_schem.JPG)
23+
24+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <Servo.h> //including the servo library
2+
3+
Servo touch_servo; // initialize a sevo object to use it
4+
int sensor_pin =2; // defining a pin for the touch sensor
5+
6+
void setup() {
7+
pinMode(2, INPUT);
8+
touch_servo.attach(9); // defining the pin of the servo motor(pin9)
9+
Serial.begin(9600); // defining the Baud Rate to use the serial Monitor
10+
}
11+
12+
void loop() {
13+
14+
if (digitalRead(2) == HIGH) // checking if the sensor is touched
15+
{
16+
touch_servo.write(90); // moving the servo 90 degree
17+
Serial.println("Sensor is touched | servo is opened");
18+
}
19+
20+
21+
}
Loading
Loading

0 commit comments

Comments
 (0)