Power for further experiment with servo

The "Eleven" is our Uno-equivalent Arduino-compatible board, but with a number of improvements including prototyping area, a mini-USB connector, LEDs mounted near the edge, and the D13 LED isolated using a FET. [Product page]
Post Reply
Rusty
Posts: 2
Joined: Tue Nov 29, 2016 10:57 am

Power for further experiment with servo

Post by Rusty » Tue Nov 29, 2016 11:12 am

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?

Rusty
Posts: 2
Joined: Tue Nov 29, 2016 10:57 am

Re: Power for further experiment with servo

Post by Rusty » Sat Dec 10, 2016 3:46 am

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:
Serial.begin(38400);
myservo.attach(11);
}

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

Post Reply