background image

You can control up to two motors with a single IC. You can use this diagram 
as a reference for pin numbers in conjunction with the table below.

Image courtesy of ITP at NYU

Hookup Table

PWM signal for controlling the speed of motor A 

2

Direction pin 1 for motor A

Motor A connection 1

4

Ground / Heat Sink 

Ground / Heat Sink 

6

Motor A connection 2

7

Direction pin 2 for motor A 

8 Motor 

supply 

voltage 

PWM signal for controlling the speed of motor B 

10 

Direction pin 1 for motor B 

11 

Motor B connection 1 

12 

Ground / Heat Sink

13 

Ground / Heat Sink

14 

Motor B connection 2 

15 

Direction pin 2 for motor B 

16 

Chip voltage (5V) 

Hardware Hookup

Ready to start hooking everything up? Check out the wiring diagram below 
to see how everything is connected.

Polarized 

Components 

Pay special attention to the component’s markings 
indicating how to place it on the breadboard. 
Polarized components can only be connected to a 
circuit in one direction.

Note: 

It is possible that you may need to bend the legs of your 

H-Bridge in slightly for it to line up with the breadboard. You can do 

Page 50 of 63

Summary of Contents for KIT-14556

Page 1: ...ful way while not breaking the bank When you re done with this guide you ll have the know how to start creating your own projects and experiments From building robots and game controllers to data logging the world will be your oyster Now enough talking let s start tinkering Included Materials Here are all of the parts in the SparkFun Tinker Kit SparkFun RedBoard Our tried and true version of the A...

Page 2: ...e RedBoard without being connected to your computer Sorry Batteries not included Experiment List The following is a list of the experiements you will complete using this Tinker Kit Experiment Guide Alternatively you can navigate around using the buttons on the right Experiment 1 Blinking an LED Experiment 2 Reading a Potentiometer Experiment 3 Driving an RGB LED Experiment 4 Driving Multiple LEDs ...

Page 3: ...milanove was discontinued and the R3 shield compatibility of the latest Arduino UNO R3 The RedBoard can be programmed over a USB Mini B cable using the Arduino IDE Just plug in the board select Arduino UNO from the board menu and you re ready to upload code RedBoard has all of the hardware peripherals you know and love 14 Digital I O pins with 6 PWM pins 6 Analog Inputs UART SPI and external inter...

Page 4: ... of Arduino is only offered in a zip file version After the download is finished simply double click the zip file to unzip it Following that you ll need to copy the Arduino application into your applications folder to complete installation Linux Install Tips As Linux users are no doubt aware there are many flavors of Linux out there each with unique installation routines Check out the Linux sectio...

Page 5: ...ding the most up to date VCP drivers Then you ll simply run the FTDIUSBSerialDriver_v2_2_18 dmg file you downloaded and follow the installation prompts Linux Driver Installation Linux is actually pretty good about automatically installing the drivers If you have any trouble check out our Linux FTDI Driver install guide Now it s time to breathe easy You ll only have to run through this driver insta...

Page 6: ...ing with this experiment we recommend you be familiar with the concepts in the following tutorial Light Emitting Diodes Learn more about LEDs Introducing the LED SparkFun RedBoard Programmed with Arduino DEV 12757 Breadboard Self Adhesive White PRT 12002 Jumper Wires Connected 6 M M 20 pack PRT 12795 LED Basic Red 5mm COM 09590 Resistor 330 Ohm 1 6 Watt PTH 20 pack COM 11507 Page 6 of 63 ...

Page 7: ... to a burnt out LED To restrict the amount of current that passes through the LED we use a resistor in line with the power source and the LED s long leg this is called a current limiting resistor With the RedBoard you should use a 330 Ohm resistor We have included a baggy of them in the kit just for this reason Hardware Hookup Ready to start hooking everything up Check out the wiring diagram and h...

Page 8: ...ick on the wiring diagram for a closer look Open Your First Sketch Open the Arduino IDE software on your computer Coding in the Arduino language will control your circuit Open the code for Circuit 1 by accessing the Tinker Kit Guide Code you downloaded and placed into your Examples folder earlier To open the code go to File Examples Tinker Kit Guide Code Circuit_01 You can also copy and paste the ...

