Devices & Components
Arduino Uno Rev3
Dual H-Bridge motor drivers L293D
Breadboard (generic)
Motor Adapter for NI myRIO
Hardware & Tools
Hot glue gun (generic)
Project description
Code
Arduino based automatic water tab using IR sensor.
c_cpp
In this project we have made automatic water tab using Arduino and IR sensor to solve the problem of wastage of water in daily life.
1#include <Servo.h> 2 3 4const int SensorPin = 3; 5//int sensorValue = 0; 6int myservo = 9; 7int pos = 0; 8Servo servo; 9 10void setup() { 11 12servo.attach(myservo); 13} 14 15void loop() { 16 17 digitalRead(3); 18 if(SensorPin==HIGH) 19 servo.attach(9); 20 pos = 90; // start at midpoint 90 degrees 21// Speed = 3; // servo moves 3 degrees each time left/right is pushed// attaches the servo on pin 9 to the servo object 22 // start at midpoint 90 degrees // servo moves 3 degrees each time left/right is pushed // Set initial position 23 24} 25
Comments
Only logged in users can leave comments