3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

USB controlled mini lava lamps

Step 8Code

The lava lamps will be controlled by system calls to the "setled" program that will turn on and off the capslock and scroll lock LEDs. Test it out by running the following from a command line (possible as root, depending on your configuration) to make your lamps blink:

setleds -L -caps +scroll < /dev/tty0 ;sleep 3s ;setleds -L +caps -scroll < /dev/tty0; sleep 3; setleds -L </dev/tty0

breaking this down:

#To turn on the red lamp:
setleds -L -caps +scroll < /dev/tty0
#to turn on the green lamp:
setleds -L +caps -scroll < /dev/tty0
#to return to the state where the LEDs display the keyboard settings
setleds -L </dev/tty0

You can include these system calls in your own program, or use the a phython unit test module that Chris wrote based on the PyUnit unit testing framework built into python. Just unpack the files from the tar archive (tar -xzvf lava_unittest.tar.gz from a console) and try the following commands from a console:

python lava_unittest.py test_lava_unittest-pass
python lava_unittest.py test_lava_unittest-fail

or

python test_lava_unittest-pass.py
python test_lava_unittest-fail.py

To run from a terminal emulators, uncomment the warning-flagged lines and try running it
as root from a terminal emulator.

With this code, all one needs to do is swap instances of "unittest" with "lava_unittest" in Python scripts written for unit testing. No re-coding is necessary.
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
2
Followers
1
Author:jamesh