Page 9: ...tself until you upload new code or power down your Arduino void loop Turn pin 13 HIGH ON digitalWrite 13 HIGH wait 1000 milliseconds 1 second delay 1000 Turn pin 13 LOW OFF digitalWrite 13 LOW wait 1000 milliseconds delay 1000 Code to Note pinMode 13 OUTPUT Before you can use one of the RedBoards pins you need to tell the board whether it is an INPUT or OUTPUT We use a built in function called pin...

Page 10: ...sparkfun com Experiment 2 Reading a Potentiometer Introduction In this circuit you will work with a potentiometer You will learn how to use a potentiometer to control the timing of a blinking LED by reading a sensor and storing it as a variable then using it as your delay timing Parts Needed You will need the following parts 1x Breadboard 1x SparkFun RedBoard 1x LED 1x 330Ω Resistor 7x Jumper Wire...

Page 11: ...tation of its knob The potentiometer has an internal voltage divider enabling you to read the change in voltage on the center pin with a microcontroller the RedBoard To hook up the potentiometer attach the two outside pins to a supply voltage 5V in this circuit and ground It doesn t matter which is connected where as long as Trimpot 10K with Knob COM 09806 Jumper Wires Connected 6 M M 20 pack PRT ...

Page 12: ...onents Pay special attention to the component s markings indicating how to place it on the breadboard Polarized components can only be connected to a circuit in one direction Wiring Diagram for the Experiment Having a hard time seeing the circuit Click on the wiring diagram for a closer look Open the Sketch Open the Arduino IDE software on your computer Coding in the Arduino language will control ...

Page 13: ...nd initializing it to have the value 0 which is the ana log input pin the pot is conected to int sensorPin 0 Variable for storing the pin number that the LED is connect ed to int ledPin 13 this function runs once when the sketch starts up void setup set ledPin 13 as an OUTPUT pinMode ledPin OUTPUT this function runs repeatedly after setup finishes void loop create a local variable variable that ca...

Page 14: ...the code delay counts in milliseconds there are 1 000 ms in one second What You Should See You should see the LED blink faster or slower in accordance with your potentiometer If it isn t working make sure you have assembled the circuit correctly and verified and uploaded the code to your board or see the Troubleshooting section Troubleshooting Sporadically Working This is most likely due to a slig...

Page 15: ...owing parts 1x Breadboard 1x SparkFun RedBoard 1x Common Cathode RGB LED 3x 330Ω Resistors 6x Jumper Wires Didn t Get the Tinker Kit If you are conducting this experiment and didn t get the Tinker Kit we suggest using these parts SparkFun RedBoard Programmed with Arduino DEV 12757 Breadboard Self Adhesive White PRT 12002 LED RGB Clear Common Cathode COM 00105 Jumper Wires Connected 6 M M 20 pack P...

Page 16: ...d to the left as shown in the graphic below The pins are Red Ground Green and Blue starting from the far left Note When wiring the RGB each colored pin still needs a current limiting resistor in line with the RedBoard pin that you plan to use to control it as with any standard LED Hardware Hookup Ready to start hooking everything up Check out the wiring diagram and hookup table below to see how ev...

Page 17: ...omputer Coding in the Arduino language will control your circuit Open the code for Circuit 3 by accessing the Tinker Kit Guide Code you downloaded and placed into your Examples folder earlier To open the code go to File Examples Tinker Kit Guide Code Circuit_03 You can also copy and paste the following code into the Arduino IDE Hit upload and see what happens Page 17 of 63 ...

Page 18: ...in milliseconds int DISPLAY_TIME 10 void setup set the three pin variables as outputs pinMode RED_PIN OUTPUT pinMode GREEN_PIN OUTPUT pinMode BLUE_PIN OUTPUT void loop We ve written a custom function called mainColors that st eps through all eight of these colors We re only calling the function here telling it to run The actual function code is further down in the sketch mainColors Here s the main...

Page 19: ...an turn green and blue on digitalWrite RED_PIN LOW digitalWrite GREEN_PIN HIGH digitalWrite BLUE_PIN HIGH wait 1 second delay 1000 Purple turn red and blue on digitalWrite RED_PIN HIGH digitalWrite GREEN_PIN LOW digitalWrite BLUE_PIN HIGH wait 1 second delay 1000 White turn all the LEDs on digitalWrite RED_PIN HIGH digitalWrite GREEN_PIN HIGH digitalWrite BLUE_PIN HIGH wait 1 second delay 1000 Cod...

