Introduction: Arduino Mini Spotlight
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.
2 Comments
8 years ago
Smart idea! Thanks for shearig :)
8 years ago on Introduction
Nicely done. Thanks for sharing this!