Push button activates Laser diode then activates led & sound

Hi,
I am working on a Diorama Project. I have an Arduino mega 2560. Let me first start by saying Hello. Hello : ) I am afraid I am way out of my depth here. I really need some help with coding.

What I want to do: I have a display diorama with an action figure. I want to push a button to activate the following; A figure with the placement of a Laser diode near his arm to fire a beam of light. An led to simulate an explosion or fire. An mp3 sound effect from a movie clip.

Thank you so much,
G

Hi, it's certainly possible. You'd need a laser with a special lens that projects that line you want rather than a dot. You could use a construction line level laser for this, available at DIY/hardware stores.

For the light sensor you'd need like a LDR light dependent resistor in the beam path. You'd need to calibrate it's readings into the arduino to make sure it only works when the laser is on it but that wouldn't be too hard.

You'd also likely need a pack of transistors or mosfets to control the various outputs from the arduino as it's pins are limited to like 30ma.

Sorry i can't help much with the code, but you could employ a freelancer on Fiverr.com starting for around $10 depending on complexity and the skill of the freelancer. There's plenty of freelancers available to program arduino!

Hope this helps, and i wish you the best with the pain!

Thank you. Oh... I just looked up a construction line level laser and it is way too big. The diode I had in mind was about an inch or 2 to scale behind or parallel to a figures arm. :frowning:

The laser will not turn off I had it now It is gone. It works but I have absolutely no idea what I am doing. Cobbled together Code so far:

unsigned long buttonState = 0;
int funcState=0;

int ledRED = 13; //the pin we connect the led
int ledRED2 = 12; //the pin we connect the led
int ledORANGE = 11; //the pin we connect the led
int Button = 6; //the pin where we connect the button
int LASER = 7; //the pin we connect the laser
int speaker = 8; //the pin we connect the speaker

enum fcnMode {
OFF,
LASER1,
LED1,
LED2,
LED3,
FADE1,
ALL,
BLINK,
NBSTATE
}; // OFF = 0 and NBSTATE=7

void buttonPressed() {
buttonState = pulseIn(Button,HIGH,1000000);
if (buttonState > 50){
funcState += 1;
Serial.print("Button state n: ");
Serial.println(funcState);
}

switch(funcState){
case OFF:
break;
case LASER1:
break;
case LED1:
break;
case LED2:
break;
case LED3:
break;
case FADE1:
digitalWrite(ledRED2,HIGH);
digitalWrite(ledORANGE,LOW);
break;
case ALL:
break;
case BLINK:
digitalWrite(ledRED2,LOW);
break;
}

funcState=funcState; buttonState;
}

void setup() {

pinMode(ledRED, OUTPUT);
pinMode(ledRED2, OUTPUT);
pinMode(ledORANGE, OUTPUT);
pinMode(Button, INPUT_PULLUP); //set the button pin as INPUT
pinMode(LASER, OUTPUT); //set the LASER pin as OUTPUT
pinMode (speaker, OUTPUT); //set the speaker pin as OUTPUT
}

void loop() {
int stateButton = digitalRead(Button); //read the state of the button
if(stateButton == 1) { //if pressed
digitalWrite(LASER, LOW); //write 1 or HIGH to LASER pin
delay(500);
} else { //if not pressed
digitalWrite(LASER, HIGH); //write 0 or low to LASER pin
delay(500);

analogWrite (speaker, 255);
delay (500);
analogWrite (speaker, 0);
delay (10);

int brightness = 0;
int fadeAmount = 5;

for (brightness=0;brightness<=255;brightness+=fadeAmount){
analogWrite(ledRED, brightness);
delay(5000);
for (brightness=100;brightness<=555;brightness+=fadeAmount){
analogWrite(ledRED2, brightness);
delay(5000);
for (brightness=0;brightness<=155;brightness+=fadeAmount){
analogWrite(ledORANGE, brightness);
delay(5000);

}
int stateButton = digitalRead(Button); //read the state of the button
if(stateButton == 1) { //if pressed
digitalWrite(ledRED, HIGH);
delay(2000);
} else { //if not pressed
digitalWrite(ledRED, LOW);
delay(2000);

int stateButton = digitalRead(Button); //read the state of the button
if(stateButton == 1) { //if pressed
digitalWrite(ledRED2, HIGH);
delay(2000);
} else { //if not pressed
digitalWrite(ledRED2, LOW);
delay(2000);

int stateButton = digitalRead(Button); //read the state of the button
if(stateButton == 1) { //if pressed
digitalWrite(ledORANGE, HIGH);
delay(2000);
} else { //if not pressed
digitalWrite(ledORANGE, LOW);
delay(2000);

}
}
}
}
}
}
}