This is a simple pivot hinge created with laser cut acrylic which is used to open the lid when your hand gets near the infrared sensor.
// Import libraries. #include <Servo.h> // The wiring assignment. const int SERVO_PIN = 9; int isObstaclePin = 7; // This is our input pin int isObstacle = HIGH; // HIGH MEANS NO OBSTACLE Servo wiggling_servo; void setup() { // Initialize the serial UART at 9600 bits per second. Serial.begin(9600); // Initialize the Servo object to use the given pin for output. wiggling_servo.attach(SERVO_PIN); wiggling_servo.write(0); //Infrared setup pinMode(isObstaclePin, INPUT); Serial.begin(9600); } void loop() { checkSensor(); } void checkSensor() { isObstacle = digitalRead(isObstaclePin); Serial.print("is obstacle"); Serial.println(isObstacle); if(isObstacle == HIGH){ wiggling_servo.write(0); } if(isObstacle == LOW){ wiggling_servo.write(45); } }
Leave a Reply
You must be logged in to post a comment.