User avatar
By Chris Brewin
#4891039
Hey all!

I'm looking for some help with Arduino stuff... I know I can join their forums and probably find help there, but it's for a Ghostbusters project, so I'd like to start here first.

While this is for an ecto-mobile project, it involves a roof-mounted trap, hence this question being asked here.

I want to have a trap that has two strips of LEDs that flash in an alternating pattern, then have the trap doors open and another light inside turn on (while the flashers are still alternating), then have the trap door close, then turn off the flashers then send a signal out to a bar graph LED indicator.

I figure Arduino control is the best way to go... can anybody help?
User avatar
By MrLithium
#4893533
Wow I'm surprised no one has gotten back to you in two months! Let me be the first then I guess haha.
I've got some good practical experience with Arduino. I can probably answer any questions you have about it. What specifically are you trying to do?
User avatar
By Chris Brewin
#4893552
My ultimate goal is to have a trap that works similarly to this (minus smoke and sounds):


Long story short:
1) turn on and it sits in stand-by (no lights, no sounds, no nothin')
2) activate once (I'll be using RC rather than a pedal - I have a solution for that) and doors open and lights inside come on
3) activate again and the trap closes and lights inside turn off which triggers the bar-graph on the cartridge and the blinky on the chasis
4) activate again and it returns to stand-by

I contacted Sean, the designer and he said his buddy did the Arduino stuff but didn't refer me. Since he didn't volunteer the referral, I decided not to ask.
User avatar
By MrLithium
#4893568
Chris Brewin wrote: Long story short:
1) turn on and it sits in stand-by (no lights, no sounds, no nothin')
2) activate once (I'll be using RC rather than a pedal - I have a solution for that) and doors open and lights inside come on
3) activate again and the trap closes and lights inside turn off which triggers the bar-graph on the cartridge and the blinky on the chasis
4) activate again and it returns to stand-by
Alright so basically what you're going to want to be doing is in the void loop () portion of the code you'll be running an if statement. Logically what that will mean is "If pedal is pressed, X will happen. Once this has happened, Y will happen."

This is extremely easy to do. In fact, I have made a demo of it already with some parts I have sitting around.
The code itself took me about an hour or so to work out the kinks and stuff but I think this will work for pretty much anything you want to do with it.
Code: Select all
#include <Servo.h>

Servo myservo;
boolean trapping = false;
boolean bagged = false;
#define trapLED 31
#define redLED 30
#define servoPin 9
#define footpedal 52
#define reset 53
#define beep 6

void setup() {
pinMode(footpedal, INPUT_PULLUP);
pinMode(redLED, OUTPUT);
pinMode(53, INPUT_PULLUP);
pinMode(trapLED, OUTPUT);
myservo.attach(servoPin);
digitalWrite(redLED, LOW);
}

void loop() {
if (digitalRead(footpedal) == LOW && bagged == false) {
digitalWrite(trapLED, HIGH);
myservo.write(180);
trapping = true;

}
if (digitalRead(footpedal) == HIGH && trapping == true){
digitalWrite(trapLED, LOW);
bagged = true;
}
if (bagged == true) {
myservo.write(0);
digitalWrite(redLED, LOW);
noTone(beep);
delay(300);
digitalWrite(redLED, HIGH);
tone(beep, 950);
delay(175);
}
if (digitalRead(reset) == LOW){
  trapping = false;
  bagged = false;
  noTone(beep);
  digitalWrite(redLED, LOW);
  digitalWrite(trapLED, LOW);
}
}
Let it be noted that an "input pullup" pinmode basically means that instead of running that pin to a 5v power supply of some sort, you are running it to ground. I do this because it is generally safer to do for the board itself and allows you do to some pretty neat things with transistors. If you have any questions feel free to ask.

If you need to change any of the pins, do so up at the top where they say #define [name] [pin]

Also, if you wish to not use delay on the blinking, you can use a function called millis() which is basically a godsend when you are doing blinking lights with multiple timers on an arduino.
User avatar
By MrLithium
#4893582
Chris Brewin wrote:Thanks a lot for that! What board did you use?
I use the Arduino mega but you can use any Arduino. I just had a mega sitting around
Chris Brewin liked this

    Correct, it grants several in fact the Melody's […]

    Are they just newspaper clippings or something? […]

    If you check the post below from reddit, one of […]

    got a link? It appears that some time today[…]