Today, we will be creating a super easy Halloween zombie mask using the ROHM Sensor Evaluation Kit! We will be using ROHM Proximity/Ambient Light Sensor (PS/ALS) Sensor. The sensor will detect anything that moves in front of the mask and will light up in red to scare away your uninvited guests!
A guide to how to setup the sensor shield and connect to Arduino was covered in the previous article. If you haven’t already, please refer back to ROHM Sensor Evaluation Kit Overview!
Quick overview of ROHM Sensor Evaluation Kit
The Sensor Evaluation Kit comes with the Sensor Shield and 8 different ROHM sensors: an accelerometer, a barometric pressure sensor, a geomagnetic sensor, an ambient-light/proximity sensor, a color sensor, a hall-effect sensor, a temperature sensor, and an ultraviolet light sensor.
The website, http://www.rohm.com/web/global/sensor-shield-support, provides detailed documentation about the sensor shield and each of the sensors, along with links to downloadable Arduino libraries for the individual sensors. The user-manual for the kit, which comes in the box and can also be found on the website, and it provides instructions on using the sensor shield with the sensors.
Figure 1. ROHM Sensor Shield (top right) with 8 different compatible sensors / @CoreStaff
Let’s make a Halloween zombie mask using the Proximity/Ambient Light Sensor!
So Halloween is just around the corner and I decided to make this scary Halloween mask!
Figure 2. The Halloween zombie mask connected to ROHM sensor shield
Remember when I said that the sensor shield is great for prototyping sensor projects? This project is a great demonstration of just that! I want to make a Halloween decoration for my front door that lights up to scare people who walk near it. The mask, a hacked light-up Halloween mask, will detect people using a proximity sensor, and will be based on the Arduino Uno! First, however, I need to prototype my creation, and for this I’ll use the sensor shield with the Proximity/Ambient Light Sensor (PS/ALS module).
Hardware Parts:
Software
This project lights up an LED whenever an object is too close to the proximity sensor.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
#define byte uint8_t #include <Wire.h> #include <RPR-0521RS.h> RPR0521RS rpr0521rs; int led_pin = 12; void setup() { byte rc; Serial.begin(9600); while (!Serial); Wire.begin(); rc = rpr0521rs.init(); pinMode(led_pin, OUTPUT); } void loop() { byte rc; unsigned short ps_val; float als_val; byte near_far; rc = rpr0521rs.get_psalsval(&ps_val, &als_val); if (rc == 0) { near_far = rpr0521rs.check_near_far(ps_val); if (near_far == RPR0521RS_NEAR_VAL) { digitalWrite(led_pin, HIGH); } else { digitalWrite(led_pin, LOW); } } delay(500); } |
The mask that I bought had LED strips around the eyes that lit up when a switch inside the mask was turned on. The LED strips were connected to a battery case also inside the mask.
Figure 3. The power and ground wires for the LED strips came connected to a 4.5V battery case.
Since I decided to power the LEDs directly from the digital output pin of the Arduino, I removed the battery unit and desoldered its JST female connectors.
I then made a custom splitter that would allow me to connect the LED strips to a breadboard. The splitter joined the positive and negative pins on each female connector together, and had two wires (one for positive voltage and one for ground) that I could then attach to a breadboard.
Figure 4. The custom splitter to connect the LED strips to a breadboard
Finally, connect the positive and ground wires to digital pin 12 and to ground respectively. Remember to use a 220Ω resistor to limit the current to the LEDs!
Figure 5. The breadboard connections
You are now ready to test your project! Play with the value of “RPR0521RS_NEAR_THRESH” in the “RPR-0521RS.h” library file to change the threshold distance at which the proximity distance triggers.
Once you are satisfied with the Sensor Shield prototype, you can finalize the project by mounting the proximity sensor to the front of the mask and drawing connections from the pins on the proximity sensor to the I2C inputs on the Sensor Shield.
Place the mask by your front door and let your visitors enjoy a spooky and cool Halloween decoration! Have a happy and safe Halloween! 🙂