Englishscone
Published © GPL3+

The Turbo $1 Flashlight

Take a poor preforming flashlight and add great modifications to it in half an hour.

BeginnerFull instructions provided4,343
The Turbo $1 Flashlight

Things used in this project

Story

Read more

Schematics

The Circuit

The single LED represents the the LED head. It will blow if a 220 Ohm resistor is not placed between the LED and ground.

Code

Flashlight Code

Arduino
Enjoy!
int buttonPin = 2;
int lightPin = 3;
static int value = 0;			//Create a changing number
void setup() {
  pinMode(buttonPin,INPUT);
  pinMode(lightPin,OUTPUT);		//Create the pinModes
}
void full_light(){
  digitalWrite(lightPin,HIGH); 
  delay(50);
}
void half_light(){
  analogWrite(lightPin,127);		//Use PWM for brightness level
  delay(50);
}
void fourth_light(){
  analogWrite(lightPin,64);
  delay(50);
}
void strobe(){
  digitalWrite(lightPin,HIGH);		//Change the delays if you want a faster strobe
  delay(100);
  digitalWrite(lightPin,LOW);
  delay(100);
}
void loop() {
int button_check = digitalRead(buttonPin);
if (button_check == 1){			//Check if the button was pressed
  value = value + 1;
  delay(220);
  if (value > 4){
    value = 0;
    delay(70);
  }
}
else{					//Keep the LEDs off if the button was not pressed
  digitalWrite(lightPin,LOW);
}
if (value == 1){			//Output the mode according to the button
  full_light();
}
if (value == 2){
  half_light();
}
if (value == 3){
  fourth_light();
}
if (value == 4){
  strobe();
}
}

Credits

Englishscone
4 projects • 2 followers
Skills in Arduino, hardware dev, python. Help on anything I can help with, just ask.

Comments