FunShield an Arduino Educational Platform

12
 http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/ Food Living Outside Play Technology Workshop FunShield, an Arduino Educational Platform by MakersBox on April 5, 2014 Table of Contents FunShield, an Arduino Educational Platform  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Intro: FunShield, an Arduino Educational Platform  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Step 1: Gather the Parts  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Step 2: Gentlement, Start Yo ur Iron  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Step 3 : I2C Hea ders and Shift Register  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Step 4 : Temperature Sensor a nd Transistor  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Step 5: Buttons and Speaker  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Step 6: Let There Be Light! or LEDs.  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Step 7: Measure yo ur Potential - Trim Pot  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Step 8: Heading Ou t, or In - I/O Headers  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Step 9: Final Hot Work - Arduino Heade rs  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Step 10: Start Sparkin  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Step 11: FunShield Library  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Step 12: ArduBlock  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Step 1 3: Example of Comp onent Integration  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Related Instructables  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Advertisements  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Comments  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Transcript of FunShield an Arduino Educational Platform

Page 1: FunShield an Arduino Educational Platform

7/21/2019 FunShield an Arduino Educational Platform

http://slidepdf.com/reader/full/funshield-an-arduino-educational-platform 1/12

Page 2: FunShield an Arduino Educational Platform

7/21/2019 FunShield an Arduino Educational Platform

http://slidepdf.com/reader/full/funshield-an-arduino-educational-platform 2/12

http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/ 

Intro:  FunShield, an Arduino Educational PlatformI’ve been using the SparkFun Inventor's Kit to help teach electronics and programming to Teen Makers at our local public library in Corvallis Oregon. We’ve had lots osuccess, 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 thisshield to so that we could skip the wiring and get right to programming. I’m 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 eightstandard 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 f ind 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 orderpremium. You will also be helping us develop and share other projects!

Page 3: FunShield an Arduino Educational Platform

7/21/2019 FunShield an Arduino Educational Platform

http://slidepdf.com/reader/full/funshield-an-arduino-educational-platform 3/12

http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/ 

Step 1: Gather the PartsTo start, check to see you have everything:

From the SparkFun Inventor's Kit (or your favorite supplier):

(1) Photocell, SparkFun SEN-09088, $1.50(1) SN74HC595N SHIFT REGISTER 16-DIP, SparkFun COM-00733, $1.50(1) IC SENSOR TEMP, SparkFun SEN-10988, $1.50(1) Piezo speaker, SparkFun COM-07950, $1.95(1) TRIMMER 10K OHM 0.2W PC PIN, SparkFun COM-09806, $0.95(1) Mini Push Button, SparkFun COM-00097, $0.35(2) Momentary Push Button Switch - 12mm Square, SparkFun COM-09190, $1.00(1) Common cathod RGB LED 5 or 10mm, SparkFun COM-11120, $0.95(8) Assorted color 5mm LEDs, COM-12062, $2.95

(12) 330 Ohm 1/6W resistor, SparkFun COM-11507, $0.95/ea(4) 10K 1/6W resistor, SparkFun COM-08374, $1.00(1) Diode SparkFun COM-08588, $0.15(1) NPN Transistor, COM-12852, $0.50

Other Items:

(1) PCB Board, http://oshpark.com/shared_projects/lPWpxju2, $22.10 for three copies(1) 40-pin Break away header, SparkFun PRT-00116, $1.50(2) CONN HEADER FEMALE 2POS .1" TIN, Digikey S7000-ND, $0.68(1) CONN FEMALE 4POS .100" R/A GOLD, Digikey S5479-ND, $0.74(1) CONN HEADER 4POS .100 R/A 30AU, Digikey 609-3312-ND, $0.39

Remember, I've done all the hard work if you just want to buy the kit at Tindie.com.

Step 2: Gentlement, Start Your IronWe are going to assume you have some kit-building experience. If you need some help soldering, head over to www.sparkfun.com/tutorials/213 to brush up.

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 othe 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 onyour 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 anblue. 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 valueother components like 10K ohm for the I2C bus are marked on the PCB.

Diode and Photocell:

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 thePCB 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 motoand probably overheat.

The photocell goes in the lower right corner, and has no polarity.

Page 4: FunShield an Arduino Educational Platform

7/21/2019 FunShield an Arduino Educational Platform

