I'll demonstrate how to isolate two different circuits, the littleBits motor circuit and the Kano Computer, with an Opto-solator, or optocoupler.
An optocoupler, according to Wikipedia, "is a component that transfers electrical signals between two isolated circuits by using light." The Kano Computer is one isolated circuit and the littleBits Light Sensor/Motor is the second isolated circuit. I'll use the Kano Computer to flash an LED (Light Emitting Diode) and these flashes are read by the littleBits Light Sensor to turn the littleBits motor on and off. </p><p>While the LED of the Kano is switched on, the light sensor will switch the motor on and when the LED is switched off the light sensor will switch the motor off. The faster the LED is switched on and off, the faster the motor will spin. Conversely, the slower the LED is switched on and off, the slower the motor will spin.
To get the Kano Computer to flash an LED, you'll need to install the scratchgpio5 software on the Kano. For detailed instructions see my review of the Kano computer here. Also, if you're not familiar with littleBits, see my review here. In my review of the Kano Computer, I demonstrated how to use MIT's Scratch graphical programming language on the Kano to flash an LED (the "Hello World!" program of hardware hacking). I'll again demonstrate how to flash an LED, but using a special variable in Scratch called "MotorA". Scratch automatically handles all of the programming for MotorA to produce a "pulse width modulation" (PWM) signal on Pin 11 of the Raspberry Pi. For a primer on pulse width modulation, see this article. I'll show you how to write a simple program to increase and decrease the flashing of an LED by pressing keys on the Kano keyboard.
Create the MotorA variable in Scratch
On the Kano, open up the Scratchgpio5 version of Scratch. In the Kano version of Scratch, click on Variables (on the web version click on Data). Click on the "Make a Variable" button and type "MotorA" in the textbox.
Click the "OK" button and Scratch will create all the motor control variables for you.
The following is the Scratch program I created to control the flashing of an LED:
The Scratch program is fairly simple:
WHEN THE GREEN FLAG ICON IS CLICKED
DISPLAY MESSAGE: "Press up arrow to increase speed, down arrow to decrease speed, or spacebar to exit."
SET MOTOR A TO 0 (Stop motor)
WAIT .01 SECS (Slows processing down enough to display one keypress at a time)
DISPLAY THE SPEED SETTING OF MOTOR A
IF UP ARROW KEY PRESSED
INCREASE MOTOR SPEED BY 1
IF DOWN ARROW KEY PRESSED
DECREASE MOTOR SPEED BY 1
IF MOTOR SPEED IS GREATER THAN 100
SET MOTOR SPEED TO 100
IF MOTOR SPEED IS LESS THAN ZERO
SET MOTOR SPEED TO 0
UNTIL SPACEBAR IS PRESSED
SET MOTOR SPEED TO 0
Build the laser mirror spinner
To be able to view the sound wave patterns we'll need to bounce the laser beam off a spinning mirror and then project the beam on to a screen. Here's how I built my laser mirror spinner out of Lego and littleBits:
Test the Kano computer and laser spinner
In the following video I have the LED from the Kano computer plugged into the hole in the Lego Technic plate above the LDR (Light Dependent Resistor) on the littleBits light sensor module. When I press the up arrow on the Kano keyboard the LED flashes faster and faster and the light sensor switches the littleBits motor on and off faster and faster—thus the mirror spins faster and faster. When I press the down arrow on the Kano keyboard the LED flashes slower and slower, the light sensor switches the littleBits motor on and off slower, and the mirror spins slower.
Build the laser mount, speaker mount, and graph paper display screen
Now we'll have to hang the laser and the speaker at about the same level as the spinning mirror (it's easier to aim the laser at the mirror on the speaker, then at the spinning mirror, and then at the graph paper...Read more »