Introduction: Variable Speed Fan With Snap Circuits, Kano Computer
In a previous How-To Guide I demonstrated how to blink a Snap Circuits LED with the Kano Computer (blinking an LED is the “Hello World!” of hardware hacking) and in this guide I’ll demonstrate how to drive a variable speed fan with Snap Circuits and the Kano Computer. I’ll actually use the same Scratch program that I used to blink the LED to control the speed of the motor. When I pressed the up arrow on the Kano keyboard, the LED blinked faster and faster. Conversely, when I pressed the down arrow the LED flashed slower and slower. In this circuit, when I press the up arrow the fan will increase in speed and when I press the down arrow the fan will decrease in speed.
Learning how to drive motors with a microcontroller is a basic skill that you will need if you are interested in robotics. You can safely use the Snap Circuits transistor with the Snap Circuits motor (M4) since there isn't much load on the motor simply spinning the fan attachment. Do see the last step (4), however, for caveats regarding using transistors with motors.
Optional: Mobile Phone Battery Pack (I used the battery pack to power the Kano so I could shoot pictures at my table top photography studio, but you can leave yours connected to your TV and the wall wart that comes with the Kano Computer).
1 Snap Circuits Base Grid (11” x 7.7”) # 6SC BG
1 Snap Circuits Motor # 6SC M4
1 Snap Circuits Wind Fan # 6SC M4B
1 Snap Circuits NPN Transistor # 6SC Q2
1 Snap Circuits Slide Switch # 6SC S1
1 Snap Circuits Battery Holder (2-AA) # 6SC B1
1 Snap Circuits 100 ohm Resistor # 6SC R1
2 Snap Circuits Conductor with 3-snaps # 6SC 03
I created a custom made interface cable to connect the Kano to my Snap Circuits using an HDD indicator LED from and old computer, electronic shrink tubing, wire glue, and the following Snap Circuits Jumper Wires:
1 Jumper Wire 18" (Black) # 6SC J1
1 Jumper Wire 18" (Red) # 6SC J2
Where to get the Kano and Snap Circuits:
Kano Computer website: http://us.kano.me/products/kano-kit
Snaps Circuits (individual parts or whole sets): http://cs-sales.net/sncirepa.html
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Connect the Snap Circuits to Kano Computer Raspberry Pi Header Pin
While I had the Kano Computer disconnected from power, I opened the case and connected a Hard Disk Drive indicator LED from an old computer to pin 9 (Ground) and pin 11 (GPIO17) on the Raspberry Pi. I cut away the LED housing and spliced a red and black Snap Circuits Jumper Wires to connect to my Snap Circuits adjustable speed fan circuit.
Step 2: Build the Adjustable Speed Fan Circuit
The circuit is actually fairly simple. We don't want to connect a motor directly to the Raspberry Pi since this might cause the Raspberry Pi to reset (or worse). The black Snap Circuits Jumper wire is connected to pin 9 (Ground) on the Raspberry Pi and to the (-) terminal on the Snap Circuits Battery Block. The red Snap Circuits Jumper wire is connected to pin 11 (GPIO17) on the Raspberry Pi and to the 100 Ohm resistor (which is connected the base of the NPN Transistor). We'll be using the transistor as an electronic switch. When we set pin 11 to high (3.3 volts) it will switch the transistor on and current can flow thru the circuit and spin the fan. When we set pin 11 to low (0 Volts) it will switch the current off and no current will flow thru the circuit and the fan will soon cease to spin.
In a way the transistor works like the Snap Circuits Slide switch--when the switch is open no current will flow and when the switch is closed current will flow thru the circuit. The advantages are that we are not connecting pin 11 directly to the motor (which can cause more than a few problems on the Raspberry Pi) and that we can switch the transistor on and of really quickly, say, 100 times a second. You couldn't switch the slide switch on and off that quickly!
Step 3: Run Scratchgpio5
To run Scratchgpio5, from the Kano Desktop click on Apps and the click Terminal. At the terminal prompt type:
sudo /bin/bash /home/pi/scratchgpio5/scratchgpio5.sh
...and press the Enter key.
When Scratch opens, click on File then Open and locate the Scratch program from my previous How-To Guide and load it into Scratch. You did save the program didn't you?
Step 4: The Scratch Program to Drive the Snap Circuits Motor
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)
REPEAT 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
Click the green flag (the icon that starts the program). When you press the up arrow the fan will slowly start spinning and continue to increase in speed until the DISPLAY speed reaches 100. When you press the down arrow the fan will decrease in speed until the DISPLAY speed reaches 0 and the fan will stop.
Learning how to drive motors with a microcontroller is a basic skill that you will need if you are interested in robotics. You can safely use the Snap Circuits transistor with the Snap Circuits motor (M4) since there isn't much load on the motor simply spinning the fan attachment. As you increase the load on the motor's axle (for instance connecting it to a gear box) it will tend to draw more current and this can cause the transistor to overheat. And this can change from motor to motor. You can drive a Lego Technic motor to spin simple magnetic stirrer, but an erector set motor will cause the transistor to overheat with no load at all. For a humorous discussion about burning up transistors with motors see the Simone Giertz (Giertz is pronounced "Yetch") video about her Wake-up Machine (NOTE to parents: you'll want to review the video before letting your kids watch it on account of language):
So, if you want to drive a motor in one direction with a microcontroller and don't need to control the speed (for example launching the Snap Circuits Flying Saucer) you can use the Snap Circuits Relay, but that's a topic for another Instructable
Participated in the
Full Spectrum Laser Contest 2016
Participated in the
Robotics Contest 2016
Participated in the
Make it Move Contest 2016