Академический Документы
Профессиональный Документы
Культура Документы
Table of Contents
Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/
Intro: FunShield, an Arduino Educational Platform
Ive been using the SparkFun Inventor's Kit to help teach electronics and programming to Teen Makers at our local public library in Corvallis Oregon. Weve had lots of
success, but being able to get a bread-boarded circuit working is sometimes a discouraging hurdle to younger makers, especially if time is limited, so I designed this
shield to so that we could skip the wiring and get right to programming. Im calling it the FunShield because what I really want kids to learn is how fun programming is.
The shield gives you access to input devices like a potentiometer, photocell, push buttons, and a temperature IC. The shield also contains outputs in the form of eight
standard LEDs, an RGB LED, and a piezo speaker. There is no way to hook them up wrong or have conflicting pin assignments.
This Instructable will show you how to build and use the FunShield. I hope you find it as useful and fun as I have!
A kit is available on Tindie.com. Purchasing the kit will save you the time and expense of ordering from several different vendors and avoid the minimum PCB order
premium. You will also be helping us develop and share other projects!
http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/
Step 1: Gather the Parts
To start, check to see you have everything:
Other Items:
Remember, I've done all the hard work if you just want to buy the kit at Tindie.com.
The order of assembly is largely a matter of preference. If you don't have a helper or a vice, I generally go from lowest height to tallest so when the board is reversed on
the table, the parts stay in place.
Resistors:
Let's start with resistors since they are the most plentiful, lowest seating, and easiest to solder. They are more heat resistant and will give you a chance to brush up on
your technique. They also have no polarity, so you can put them in either way.
You will, however, have to get the right values if you want the LED to be the correct brightness. In general, I use 330 ohm for red and yellow and 180 ohm for green and
blue. When in doubt, check your data sheets for the forward voltages, and then calculate the correct resistor for 5 volts at http://led.linear1.org/1led.wiz. Resistor value for
other components like 10K ohm for the I2C bus are marked on the PCB.
Now you are warmed up, time to try something with polarity. Add the diode above the 330 ohm resistor in the upper center of the board, observing the white line on the
PCB and the black band on the diode. This is the "kick-back" diode for the motor transistor, so your motor will not work if it is in backwards (it will just bypass the motor
and probably overheat.
The photocell goes in the lower right corner, and has no polarity.
http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/
Image Notes
1. Photo cell (no polarity)
2. Diode, observe polarity (black band).
The shift register allows us to control the eight LEDs using just three of the Arduino's I/O pins. Itis a 16-pin IC that must go in with the correct orientation to work. Note
the notch in one end. This show which side of the chip has pin one. Match the notch with the outline on the PCB. I usually solder on pin on each diagonal corner and then
check the seating. Double check the orientation, because after you solder more than two pins, it will be very difficult to switch. Trust me, I've had to do it more
than one.
http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/
Step 4: Temperature Sensor and Transistor
The Temperature Sensor and the Transistor look identical except for the markings. Identify them by the markings on the face using a good light and a magnifying
glass. You are looking from something like "TMP36" for the temperature IC, and "2Nxxxx" for the transistor.
The Temperature Sensor goes in the upper left corner with the flat face toward the center of the board. This is an analog device that produces a voltage proportional to
temperature.
The NPN Transistor goes on the upper right side of the board, and may or may not have the flat face pointing toward the center of the board, depending on your
manufacture. Check your data sheet and the schematic above to see where the base, collector, and emitter pins are. The transistor is an electronic switch that lets us use
the small current the Arduino digital pins can supply to control a motor needing 200 milliamps. An LED, on the other hand, only needs 10 milliamps, so can be powered
directly from the digital pins.
Image Notes
1. TMP36 temperature sensor
2. NPN transistor. Check the parts data sheet and the schematic to determine the
correct orientation. It varies by manufacture!
Image Notes
1. Check the part's data sheet to determine the correct orientation. It varies by
manufactures!
The speaker is next. There are two sets of holes. The speaker sold by SparkFun has leads closer together, and has polarity. The set of holes 90 degrees off are farther
apart, and fit the PS1202 style speaker sold by Adafruit which doesn't have polarity.
http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/
Image Notes Image Notes
1. SparkFun style piezo has leads aligned horizontally, and has polarity (check 1. Adafruit style piezo. Leads are aligned vertically and have no polarity.
marking on bottom of speaker.)
The RGB led goes in the upper left corner. There are two types of RGBs, common cathode, where the longer pin has the supply voltage, and each color runs to ground,
and common anode, where the long pin is the ground. In both cases, the longer lead goes through the hole with the square pad. The board comes ready for
common cathode, which comes in SparkFun kits, but can be easily modified for the other if that is what you got from Adafruit. On the underside of the board, cut the CC
pad, and solder-bridge the CA pad. Check both for continuity with a multimeter. Note: I've left enough room to use a 10mm RGB LED instead of the standard 5mm.
http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/
Image Notes
1. For a "Common Anode" RGB, cut the "CC" pad as shown, and bridge the
"CA" pad with solder.
http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/
Step 8: Heading Out, or In - I/O Headers
There wasn't room for all the SparkFun kits components, so I added some headers to help us connect with the outside world. The 2-pin female header on the left
connects the motor to the transistor controlled digital output. The 2-pin female header on the right connects to an analog pin and ground for components like the flex
sensor. Use a piece of male header to hold them in place and aligned while soldering.
For connecting to the servo, add the 3-pin male header next to the motor header.
Image Notes
1. Arduino board holds these headers in alignment for soldering.
http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/
Step 10: Start Sparkin
You should have noticed by now that all the pin assignments are marked on the bottom of the board, and can be used in normal Arduino fashion. In a lot of cases, they
actually match the ones used in the SparkFun Inventors Kit's demonstration sketches. At most, you will just have to change the pin numbers to use them.
Place the "SIK Guide Code" folder in the Arduino IDE "examples" directory:
PC: drag the "SIK Guide Code" folder into C:\program files\Arduino-x\examples
MAC: drag the "SIK Guide Code" folder into Arduino-x/Contents/Resource/Java/examples
Linux: see http://www.arduino.cc/playground/Learning/Linux
Start the Arduino IDE; the examples should be visible in File/Examples/SIK Guide Code
D6 RGB-BLUE
D9 RGB-RED
D10 RGB-GREEN
D3 MOTOR
D5 SERVO
D7 RIGHT BUTTON
D8 LEFT BUTTON
D11 Speaker
The one "gotcha" is that this library has to be installed with the Arduino standard libraries instead of the sketchbook folder like most libraries do. This seems to be a
"software feature" regarding relative paths to the Wire library, which we need to do the cool I2C stuff later on.
Steps:
http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/
Step 12: ArduBlock
ArduBlock is a graphical programming environment that integrates with the Arduino IDE. It is an open source project written in Java.
1. If you haven't downloaded the zip file from: https://github.com/MakersBox/FunShield/archive/master.zip in the previous step, do so now and unzip it.
2. Move the toolsfolder to your sketchbook folder.
3. Move the ArduBlockExamples folder to your sketchbook folder.
4. Restart the Arduino IDE.
5. Start ArduBlock from [Tools] -> [ArduBlock].
If the "ArduBlock" option is not visible, go back and check you got it in the right location.
The actual directory structure should end up looking like: ../sketchbook/tools/ArduBlockTool/tool/ardublock-FunShield.jar
If you are still having trouble, check out the more detailed instructions at http://blog.ardublock.com/engetting-started-ardublockzhardublock/
6. Open an example project (you will have to navigate to the ../sketchbook/ArduBlockExamples folder.
First, we need to indicate we want to use the FunShield library, and instanciate a FunShield object called "fs":
// sets up and initialize FunShield
#include <FunShield.h>
#include <Wire.h> // Require for I2C communication
FunShield fs; // Instanciate FunShield instance
Since the FunShield library handles all the setup, the setup() function can be empty. I usually ad some code to see what is going on via the console:
void setup() {
Serial.begin(9600); // Setup serial communications for troubleshooting
Serial.println("FS_01_LED.ino");
}
You should recognize this as the basic Arduino "blink" sketch, just using the FunShield LED() function instead of digitalWrite().
Lets bring in a for loop so we can turn all the LEDs on and off.
void loop(){
for(led=0; led<8; led++){
LED(led, HIGH); // turn LED on
delay(delayTime);
LED(led, LOW); // turn LED off
}
}
You may want to lower your delayTime value so it doesn't take a full 8 seconds to traverse the LEDs.
Now, how could we get the LED to reverse direction when it reaches the end? Another for loop maybe?
void loop(){
for(led=0; led<8; led++){
http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/
LED(led, HIGH); // turn LED on
delay(delayTime);
LED(led, LOW); // turn LED off
}
for(led=6; led>0; led--){
LED(led, HIGH); // turn LED on
delay(delayTime);
LED(led, LOW); // turn LED off
}
}
Notice I start back on led #6 because led #7 was already lit by the first for loop. I also stop the second loop at led#1 because the other for loop handles it as well.
What if we want to add an audible clue as the light changes direction? Here is where the beauty of the library comes in handy. No need to look up pin numbers. Just call
the speaker() function
void loop(){
for(led=0; led<8; led++){
LED(led, HIGH); // turn LED on
delay(delayTime);
LED(led, LOW); // turn LED off
}
speaker(440, 10); // short beep
for(led=6; led>0; led--){
LED(led, HIGH); // turn LED on
delay(delayTime);
LED(led, LOW); // turn LED off
}
speaker(880, 10); // short beep
}
One final trick to throw in. How about we vary the speed of the LED based on the trim potentiometer value? Piece of cake! Just change the delayTime variable to the
trim() function:
void loop(){
for(led=0; led<8; led++){
LED(led, HIGH); // turn LED on
delay(trim()); // read potentiometer to determine delay time.
LED(led, LOW); // turn LED off
}
speaker(440, 10); // short beep
for(led=6; led>0; led--){
LED(led, HIGH); // turn LED on
delay(trim());
LED(led, LOW); // turn LED off
}
speaker(880, 10); // short beep
}
Wow, that was easy! You have the basis for a cool 2-dimension Pong game. Now go forth and have FUN!
http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/
Related Instructables
Advertisements
Comments
2 comments Add Comment
Once the library is installed, in your sketch you use the following to access the FunShield functions:
http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/