http://slidepdf.com/reader/full/funshield-an-arduino-educational-platform 4/12

http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/ 

Image Notes

1. Photo cell (no polarity)2. Diode, observe polarity (black band).

Step 3: I2C Headers and Shift RegisterThe I2C headers on the right side are optional, and will allow you to connect two boards together, or connect to another I2C device like a Wii Nunchuk or Adafruit I2CLCD. They are logically next because they sit so low, but they can be added later if desired.

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. Notthe 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 tcheck 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 morethan one.

Image Notes1. Optional I2C headers for connecting to other boards or I2C devices.

Image Notes1. Shift Register IC. Observe orientation (notch in center on left side.)

Page 5: FunShield an Arduino Educational Platform

7/21/2019 FunShield an Arduino Educational Platform

http://slidepdf.com/reader/full/funshield-an-arduino-educational-platform 5/12

http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/ 

Step 4: Temperature Sensor and TransistorThe 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 magnifyingglass. 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 ttemperature.

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 yourmanufacture. 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 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 poweredirectly from the digital pins.

Image Notes1. TMP36 temperature sensor2. NPN transistor. Check the parts data sheet and the schematic to determine thecorrect orientation. It varies by manufacture!

Image Notes1. Check the part's data sheet to determine the correct orientation. It varies bymanufactures!

