adruino board with servo motor

Discussion in 'The Projects Forum' started by kaznov, Mar 3, 2013.

  1. kaznov

    Thread Starter Member

    Mar 10, 2012
    30
    0
    Hi guys
    Do you know where or how would I get a code to control a servo motor (5v) to stop on incremental angle like 90, 180, 270 and more because I just got to make the servo motor to work with my adruino board but i couldn't stop it in the positions that I want, and my programming knowledge is not that good :(

    any help will be appreciated guys
    thanks
     
  2. boingaon

    Member

    May 15, 2012
    31
    0
  3. kaznov

    Thread Starter Member

    Mar 10, 2012
    30
    0
    Thanks sir
    but there is a need of using potinomater but for my design i want to use the adruino board with the servo motor to automatically rotate with different angle based on the detection of the light sensor basically for a window blind so in the morning the servo motor will rotate 180 degree and let say in the evening will rotate a 90 degree angle and so on but since there is a potionater that will not make it automatically rotate

    any idea or help please
    Thanks
     
  4. w2aew

    Member

    Jan 3, 2012
    219
    64
    You can setup a simply voltage divider between a photo-resistor (CdS photocell) and a fixed resistor. Put this across 5V and ground, then read the divided voltage with an analog input. Use this value, and a threshold you determine to make the decision on where to put the blinds. See this lesson on how to setup and read the light level based on the photocell:
    http://learn.adafruit.com/photocells/using-a-photocell
     
  5. kaznov

    Thread Starter Member

    Mar 10, 2012
    30
    0
    so am assuming that you mean using the circuit will replace the need of potiomater ..right?
    clarification please ?
     
  6. w2aew

    Member

    Jan 3, 2012
    219
    64
    Yes. In fact you can use the servo example that installed as part of the Arduino IDE that uses a pot to set the servo position. Replace the pot with the series combination of the CdS photocell and a 10k resistor. The ends of this series combination connect to 5v and ground respectively, and the junction between the two devices connects to the analog input pin. This will make the servo vary with light level. If you only want two positions (open and closed), the simply read the value and compare it to a threshold value you setup, then adjust the servo angle as required. You might want to setup a little hysteresis in the threshold value so that the servo doesn't wiggle when the light level is right at the threshold.
     
Loading...