diff --git a/examples/touch_to_open/README.md b/examples/touch_to_open/README.md new file mode 100644 index 0000000..8af9d88 --- /dev/null +++ b/examples/touch_to_open/README.md @@ -0,0 +1,26 @@ +# touch_to_open + +touch the touch senso to make the servo move 90 degree + +## Hardware Required + +* Arduino Board +* Servo Motor +* Hook-up wires +* touch sensor + +## Circuit + +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. + +![](images/Touch_to_open_BB.JPG) + +(Images developed using Fritzing. For more circuit examples, see the [Fritzing project page](http://fritzing.org/projects/)) + +## Schematic + +![](images/Touch_to_open_schem.JPG) + + + + diff --git a/examples/touch_to_open/images/Touch_to_open_BB.JPG b/examples/touch_to_open/images/Touch_to_open_BB.JPG new file mode 100644 index 0000000..942ef72 Binary files /dev/null and b/examples/touch_to_open/images/Touch_to_open_BB.JPG differ diff --git a/examples/touch_to_open/images/Touch_to_open_schem.JPG b/examples/touch_to_open/images/Touch_to_open_schem.JPG new file mode 100644 index 0000000..d98a20d Binary files /dev/null and b/examples/touch_to_open/images/Touch_to_open_schem.JPG differ diff --git a/examples/touch_to_open/touch_to_open.ino b/examples/touch_to_open/touch_to_open.ino new file mode 100644 index 0000000..56c32cb --- /dev/null +++ b/examples/touch_to_open/touch_to_open.ino @@ -0,0 +1,21 @@ +#include //including the servo library + +Servo touch_servo; // initialize a sevo object to use it +int sensor_pin =2; // defining a pin for the touch sensor + +void setup() { + pinMode(2, INPUT); + touch_servo.attach(9); // defining the pin of the servo motor(pin9) + Serial.begin(9600); // defining the Baud Rate to use the serial Monitor +} + +void loop() { + + if (digitalRead(2) == HIGH) // checking if the sensor is touched + { + touch_servo.write(90); // moving the servo 90 degree + Serial.println("Sensor is touched | servo is opened"); + } + + +}