Go Down

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

Graynomad

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.

http://arduino.cc/playground/

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

ChickenMechanic

Got the basic code started and tested.

http://www.youtube.com/watch?v=kCsqRok9nBM

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:
  Serial.begin(9600);
}

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) {
    myservo.write(180);
  }
  else {
    myservo.write(0); //Reset the Servo if the value is too low
  }

  // print the analog value:
  Serial.println(analogValue);
  delay(150);        // delay in between reads for stability
}

wildbill

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.

ChickenMechanic

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?


johnwasser

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