loading
First of all we would like to thank everybody that helped organizing the 2nd edition of Arduino Jam, and especially the Jo3ri, who supplied us with some quite cool goodies and kept us safe during the weekend. (Video will come soon!)

This project is a contribution to the second belgian Arduino Jam (2012) at Timelab, Ghent.

During this edition I teamed up with Jeff to build a mechanical light ticker display. The initial idea was to do something with time lapse and motion control.

.
The bill of materials is the following
  • An Arduino Uno
  • A Pololu motor driver carrier (H-Bridge)
  • An old inkjet printer rail
  • A Raspberry Pi (optional, just to have a nice web interface to input some text)
  • Two led matrix displays (Using a MAX72XX driver) 
  • A copper arm (to carry those led matrices)
  • A camera (DSLR) on a tripod that allows you to set shutter speeds longer than 5s 
You can find the source code for this project attached in the zip file. The code was adapted to work with Netbeans. Just copy the constants.h and project.cpp contents to a new ino file if you want to build it with the Arduino IDE.

Step 1: Get Your Stepper Motor Up and Running

Firstly we did a couple of small tests with the pololu stepper driver. Therefore we wired up the motor according to the schematic here below. We used a bench supply at about 12V as the motor power supply (higher voltages might work even better here).

Driving the motor was then just a matter of
  • Driving the ENABLE pin LOW
  • Setting the dir pin to LOW or HIGH (depending on the direction you want the motor to turn)
  • Sending a LOW (stop) or HIGH (drive) to the STEP pin 
The motor was then attached to the rubbers of a rail of an old inkjet printer (see second picture). We had to drill two holes in the metal to attach our stepper properly. After tightening the rubber a bit, everything was working fine.

We also attached a click button at one end of the rail, so the system would be notified when the carry hit the end of the rail. The code foresaw a routine that stopped the motor when this event would occur. We did this by using a polling loop (no interrupt was needed here)

Step 2: Drive the LED Matrix Displays

In order to get the LED matrix displays working, we needed to do a mapping between the characters we wanted to show and a sequence of LEDs that should be enabled on the display. Every LED is driven by a single line by the MAX72XX chip.

The issue of having to use a wire per LED is solved by using a shift register. In this case it was already present on the LED matrix itself. The interfacing with the Arduino itself is done using SPI, which enables you to drive 64 LEDs with just 3 wires (10, 11 and 12 on the UNO).

After hooking up the display, we ran an example program and saw the LEDs light up nicely. However, there was a small bug in the setup, as for some reason the last line was shifted to the top of the matrix, This caused certain letters to be truncated. We solved this by  bitshifting the pattern for each character to the right just once.

After some searching we found a complete character to bit pattern mapping for those LED matrices on the AVR freaks forum.
Now it was just a matter of making some code that was able to map a single character to its corresponding bit pattern. We did this by using a 2D array and casting a given character to it's corresponding int value (1 - 128) and use this as a first index for the 2D array.

When we had the first display working, we decided to add a second one. The wiring is quite easy here, you can just daisy chain the second starting from the first one. The library that comes with the display is also well written and the code was easily adapted (just duplicate a couple of lines)

Step 3: Building a Nice Enclosure

Finally we decided to build a nice enclosure to give the project a better look. Jeffrey used the laser cutter to construct a big wooden box with a big opening in the front through which we could see the LED matrix displays.

For the designs he used the maximum size of wood plate for the cutter and boxmaker to generate the typical cutted edges to snap together nicely.

Step 4: Adding a Web Interface to the Project

Finally, we decided to connect a raspberry pi to the Arduino driving the LEDs and motor to add a simple web interface to the project. Therefore, I installed the last version of debian wheezy on an SD card and installed i in the Rasp.

After logging in with SSH (first I used serial through its GPIO headers, to find the IP address), I installed php5.
This was quite easy thanks to the aptitude package manager which is installed by default.

Just issue the following command:

sudo apt-get install php5

This should setup an apache web server with php installation. If this is finished, just try to type in the address of the raspberry in your browser, and you should see a default login page. 

After installing this web server, you should try to connect the arduino to the Raspberry's USB port. The FTDI driver for the UNO should be installed by default and if this works, an interface will be created (most probably under /dev/ttyUSB0). Just check your kernel log (type sudo dmesg) to see if everything worked out fine.

Next, you can easily test whether the communication between the Raspberry and the Arduino works OK through the USB bus. Just try to type the following

echo "hello" > /dev/ttyUSB0

and you should see the RX LEDS come up on the Arduino.

To make a PHP script work with the serial on Linux, we used the PhpSerial library. This is essentially just a wrapper around a couple of basic shell commands that eases your life a little bit. The default directory for web content under linux seems to be /var/www (thanks Tom!). Just drop your PHP file in there and you should be good to go!

We did encounter a couple of problems which were the following
  • Firstly, you need to add the user under which apache is running to the dialout group (useradd -G {dialout} your_name) to be able to communicate with serial devices
  • Secondly, you need to double check the PhpSerial code, which in our case replaced the prefix of the name of the serial device with a 'tty', which caused the communication to fail. Just change the name of the interface in the code to whatever you might need (eg. /dev/ttyUSB)
  • It might be easy to open a tail view on the PHP error.log file (you can find it in the /var/log folder) to see what is going wrong
Finally I quickly assembled a simple web page that handled the POST request of one input field and sent the result over USB to the Arduino (code is attached in the php.zip file!)
looks great! I like the idea of making a display that has to be decoded a little to read- in this case w/ the long exposure photos. What is this display being used for now? will we get to see the web interface?
I uploaded the code for the serial interfacing of the raspi with arduino.. feel free to check it out
Hi, <br> <br>I had the chance to pay visit you guys a short vizit on September 22. <br> <br>I'm glad to see the very cool result. <br> <br>Keep up the good work!
Thanks.. The setup was primarily used as a study in motion control.. we had to disassemble it in the end because we used some materials that weren't ours. I added the source code for the PHP part together with a screenshot to the attachments section.

About This Instructable

7,067views

15favorites

License:

More by jekkos:Four on a Glow Mechanical Led Matrix Display Interactive Logo 
Add instructable to: