Nwazet Mean Crafty Pi Monster - Lighting Board

$6.50

Product Type: Prototyping

This simple backlighting kit looks fantastic inside of our 'Pi Head Cases' and comes with two big 10mm diffused LEDs. The difficult part will be choosing the color ;)

This kit is also an open invitation to hacking the Raspberry Pi's GPIO connector and learning basic electronics, perhaps starting with the lighting circuit itself: the printed circuit board is designed so that it's easy to go from a circuit built on a half-size breadboard to a permanent circuit, ready to be stacked above a Raspberry Pi (Model A or B with mounting holes).

Bill of Materials

  • PCB: 'Mean Crafty Pi Monster' permanent prototyping board
  • LED1-2: 10mm diffused LED
  • PD1: 10K ohm resistor (part # CF14JT10K0)
  • BR1: 100 ohm resistor (part # CF14JT100RTR)
  • LR1: 100 ohm resistor (part # CF14JT100RTR)
  • SGD: MOSFET N-CHANNEL 60V 200mA (part # 2N7000)
  • LED_CTRL: 0.1" pin header (3 positions)

This kit also includes the following connectors and fasteners:

  • 3x female / female jumper wires to connect the backlight circuit to the Raspberry Pi's GPIO connector. The jumper wires will be of three different colors, typically red (3v3), black (GND) and yellow/blue/green (PWM).
  • 2x 1" hex aluminum standoffs
  • 2x 1/4" hex aluminum standoffs
  • 2x 1/4" screws

Assembly Directions and Time

  • LED 1 & 2: align the LED lens against the edge of the PCB. Ensure that the shortest leg of the LED is on the side of the hole with a square shape (LED cathode indicator). Using a permanent marker, make a line on the LED's leads where the leads align with the soldering holes in the PCB. Gently bend the LED's leads downward at a 90 degree angle. The LED should now be ready to be inserted into the PCB with its shortest lead going into the square-shaped hole.
  • LED_CTRL: the 0.1" pin header should be inserted on the bottom of the board, with the long portion of the pins pointing downward.
  • Connect the female / female jumper wires as follows:
    • red (3v3) -> GPIO pin #1 (first from the left on the bottom row)
    • black (GND) -> GPIO pin #6 (third from the left on the top row)
    • yellow/blue/green (PWM) -> GPIO 18 (GPIO 18 is pin 12 on the GPIO connector, 6th pin from the left on the top row of the connector)
  • Standoffs: add or remove the 1/4" standoffs as needed to align the LEDs with the eyes of the face plate.

For best results:

  • Use a 30 Watt soldering iron
  • Use a fine soldering iron tip
  • Use fine rosin-core solder (0.022")
  • Use masking tape to hold parts in place as needed while soldering
  • Assembly time is about 5 minutes

Sample Code

Pulses the Raspberry Pi's GPIO # 18 (PWM0) with a breathing effect.

To use this sample:

  • Install wiringPi
  • Download and uncompress the mcpm.zip archive to your Raspberry Pi
wget nwazet.com/Media/Default/Sample/mcpm/mcpm.zip
unzip mcpm.zip

You can either compile the code by typing 'make' or you can simply use the 'mcpm' binary that's including in 'mcpm.zip' by making it executable.

chmod +x mcpm
  • As root (or using sudo), run './mcpm&' from the shell and enjoy the pretty lights ;)

Auto-starting the creeper head lights on boot

If you want the creeper to light up automatically when the Raspberry Pi boots up, follow these directions. It is assumed that you're running as 'root' or use 'sudo' as needed.

  • Create the auto-start script
nano /etc/init.d/mcpm.sh
  • Paste the script below in the editor and save it. The script assumes that 'mcpm' was compiled in the '/home' folder. Adjust the auto-start script according to the actual location of the executable if it's not in '/home'.
#! /bin/sh
# /etc/init.d/mcpm.sh
# http://wiki.debian.org/LSBInitScripts

### BEGIN INIT INFO
# Provides:          mcpm
# Required-Start:    $local_fs $syslog
# Required-Stop:     $local_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Basic startup & shutdown script
# Description:       Starts and stops an application on boot & shutdown
### END INIT INFO

# Commands listed below will always run

# System command handler
case "$1" in
  start)
    # start the application
    echo "Head case lights on"
    /home/mcpm&
    ;;
  stop)
    # stop the application
    echo "Head case lights off"
    killall mcpm
    ;;
  help)
    echo "Usage: /etc/init.d/mcpm.sh {start|stop}"
    exit 1
    ;;
esac

exit 0
  • Make the script executable and test the commands
chmod +x /etc/init.d/mcpm.sh
/etc/init.d/mcpm.sh help
/etc/init.d/mcpm.sh start
/etc/init.d/mcpm.sh stop
  • Add mcpm.sh to the list of programs to start on boot
update-rc.d mcpm.sh defaults
  • If you want to remove it from the list of programs to start on boot, do:
update-rc.d mcpm.sh remove

That's it! Now, the head lights will turn on and glow as soon as the Raspberry Pi boots up :)

See also

Nwazet Pi Head Case Series

  • RoHS Compliant
  • Open Source Hardware
  • Designed by Nwazet
  • Assembled In The USA
  • Raspberry Pi

Tags: Raspbian, Raspberry Pi, run program, run application, auto-start, start-up, boot, shutdown