Arduino Mini Spotlight

1,620

9

2

Posted in TechnologyArduino

Introduction: Arduino Mini Spotlight

About: I'm a teenage male that has an interest in arduino, robots and other awesome stuff.

This is a mini led spotlight that I made which can be controlled by a potentiometer.

Step 1: Materials

You will need:

Arduino Uno Rev 3

Radioshack Standard Servo

Potentiometer(I used a 10k)

6v Battery Pack

Breadboard

Jumper wires

Small led Flashlight

Step 2: Attach the Potentiometer

The first step is pretty simple just attach the potentiometer as shown in the picture.

Step 3: Attaching the Servo

Attach the servo as shown in this picture.

Step 4: Attaching the Battery Pack

Attach the battery pack as shown in this picture.

Step 5: The Led Light

For this next step you can attach the led by wrapping it around the servo horn.

Step 6: CODE!!!

The code for this project is pretty simple just copy and paste this program right here and upload it into the arduino:

#include <Servo.h>

int potPin = 2;

int pos;

Servo myservo;

void setup()

{

myservo.attach(9);

}

void loop()

{

pos = analogRead(potPin);

pos = map(pos, 0, 1023, 0, 179);

myservo.write(pos);

}

Step 7: Your Done

If you made it to this step then that means your done with the project. To use this project just turn on the power, turn on the led and twist the potentiometer to move the led.

Share

    Recommendations

    • Spotless Contest

      Spotless Contest
    • Science of Cooking

      Science of Cooking
    • Pocket-Sized Contest

      Pocket-Sized Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    2 Comments

    Smart idea! Thanks for shearig :)

    Nicely done. Thanks for sharing this!