Red Pitaya Blog

Home » , »

GUEST POST: Red Pitaya Halloween Project

First of all, I plugged the Sensor Extension board onto the Red Pitaya. To trigger everything I used the Grove PIR sensor – this is the same sensor I used as a trigger in my Alarm project to keep my brother out of my room, so I knew it would work really well.

I decided to use a plastic pumpkin, because picking bits of pumpkin out of electronics when it’s time to dismantle the project doesn’t sound like fun.

Next was adding lights. I have two Grove sensors that contain LEDs that plug right into the board. First I tried the Grove 3mm Purple LED, but it was way too dim – it would work great as an indicator, but it just wasn’t bright enough to do the job. Next I tried the 4mm Green LED, this was better, but even with the variable resistor on the board turned all the way up, it was still too dim. So I decided to use the Green one, plus add two more Yellow LEDs and a Red one:

I soldered a 100 Ohm resistor to each one – the Red Pitaya pins are 3.3V, there is about a 2V drop across the LEDs, so this puts about 13mA through each LED, making them nice and bright. After the above photo was taken all bare wires were covered with electrical tape to prevent shorts. These wires were inserted into the headers on the Extension Board, in digital pins 6, 7 and 8.

Next was sound, I really wanted this to scare people. We went to a couple of local stores looking for something that made a scary sound, but couldn’t find anything suitable. We did however have a very loud hand held siren that we could use – not ideal, but it will certainly scare people. It works by holding down a button, so to control it from the Red Pitaya we had to do the following:

  1. Tape down the button with electrical tape, so the siren is always on.
  2. Cut the cable between the battery and the siren.
  3. Connected the two cut wires to a Grove relay board.
  4. Plug in the Grove Relay Board to the Red Pitaya Extension Board.

That way, when the relay is switched on, the circuit is complete, and the alarm sounds:

So that is the hardware complete, into the Extension Board I have a PIR Sensor, LED and Relay from Grove, plus 3 additional LEDs:

With the hardware complete, all that is left is the code, which is simple using Red Pitaya’s Visual Programming.

First we set up a loop, and check the PIR sensor every 100 milliseconds.

If the sensor is triggered, we turn on the alarm (relay) and LEDs for 10 seconds. However since I had 4 LEDs, I wanted to try to make a ‘flicker’ effect to make it even scarier. To do that, I split the 10 seconds into 100 intervals, and for each 100 millisecond interval, each LED has a 75% chance of being turned on (based on a random number).

 

I’m really happy with the way the flicker effect worked out. You can see the project working in the video below:

Can wait to set this outside on Halloween and scare people!


Red Pitaya makes real engineers!

Categories
Subscribe to our newsletter

Related Posts