Page 20: ...ng Red The red diode within the RGB LED may be a bit brighter than the other two To make your colors more balanced use a higher ohm resistor Experiment 4 Driving Multiple LEDs Introduction Now that you ve gotten your LED to blink on and off it s time to up the stakes a little bit by connecting six LEDs at once We ll also give your RedBoard a little test by creating various lighting sequences This ...

Page 21: ...nent s markings indicating how to place it on the breadboard Polarized components can only be connected to a circuit in one direction Wiring Diagram for the Experiment SparkFun RedBoard Programmed with Arduino DEV 12757 Breadboard Self Adhesive White PRT 12002 Jumper Wires Connected 6 M M 20 pack PRT 12795 LED Basic Red 5mm COM 09590 Resistor 330 Ohm 1 6 Watt PTH 20 pack COM 11507 Page 21 of 63 ...

Page 22: ... the Arduino language will control your circuit Open the code for Circuit 4 by accessing the Tinker Kit Guide Code you downloaded and placed into your Examples folder earlier To open the code go to File Examples Tinker Kit Guide Code Circuit_04 You can also copy and paste the following code into the Arduino IDE Hit upload and see what happens Page 22 of 63 ...

Page 23: ...es int ledPins 4 5 6 7 8 9 void setup create a local variable to store the index of which pin w e want to control int index For the for loop below these are the three statements 1 index 0 Before starting make index 0 2 index 5 If index is less or equal to 5 run th e following code 3 index Putting after a variable means add o ne to it When the test in statement 2 is finally false the sketch will co...

Page 24: ...ED and repeat until all the LEDs are on It will th en turn them off in the reverse order void oneAfterAnotherNoLoop time milliseconds to pause between LEDs int delayTime 100 turn all the LEDs on digitalWrite ledPins 0 HIGH Turns on LED 0 pin 4 delay delayTime wait delayTime millisecon ds digitalWrite ledPins 1 HIGH Turns on LED 1 pin 5 delay delayTime wait delayTime millisecon ds digitalWrite ledP...

Page 25: ...eAfterAnotherLoop This function does exactly the same thing as oneAfterAnotherNo Loop but it takes advantage of for loops and the array to do it w ith much less typing void oneAfterAnotherLoop int index int delayTime 100 milliseconds to pause between LEDs make this smaller for faster switchi ng Turn all the LEDs on This for loop will step index from 0 to 5 putting after a variable means add one to...

Page 26: ...hrough the LEDs lighting one at at time in both directions void pingPong int index int delayTime 100 milliseconds to pause between LEDs make this smaller for faster switchi ng step through the LEDs from 0 to 5 for index 0 index 5 index digitalWrite ledPins index HIGH turn LED on delay delayTime pause to slow down digitalWrite ledPins index LOW turn LED off step through the LEDs from 5 to 0 for ind...

Page 27: ...n on random LEDs Can you modify it so i t also lights them for random times void randomLED int index int delayTime The random function will return a semi random number ea ch time it is called See http arduino cc en Reference Ran dom for tips on how to make random even more random index random 5 pick a random number between 0 and 5 delayTime 100 digitalWrite ledPins index HIGH turn LED on delay del...

Page 28: ...Troubleshooting Some LEDs Fail to Light It is easy to insert an LED backward Check the LEDs that aren t working and ensure they are in the correct orientation Operating out of Sequence With eight wires it s easy to cross a couple Double check that the first LED is plugged into pin 4 and each pin thereafter Starting Fresh It s easy to accidentally misplace a wire without noticing Pulling everything...

Page 29: ...t get the Tinker Kit we suggest using these parts SparkFun RedBoard Programmed with Arduino DEV 12757 Breadboard Self Adhesive White PRT 12002 Momentary Pushbutton Switch 12mm Square COM 09190 LED RGB Clear Common Cathode COM 00105 Jumper Wires Connected 6 M M 20 pack PRT 12795 Resistor 330 Ohm 1 6 Watt PTH 20 pack COM 11507 Page 29 of 63 ...