Step 5: Buttons and SpeakerNext up are the buttons. There are two input buttons, which can use either the 12mm button or a smaller tactile button, and the reset set button. These do need to beinstalled in a certain direction, the PCB holes are aligned to take care of that (don't bend the pins to fit them in).

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 fartheapart, and fit the PS1202 style speaker sold by Adafruit which doesn't have polarity.

Page 6: FunShield an Arduino Educational Platform

7/21/2019 FunShield an Arduino Educational Platform

http://slidepdf.com/reader/full/funshield-an-arduino-educational-platform 6/12

http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/ 

Image Notes

1. SparkFun style piezo has leads aligned horizontally, and has polarity (checkmarking on bottom of speaker.)

Image Notes

1. Adafruit style piezo. Leads are aligned vertically and have no polarity.

Step 6: Let There Be Light! or LEDs.Time for LEDs. You should have already decided on colors and resistor values, so now you just need to get the correct LEDs in the right spots. LEDs have polarity, withe longer leg being positive. Solder one leg of each LED and then check the seating on the other side (it is easier to reseat if you only have one solder joint to heat up

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 grouand 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 forcommon 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 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.

Image Notes1. Observe polarity. Long lead is positive, flat side of face is negative (shownfacing downward here).

Image Notes1. RGB LED. Should be "common cathode" type unless you modify theconnections on the underside of the board.

Page 7: FunShield an Arduino Educational Platform

7/21/2019 FunShield an Arduino Educational Platform

http://slidepdf.com/reader/full/funshield-an-arduino-educational-platform 7/12

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.

Step 7: Measure your Potential - Trim PotThe potentiometer, or "trim pot" goes in the lower left corner. There are several types of pin arrangements for potentiometer, and the SparkFun kit comes with one thbreadboard friendly with three 0.1" spaced leads in a line. I've also added the offset hole to mount the more common and inexpensive trim pots if that is what you've gon hand.

Image Notes1. Potentiometer or "Trim Pot"

Image Notes1. These inexpensive trim pots can be used as well.

Page 8: FunShield an Arduino Educational Platform

7/21/2019 FunShield an Arduino Educational Platform

http://slidepdf.com/reader/full/funshield-an-arduino-educational-platform 8/12

http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/ 

Step 8: Heading Out, or In - I/O HeadersThere 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 leftconnects 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 flexsensor. 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 Notes1. Male header to hold alignment while soldering.2. 2-pin female header for motor.3. 2-pin female header for analog input like flex sensor.

Image Notes1. 3-pin male header for servo.

Step 9: Final Hot Work - Arduino HeadersThe final bit of soldering you need is to connect the two 8-pin and two 6-pin male headers for connecting the shield to the Arduino. The easiest way I've found to do thto put the headers in place in the Arduino first, and then place the shield over the pins before soldering them in place. This will give you rock-solid alignment.

Image Notes1. Arduino board holds these headers in alignment for soldering.

Page 9: FunShield an Arduino Educational Platform

7/21/2019 FunShield an Arduino Educational Platform

http://slidepdf.com/reader/full/funshield-an-arduino-educational-platform 9/12

http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/ 

Step 10: Start SparkinYou 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, theactually 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.

SparkFun Inventors Kit Guide: http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Kit...

SparkFun Inventors Kit Example Sketches: http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Kit...

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\examplesMAC: drag the "SIK Guide Code" folder into Arduino-x/Contents/Resource/Java/examplesLinux: see http://www.arduino.cc/playground/Learning/Linux

Start the Arduino IDE; the examples should be visible in File/Examples/SIK Guide Code

Here are the FunShield Pin Assignments:

A0 TRIMA1 LIGHTA2 TEMPA3 ANALOGA4 I2C-SDAA5 I2C-SCL

D2 Shift register DataD4 Shift register LatchD12 Shift register Clock

D6 RGB-BLUED9 RGB-REDD10 RGB-GREEN

D3 MOTORD5 SERVOD7 RIGHT BUTTOND8 LEFT BUTTOND11 Speaker

Step 11: FunShield LibraryI have written a library for the FunShield to help take care of the dirty work of setup and pin assignment. The library includes demo sketches to get you going.

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:

Download zip file from: https://github.com/MakersBox/FunShield/archive/mas...1.Unzip the folder.2.Move the libraries/FunShield folder to your Arduino's installation folder (not the sketchbook/libraries folder):3.

Windows: C:\Program Files (x86)\Arduino\librariesRestart the Arduino IDE.4.Example sketches should now show up under:5.

[File] -> [Examples] -> [FunShield]

Page 10: FunShield an Arduino Educational Platform

7/21/2019 FunShield an Arduino Educational Platform

http://slidepdf.com/reader/full/funshield-an-arduino-educational-platform 10/12

http://www.instructables.com/id/FunShield-an-Arduino-Educational-Platform/ 

Step 12: ArduBlockArduBlock is a graphical programming environment that integrates wi th the Arduino IDE. It is an open source project written in Java.

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.1.Move the toolsfolder to your sketchbook folder.2.Move the ArduBlockExamples folder to your sketchbook folder.3.Restart the Arduino IDE.4.Start ArduBlock from [Tools] -> [ArduBlock].5.

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/ 

Open an example project (you will have to navigate to the ../sketchbook/ArduBlockExamples folder.6.

Step 13: Example of Component IntegrationYou are done! I guess that all that is left is to give you a gentle push in the right direction. Let's take a look at the example sketch called "FS_01_LED.ino":

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

A couple of simple variables to help us:

// variable declarations

int led = 0; // Can be any led from 0 to 7

int delayTime = 1000; // Delay time in milliseconds

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");

}

And now for the main loop:

void loop(){

 LED(led, HIGH); // turn LED on

 delay(delayTime);

 LED(led, LOW); // turn LED off

 delay(delayTime);

}

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++){

Page 11: FunShield an Arduino Educational Platform

7/21/2019 FunShield an Arduino Educational Platform

http://slidepdf.com/reader/full/funshield-an-arduino-educational-platform 11/12

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 cthe 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 thetrim() 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!

Page 12: FunShield an Arduino Educational Platform

7/21/2019 FunShield an Arduino Educational Platform

http://slidepdf.com/reader/full/funshield-an-arduino-educational-platform 12/12

htt // i t t bl /id/F Shi ld A d i Ed ti l Pl tf /

Related Instructables

Linux, WiFi,Ethernet , USBShield for

Arduino by

edwin chen

Controlling anLED witharduino and

Wifly shield by

yhtomitsy

Run Ethernetshield on

arduino by

Linksprite

Make Amarinoevaluationshield forAndroid-Arduino-Bluetooth

Experiments bybuildcircuit

The ArduinoDoAnything

Shield by

blinkyblinky

How to tweetfrom an Arduinousing the wifi

sheild by

echoalex

Advertisements

Comments

2 comments Add Comment

 YdnaW says:  Jul 30, 2014. 4:44 AM REP

I'm getting 'fun shield does not name a type' when uploading to the arduino. Am I missing some header files? thanks

 MakersBox says:  Jul 30, 2014. 7:47 AM REP

Step 11 shows you how to install the FunShield library.

Once the library is installed, in your sketch you use the following to access the FunShield functions:

 // sets up and initialize FunShield#include#include // Require for I2C communicationFunShield fs; // Instanciate FunShield instance

Let me know how it goes!