Previous posts for this project:
- Sci Fi Your Pi: PiDesk - Project Description
- Sci Fi Your Pi: PiDesk - Project Update #1
- Sci Fi Your Pi: PiDesk - Guide: Setting Up the Raspberry Pi 2
- Sci Fi Your Pi: PiDesk - Project Update #2
- Sci Fi Your Pi: PiDesk - Review: Bare Conductive Touch Board
- Sci Fi Your Pi: PiDesk - Project Update #3
- Sci Fi Your Pi: PiDesk - Guide: Stepper Motors with Gertbot
- Sci Fi Your Pi: PiDesk - Project Update #4
- Sci Fi Your Pi: PiDesk - Project Update #5
- Sci Fi Your Pi: PiDesk - Guide: Controlling NeoPixels with the Raspberry Pi A+/B+
- Sci Fi Your Pi: PiDesk - Project Update #6
Project Update
There was some nice weather in Belgium the past week, and I took the opportunity to prepare the garden for summer. Mowing the lawn, planting some herbs, cleaning the terrace, etc ... This means that I didn't make a whole lot of progress on my project this week, but it doesn't mean I didn't do anything either. For this week's update, I've been combining some components I got up and running in the previous weeks, more specifically: the Touch Board and the Raspberry Pi with LED strip.
I hooked up the Touch Board via USB to the Raspberry Pi and had it send PLAYX (where X is the number of the electrode pressed) messages to the Pi over serial. Listing the tty devices, I determined the Touch Board was the "ttyACM0" device.
pi@PiDesk ~ $ ls -l /dev/tty tty tty17 tty26 tty35 tty44 tty53 tty62 tty0 tty18 tty27 tty36 tty45 tty54 tty63 tty1 tty19 tty28 tty37 tty46 tty55 tty7 tty10 tty2 tty29 tty38 tty47 tty56 tty8 tty11 tty20 tty3 tty39 tty48 tty57 tty9 tty12 tty21 tty30 tty4 tty49 tty58 ttyACM0 tty13 tty22 tty31 tty40 tty5 tty59 ttyAMA0 tty14 tty23 tty32 tty41 tty50 tty6 ttyprintk tty15 tty24 tty33 tty42 tty51 tty60
I installed "minicom" to verify the expected serial messages where being received by the Pi.
pi@PiDesk ~ $ sudo apt-get install minicom Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: lrzsz The following NEW packages will be installed: lrzsz minicom 0 upgraded, 2 newly installed, 0 to remove and 22 not upgraded. Need to get 420 kB of archives. After this operation, 1189 kB of additional disk space will be used. Do you want to continue [Y/n]? y Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main lrzsz armhf 0.12.21-5 [106 kB] Get:2 http://mirrordirector.raspbian.org/raspbian/ wheezy/main minicom armhf 2.6.1-1 [314 kB] Fetched 420 kB in 2s (173 kB/s) Selecting previously unselected package lrzsz. (Reading database ... 78547 files and directories currently installed.) Unpacking lrzsz (from .../lrzsz_0.12.21-5_armhf.deb) ... Selecting previously unselected package minicom. Unpacking minicom (from .../minicom_2.6.1-1_armhf.deb) ... Processing triggers for man-db ... Processing triggers for menu ... Setting up lrzsz (0.12.21-5) ... Setting up minicom (2.6.1-1) ... Processing triggers for menu ...
Using the minicom command with parameter "s", the serial port information can be configured. I specified the correct interface and baudrate and could see the messages coming in.
pi@PiDesk ~ $ sudo minicom -s
To be able to read from the serial interface from Python, I tried to install the "python-serial" module. It turned out to be pre-installed.
pi@PiDesk ~/rpi_ws281x/python/examples $ sudo apt-get install python-serial Reading package lists... Done Building dependency tree Reading state information... Done python-serial is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 22 not upgraded.
After taking the "strandtest.py" NeoPixel strip example and modifying it to react to serial input, the PLAY messages could trigger the LED strip. It does not yet make a distinction between the buttons being pressed, but the mechanism itself is working.
pi@PiDesk ~/rpi_ws281x/python/examples $ sudo python button.py Press Ctrl-C to quit. PLAY0 PLAY0 PLAY0 PLAY1 PLAY4 PLAY7 PLAY0
The Python script reading the serial input and triggering the LED strip can be found here:
And finally, a short demo:
Top Comments