It knows if you have been Naughty or Nice!

The Naughty or Nice machine is simply a bit of fun for the holidays. The machine works by taking a photo of the hand placed on the bottom plate. Using the openCV python computer vision library to count the number of red colour pixels, and display the result on the LCD screen. A little showmanship is used to entrain people while they are waiting for the results of the test. I created the “Naughty or Nice” machine for Christmas 2013, first of all I thought about hacking our Christmas tree, but everyone hacks their Christmas tree, then I had the idea for a “Naughty or Nice” meter, checked online and found that Ben Heck had beat me too that idea, sometime later I had the idea about making the meter interactive, and the idea for the “Naughty or Nice” machine was born.

The “Naughty or Nice” machine is built around the Raspberry Pi camera module, a Raspberry Pi model A, Adafrut USB/serial LCD screen and an Arduino driving RGB LEDs, Adafruit Neopixels. The project is cased in a frame made with Makerbeam and laser cut Perspex panels.


Warning: This build involves soldering and high voltages

If you're new to soldering have a look at this guide

The cable between the LV panel and it’s transformer plus the EL panel itself has a high potential (high voltage between 60 VAC to 120 VAC) be careful not to damage the cable and panel when installing it, see the Adafruit EL guide for details


  • Raspberry Pi
  • Raspberry Pi camera module
  • Adafruit USB/serial LCD display
  • 2 x Adafruit Neopixel bars
  • Arduino Uno
  • RGB LED Arduino Shield - by Re-Innovation
  • Adafruit blue EL panel plus power transformer
  • buck converter or hacked car 12V to USB converter
  • 12Vdc PSU  2 amps or more
  • 12V 2.1mm barrel socket
  • 0.1” plug and sockets plus cable or you could use jumpers as required
  • RGB LED strip
  • short USB to micro USB lead
  • stripbroad
  • 2 x 10K resistors surface mount or through the hole
  • 2 x 1K resistors or surface mount or through the hole
  • 2 x push buttons

The Case

I used Makerbeam for the frame and laser cut Perspex panels for the sides. You can use almost anything, from a cardboard box, wooden box or a fake ginger bread house, for your frame. The case should be at least 200mm high with a base large enough to fit a hand in. The Raspberry Pi is mounted on the top panel with the camera looking down and the Arduino is mount under the panel. The EL panel is mounted between the bottom panel and the base.

The LCD screen

Solder together and test the USB/serial LCD kit, following the instructions here

Neopixel Sticks

Solder the two neopixal bars together, making sure that the power and data connections are same as in the photo. Solder 3 wires, to the 5v, 0v and data in connections, they need to be longer enough to connect to the Arduino.

Hacked Car USB Adaapter

Hack the car USB adapter, by removing the case and plug. Solder cables to the plug connection points, you removed, the centre pin is 12v and the side plates are ground (0v)

The Switches

I used stripbroad and service mount resistors for the switches in this build, you can do the same or use through hole resistors. The copper has to be removed behind the 1K resistor.

It is best to use the latest version of Raspbian you can find the latest version on the Raspberry Pi website, follow the instutions there. I personally like the noobs install method. When you have installed Raspbian, when your Raspberry Pi starts for the first time, the config apt starts, select advanced options and enable the i2c option, then enable the camera module, exit and make sure Raspbian is up to date by entering the following at the command line. Your Raspberry PI will need to be connected to the internet to do this and to download the required software and modules.

sudo apt-get update

sudo apt-get upgrade 

Install the picamera python module, if you are using the latest version of Raspbian the picamera module is already installed. For instructions follow this guide on the Raspberry Pi website by following this link.

 install the openCV python module by entering the following at the command line

sudo apt-get install libopencv-dev

sudo apt-get install python-opencv

 download the bootup program plus the control program for the Raspberry Pi to your home folder from git. enter the follow at the command line

cd master
cp ~/
cp ~/
cd ~
sudo rm -r NorN_4-master/

Next we need to modify the rc.local file to start running when the Raspberry Pi starts up. first of all we need to make a backup of the file, enter the following at the command line. 

sudo cp etc/rc.local etc/rc.local.old

if you need to restore the old file enter enter the following at the command line

 sudo cp etc/rc.local.old etc/rc.local 

Now to modify the rc.local file by entering at the command line.

 sudo nano /etc/rc.local

and adding the following before "exit O"

python /home/pi/

and save by holding ctrl O, press enter to accept and then ctrl X to exit

follow the guide on the hobbytronics website to disable the console on the serial port.

Install Arduino and add the Adafruit libraries for the Adafruit_WS2801.h and Adafruit_NeoPixel.h for Arduino. you can find them at

If you are new to the world of Arduinos, I would suggest that you follow the first few guides by Simon Monk on the starting with the first lession. 

next upload NorN_4.ino sketch to your Arduino using your normal method. You can download sketch from here

 install the RGB strip shield, contect the RGB strips to the shield and NeoPixel sticks. you will not be able to test until the Arduino and Raspberry Pi are conected together.

NOTE: you could use just a NeoPixel strip instead of the RGB shield and RGB strip, the Arduino sketch would required adjusting if this was done.

Connect the Arduino SDA and SCL lines to the Raspberry Pi plus connect grounds of both devices together.





Raspberry Pi


Build your case, fixing the Raspberry PI, Arduino, LCD display, Neopixals plus the RGB strip in place.

The EL panel is installed behind the transparent blue base in my case, this is to protect it, take care with the power connections, making sure that the cable and joints are OK.

Connect the connected the RGB LEDs strips following the screen print markings to the shield, and the Neopixels 5V, 0V to the Arduino’s 5V, 0V and the data in is connected digital pin 12. Using the TLL serial connection on the LCD display, connect the JST cable to the backpack and then connect to the Raspberry Pi's GPIO pins as follows: Red wire goes to +5V, Black wire goes to Ground, White data wire goes to pin 6 (TxD) or you can solder a header on and use jump wires instead.

Fit the power socket and connect with wires to the power in on the Arduino shield, and also feed the hacked 12v to USB converter or the buck converter, use the USB lead to power the Raspberry Pi from the usb socket on the USB converter. Connect the feed for the EL transformer to the socket, you may need to use some form of connector blocks to be connect all the required feeds.

Connect the Arduino SDA and SCL lines to the Raspberry Pi plus connect grounds of both devices together.





Raspberry Pi


Fit and connect the switches, to the Raspberry Pi GPIO pins  the red wires goes to a 3v3 pin and the black wires to a 0V pin, The first switch's signal wire is connected to pin 23 and the second is connected to pin 24

Instructions for use.


  1. When the "Naughty or Nice" machine first starts press the bottom button. 
  2. Place hand on the bottom plate inside the machine, up to your wrist
  3. Press bottom button
  4. Remove hand when instructed
  5. Wait for your Naughtness rating

This guide was first published on Dec 18, 2014. It was last updated on Mar 08, 2024.