Go Down

Topic: Rotating door automation (Read 5 times) previous topic - next topic


I don't know of any tutes and probably I doubt you'll find one that does both, but there will be LDR tutes and LCD tutes that you can put together.

Start looking in the Arduino playground.


Rob Gray aka the GRAYnomad www.robgray.com


Got the basic code started and tested.


Can anyone suggest an easy way to have the servo move more slowly?

Code: [Select]
#include <Servo.h>

const int THRESHOLD = 680;   // an arbitrary threshold level that's in the range of the analog input
Servo myservo;  // create servo object to control a servo

int LDRpin = 0;  // analog pin used to connect the potentiometer
int LDRval;    // variable to read the value from the analog pin

void setup()
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
    // initialize serial communications:

void loop() {
  // read the value of the LDR:
  int analogValue = analogRead(LDRpin);

  // if the analog value is high enough, turn on the Servo:
  if (analogValue > THRESHOLD) {
  else {
    myservo.write(0); //Reset the Servo if the value is too low

  // print the analog value:
  delay(150);        // delay in between reads for stability


One easy way to move the servo more slowly is a for loop that moves it a degree at a time, with whatever size delay you need on each iteration.


I have finished (I think) the code and hardware for this and I'm now at the stage where I want a permanent power solution.

Ideally I want to take a hard wired feed from the mains. Are there any recommendations for the easiest way to power an UNO board and servo in this way?


The Arduino can run on 5V at the +5V pin or on 7-12V on the Vin pin.  The servo is probably designed to run at 6V so neither choice is ideal.  Perhaps you could use a hefty 7+V supply and put a few big silicon diodes in the line going  to power the servos.  A silicon diode has a voltage drop of 0.6 to 0.7V so add drops to bring the voltage down to about 6V.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Go Up