Hello community. Im trying to make kind of a projector for a class, with a moving image. Im using 2x1W leds, with a current control, using lm317 transistor. The circuit is functioning perfectly, its made to work with 12V. The problem, is that I want the image to move, so im using a MicroServo 9g, to attach the LED’S. When I connect it, it moves, but then the leds won’t light. I assume is because im using 12V for the leds and I need 4.5 V extra for the Servo, but im not sure. ¿Should I use a 17V? I don’t know if thats going to burn the leds or something like that. Im really new in Arduino, so please be kind and forgive me if i’m asking something stupid. Also I want the leds to turn on and off according to the movement of the servo (in 0º and 180º the leds turn off). The code I have at this point is:

#include <Servo.h>
Servo myservo;

int nLedDrive = 10;
int x;
int pos = 0;

void setup() {

pinMode(nLedDrive, OUTPUT);
digitalWrite(nLedDrive, HIGH);

void loop() {

for (x = 0; x < 255; x++){
analogWrite(nLedDrive, x); // 0 is off, 255 is bright

for (pos = 0; pos <= 180; pos += 1) {
for (pos = 180; pos >= 0; pos -= 1) {


Thanks a lot

Please post a diagram of your circuit. Hand drawn and photographed is good enough.

You cannot drive 12V LEDS directly from the Arduino.

Servos need timers. PWM needs timers. When you attach a servo, you disable PWM on two pins. Can you guess (or do some research to find out) which two pins cease to be able to do PWM?

Got it. I can’t connect both leds and servo in PWM. Thank you a lot. You don’t need to write like im some kind of idiot. I was just asking for help.

labsei wrote (in part):

I can't connect both leds and servo in PWM.

And you still do not get it. You can connect both LEDs and servos and use PWM, you just have to be careful what pins you choose.