Page 30: ...h in one direction Once you get the button pressed firmly into the breadboard across the ditch the pins are horizontally paired The pins toward the top of the breadboard are connected and the pins toward the button of the breadboard are connected Note Not all buttons share this pin format Please refer to the data sheet of your specific button to determine which pins are paired up Hardware Hookup R...

Page 31: ...lid connection to either 5V or ground The pin could read as either one To deal with this issue we ll connect a small 10K or 10 000 Ohm resistance between the signal pin and 5V This pull up resistor will ensure that when you re NOT pushing the button the pin will still have a weak connection to 5 volts and therefore read as HIGH Advanced When you get used to pull up resistors and know when they re ...

Page 32: ...9 create a variable to store a counter and set it to 0 int counter 0 void setup Set up the pushbutton pins to be an input pinMode buttonPin INPUT Set up the RGB pins to be an outputs pinMode redPin OUTPUT pinMode greenPin OUTPUT pinMode bluePin OUTPUT void loop local variable to hold the pushbutton states int buttonState read the digital state of buttonPin with digitalRead fun ction and store the ...

Page 33: ...gital pins can be used as inputs as well as outputs Before you do either you need to tell the Arduino which direction you re going buttonState digitalRead buttonPin To read a digital input you use the digitalRead function It will return HIGH if there s 3 3V present at the pin or LOW if there s 0V present at the pin if button1State LOW Because we ve connected the button to GND it will read LOW when...

Page 34: ...s the voltage being read by the analog input pin In this circuit you ll be using a photoresistor which changes resistance based on how much light the sensor receives You will read the light value of the room and have an LED turn on if it is dark and turn off if it is bright That s right you are going to build a night light Parts Needed You will need the following parts 1x Breadboard 1x SparkFun Re...

Page 35: ...oresistor Mini Photocell SEN 09088 Jumper Wires Connected 6 M M 20 pack PRT 12795 LED Basic Red 5mm COM 09590 Resistor 330 Ohm 1 6 Watt PTH 20 pack COM 11507 Resistor 10K Ohm 1 6th Watt PTH 20 pack COM 11508 Page 35 of 63 ...

Page 36: ...ial on voltage dividers Note Make sure you are using the 10K Ohm resistor in your voltage divider with the sensors in this kit Otherwise you will get odd and inconsistent results Hardware Hookup Ready to start hooking everything up Check out the wiring diagram below to see how everything is connected Polarized Components Pay special attention to the component s markings indicating how to place it ...

Page 37: ...ariables for the light leve l a calibration value and and a raw light value int lightCal int lightVal void setup We ll set up the LED pin to be an output pinMode ledPin OUTPUT lightCal analogRead sensorPin we will take a single reading from the light sensor and st ore it in the lightCal variable This will give us a prelinary value to compare against in the loop void loop Take a reading using analo...

Page 38: ...g it If it isn t working make sure you have assembled the circuit correctly and verified and uploaded the code to your board or see the Troubleshooting section Troubleshooting LED Remains Dark You may have been casting a shadow over the sensor when you uploaded your code Make sure the sensor is exposed to the ambient light of the room and press the MASTER RESET button or re upload your code This w...

Page 39: ...rts Introducing the TMP36 Temperature Sensor The TMP36 is a low voltage precision centigrade temperature sensor It provides a voltage output that is linearly proportional to the Celsius temperature It also doesn t require any external calibration to provide SparkFun RedBoard Programmed with Arduino DEV 12757 Breadboard Self Adhesive White PRT 12002 Temperature Sensor TMP36 SEN 10988 Jumper Wires C...

Page 40: ...on to the component s markings indicating how to place it on the breadboard Polarized components can only be connected to a circuit in one direction Please note The temperature sensor can only be connected to a circuit in one direction See below for the pin outs of the temperature sensor TMP36 Wiring Diagram for the Experiment Having a hard time seeing the circuit Click on the wiring diagram for a...

Page 41: ...ariable float volts final temperature variables float tempC float tempF void setup start the serial port at 9600 baud Serial begin 9600 void loop read the temp sensor and store it in tempVal tempVal analogRead tempPin print out the 10 value from analogRead Serial print TempVal Serial print tempVal print a spacer Serial print converting that reading to voltage by multiplying the readi ng by 5V volt...

