Experiment Guide for the SparkFun Tinker Kit

Pages
Contributors: D___Run___
Favorited Favorite 1

Experiment 1: Blink an LED

Introduction

LEDs are small, powerful lights that are used in many different applications. To start off, we will work on blinking an LED, the “Hello, World!” of microcontrollers. That’s right – it’s as simple as turning a light on and off. It might not seem like much, but establishing this important baseline will give you a solid foundation as we work toward more complex experiments.

Parts Needed

You will need the following parts:

  • 1x Breadboard
  • 1x SparkFun RedBoard
  • 1x LED
  • 1x 330Ω Resistor
  • 3x 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:

Breadboard - Self-Adhesive (White)

PRT-12002
$4.95
35
Jumper Wires - Connected 6" (M/M, 20 pack)

PRT-12795
$1.95
2
Resistor 330 Ohm 1/6 Watt PTH - 20 pack

COM-11507
$0.95
2
LED - Basic Red 5mm

COM-09590
$0.35

DEV-12757
127 Retired

Suggested Reading

Before continuing with this experiment, we recommend you be familiar with the concepts in the following tutorial:

Introducing the LED

alt text

A Light-Emitting Diode (LED) will only let current through it in one direction. Think of an LED as a one-way street. When current flows through the LED, it lights up! When you are looking at the LED, you will notice that its legs are different lengths. The long leg, the “anode,” is where current enters the LED. This pin should always be connected to the current source. The shorter leg, the “cathode,” is the current’s exit. The short leg should always be connected to a pathway to ground.

LEDs are finicky when it comes to how much current you apply to them. Too much current can lead 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 hookup table below to see how everything is connected.

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.

Please note: Pay close attention to the LED. The negative side of the LED is the short leg, marked with a flat edge.

LED drawing

Components like resistors need to have their legs bent into 90° angles in order to correctly fit the breadboard sockets. You can also cut the legs shorter to make them easier to work with on the breadboard.

Bent resistor

Wiring Diagram for the Experiment

alt text

Having a hard time seeing the circuit? Click 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.

You can type out or copy and paste the following code into the Arduino IDE. Hit upload, and see what happens!

language:cpp
/*
SparkFun Tinker Kit 
Example sketch 01

BLINKING AN LED

Turn an LED on for one second, off for one second,
and repeat forever.

This sketch was written by SparkFun Electronics,
with lots of help from the Arduino community.
This code is completely free for any use.
Visit http://learn.sparkfun.com/products/2 for SIK information.
Visit http://www.arduino.cc to learn about Arduino.
*/



//The setup function runs once upon your Arduino being powered or once upload is          //complete.

void setup()
{
  //set pin 13 to OUTPUT 
  pinMode(13, OUTPUT);
}

//The loop function runs from the top down and repeats itself 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 pinMode() to do this.

digitalWrite(13, HIGH);

When you’re using a pin as an OUTPUT, you can command it to be HIGH (output 5 volts), or LOW (output 0 volts).

What You Should See

You should see your LED blink on and off. If it doesn’t, make sure you have assembled the circuit correctly and verified and uploaded the code to your board, or see the Troubleshooting section.

Tinker Kit Circuit 1

Troubleshooting

Program Not Uploading

This happens sometimes; the most likely cause is a confused serial port. You can change this in Tools > Serial Port >

Still No Success

A broken circuit is no fun. Send us an email, and we will get back to you as soon as we can: techsupport@sparkfun.com