Page 1 of 1

Power for further experiment with servo

Posted: Tue Nov 29, 2016 11:12 am
by Rusty
I have successfully run Project 6 - Servo from the Freetronics Project Guide (v 1.4) and wanted to take it one step further by doing the further experiment as stated - "Create a light level meter that uses the light sensor to measure the ambient light, which is then shown
using the servo and a small arrow placed on the rotating horn."

However, my first dilemma is running both the light sensor and the servo motor as both need 5v power and there is only one 5v output on the Eleven board. How does one overcome this? Has anyone done this additional project and created a working sketch for it?

Re: Power for further experiment with servo

Posted: Sat Dec 10, 2016 3:46 am
by Rusty
Think I solved it. I used the breadboard to supply both ground and 5v to both servo and light meter. The sketch I created is below. If anyone has any suggestions for improvements I would be grateful - still trying to learn this programming.

int angle=0;
int delaytime=100;
int lightLevel;

#include <Servo.h>
Servo myservo;

void setup() {
// put your setup code here, to run once:

void loop() {
// put your main code here, to run repeatedly:
lightLevel = analogRead(A0);
myservo.write (angle);
angle = lightLevel / 6;
Serial.print("Light level: ");
Serial.println(lightLevel, DEC);