Page 42: ...ln tempF Serial print will print everything on the same line Serial println will move to the next line By using both of these commands together you can create easy to read printouts of text and data What You Should See You should be able to read the temperature your temperature sensor is detecting on the serial monitor in the Arduino IDE If it isn t working make sure you have assembled the circuit...

Page 43: ...eally Hot You have wired it backward Unplug your Arduino immediately let the sensor cool down and double check your wiring If you catch it soon enough your sensor may not have been damaged and may still work Experiment 8 Using a Servo Motor Introduction This experiment is your introduction to the servo motor which is a smart motor that you can tell to rotate to a specific angular location You will...

Page 44: ...side of the servo there is a gearbox connected to a motor that drives the shaft There is also a potentiometer that gives feedback on the rotational position of the servo which is then compared to the incoming PWM signal The servo adjusts accordingly to match the two signals In this experiment the servo is powered through 5 volts on the red wire ground on the black wire and the white wire is connec...

Page 45: ...make it easier to breadboard the servo Wiring Diagram for the Experiment Having a hard time seeing the circuit Click on the wiring diagram for a closer look Open the Sketch Open the Arduino IDE software on your computer Coding in the Arduino language will control your circuit Open the code for Circuit 8 by accessing the Tinker Kit Guide Code you downloaded and placed into your Examples folder earl...

Page 46: ...pin 9 on the Arduino 101 servo1 attach 9 void loop create a local variable to store the servo s position int position To control a servo you give it the angle you d like it to turn to Servos cannot turn a full 360 degrees but yo u can tell it to move anywhere between 0 and 180 degrees Change position at full speed Tell servo to go to 90 degrees servo1 write 90 Pause to get it time to move delay 10...

Page 47: ...me each one in this way servo1 attach 9 The Servo library adds new commands that let you control a servo To prepare the RedBoard to control a servo you must first create a Servo object for each servo here we ve named it servo1 and then attach it to a digital pin here we re using pin 9 Think of this as the servo s way of calling a pinMode function servo1 write 180 The servos in this kit don t spin ...

Page 48: ... this problem Experiment 9 Driving a Motor with an H Bridge Introduction How could you make a motor spin in different directions With an H Bridge In this experiment you will use the H Bridge to control the motor s direction and speed Parts Needed You will need the following parts 1x Breadboard 1x SparkFun RedBoard 1x SN754410 H Bridge IC 1x 48 1 Geared Motor 12x Jumper Wires Didn t Get the Tinker ...

Page 49: ...se two pins to toggle pins on the board either HIGH or LOW If the two direction pins are both HIGH or LOW at the same time that causes the board to brake the motors If one pin is HIGH and the other is LOW the motor spins in one direction If you flip flop the states the motor spins in the opposite direction The IC is also powered separately with 5V supplied to pin 16 on the IC and up to 36V for the...

Page 50: ...d of motor B 10 Direction pin 1 for motor B 11 Motor B connection 1 12 Ground Heat Sink 13 Ground Heat Sink 14 Motor B connection 2 15 Direction pin 2 for motor B 16 Chip voltage 5V Hardware Hookup Ready to start hooking everything up Check out the wiring diagram below to see how everything is connected Polarized Components Pay special attention to the component s markings indicating how to place ...

Page 51: ...r look Open the Sketch Open the Arduino IDE software on your computer Coding in the Arduino language will control your circuit Open the code for Circuit 9 by accessing the Tinker Kit Guide Code you downloaded and placed into your Examples folder earlier To open the code go to File Examples Tinker Kit Guide Code Circuit_09 You can also copy and paste the following code into the Arduino IDE Hit uplo...

Page 52: ...OUTPUT pinMode DIR_B OUTPUT pinMode PWM OUTPUT void loop drive forward at full speed by pulling DIR_A High and DIR_B low while writing a full 255 to PWM to control speed digitalWrite DIR_A HIGH digitalWrite DIR_B LOW analogWrite PWM 255 wait 1 second delay 1000 Brake the motor by pulling both direction pins to the same state in this case LOW PWM doesn t matter in a brake situation but set as 0 dig...

Page 53: ...M 0 This final chunk of code demonstrates the logic for stopping or braking the motor by pulling both direction pins to the same state In this case we used LOW but both set to HIGH would produce the same results In a brake the PWM level doesn t matter We set it to 0 as more of a formality than anything If not see the Troubleshooting section below What You Should See You should see the motor spin i...

Page 54: ...ch as you would your own car In this experiment we will add two inputs and use them to control the direction and speed of your motor Are you ready to get your motor running Let s go Parts Needed You will need the following parts 1x Breadboard 1x SparkFun RedBoard 1x Push Button 1x 10K potentiometer 1x H Bridge IC 1x 48 1 ratio Gearmotor 20x Jumper Wires Didn t Get the Tinker Kit If you are conduct...

Page 55: ...ram for the Experiment Having a hard time seeing the circuit Click on the wiring diagram for a closer look CAUTION You will be using voltage that may be higher than the limit of the circuitry on your RedBoard allows Make sure you keep motor voltage MV isolated from other circuitry Accidentally using MV to power other circuitry may cause irreparable damage to your RedBoard Open the Sketch Jumper Wi...

Page 56: ...n the code for Circuit 10 by accessing the Tinker Kit Guide Code you downloaded and placed into your Examples folder earlier To open the code go to File Examples Tinker Kit Guide Code Circuit_10 You can also copy and paste the following code into the Arduino IDE Hit upload and see what happens Page 56 of 63 ...

Page 57: ...void setup set all pins as output pinMode DIR_A OUTPUT pinMode DIR_B OUTPUT pinMode PWM OUTPUT set the switchPin as INPUT pinMode switchPin INPUT void loop read the value from the potentiometer and divide it by 4 to get a 0 255 range Store the value in the speed variable int speed analogRead potPin 4 read the value of the switch and store it in the direction variable if the value of direction is H...

Page 58: ...more modular and useful in other applications Watch out You are halfway to writing your own library What You Should See You should be able to control the motor s direction by flipping the SPDT switch and then the speed through the potentiometer Go ahead and play with both inputs to make sure they both work and the motor is responding to those inputs Troubleshooting Motor Only Spins in One Directio...

Page 59: ...following parts 1x Breadboard 1x SparkFun RedBoard 1x Common Cathode RGB LED 3x 330Ω Resistors 6x Jumper Wires Didn t Get the Tinker Kit If you are conducting this experiment and didn t get the Tinker Kit we suggest using these parts SparkFun RedBoard Programmed with Arduino DEV 12757 Breadboard Self Adhesive White PRT 12002 LED RGB Clear Common Cathode COM 00105 Jumper Wires Connected 6 M M 20 pa...

Page 60: ...agram for the Experiment Having a hard time seeing the circuit Click on the wiring diagram for a closer look Open the Sketch Open the Arduino IDE software on your computer Coding in the Arduino language will control your circuit Open the code for Circuit 3 by accessing the Tinker Kit Guide Code you downloaded and placed into your Examples folder earlier To open the code go to File Examples Tinker ...

Page 61: ...nst int RED_PIN 5 const int GREEN_PIN 6 const int BLUE_PIN 9 How fast we plan to cycle through colors in milliseconds int redVal 0 int greenVal 0 int blueVal 0 void setup set the three pin variables as outputs pinMode RED_PIN OUTPUT pinMode GREEN_PIN OUTPUT pinMode BLUE_PIN OUTPUT Start the Serial port at 9600 baud rate Serial begin 9600 Serial println Please enter your RGB in CSV format Example 2...

Page 62: ...load is complete Open up the Serial Monitor The magnifying glass icon in the upper right hand corner of the Arduino IDE You should see the text Please enter your RGB in CSV format Example 255 100 0 print out in the serial monitor Enter an RGB value we are using 255 100 0 as an example in the text entry area as shown below and click Send Once you click the send button your RGB should turn a purple ...

Page 63: ...brary Arduino Data Types For more hardware related tutorials give these a read Breadboards Working with Wire Sewing with Conductive Thread Page 63 of 63 6 14 2016 https learn sparkfun com tutorials experiment guide for the sparkfun tinker kit all ...

Reviews: