arduino: blink · arduino: blink introduction what is arduino? arduino is a tool for making...

12
Arduino: Blink Introduction What is Arduino? Arduino is a tool for making computers that can sense and control more of the physical world than your desktop computer. It's an open-source physical computing platform based on a simple microcontroller board, and a development environment for writing software for the board. In this lesson you will learn how the make a LED on the Arduino blink. Equipment Computer with Internet Arduino Uno USB cable (A plug to B plug): the kind you would connect to a USB printer Vocabulary Microcontroller – a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals. Sketch – the name that Arduino uses for a program. It's the unit of code that is uploaded to and run on an Arduino board. Procedure Form pairs as instructed by your teacher. You will be completing this Unit with your partner. In Pair Programing you will work together on one computer alternating who is “driving” with the keyboard and mouse. Professional coders work together to reduce errors and increase creativity. The first time you use an Arduino Microcontroller there are several steps, if you are doing this lesson on your own these steps can be found on the Arduino home page. Link This Unit will follow the step for a computer running Windows, click the above link for Mac. Your teacher has complete Steps 1-4. 1. Get an Arduino board and USB cable 2. Download the Arduino environment 3. Connect the board 4. Install the drivers Step 5 Launch the Arduino application: Double-Click the Arduino application. Step 6 Open the blink example sketch: Open the LED blink example sketch: File > Examples > 1.Basics > Blink.

Upload: others

Post on 15-Nov-2019

19 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Arduino: Blink · Arduino: Blink Introduction What is Arduino? Arduino is a tool for making computers that can sense and control more of the physical world than your desktop computer

Arduino: Blink

Introduction

What is Arduino? Arduino is a tool for making

computers that can sense and control more of the

physical world than your desktop computer. It's an

open-source physical computing platform based on a

simple microcontroller board, and a development

environment for writing software for the board. In this

lesson you will learn how the make a LED on the Arduino

blink.

Equipment

✦ Computer with Internet

✦ Arduino Uno

✦ USB cable (A plug to B plug): the kind you would connect to a USB printer

Vocabulary

✦ Microcontroller – a small computer on a single integrated circuit containing a

processor core, memory, and programmable input/output peripherals.

✦ Sketch – the name that Arduino uses for a program. It's the unit of code that is

uploaded to and run on an Arduino board.

Procedure

Form pairs as instructed by your teacher. You will be completing this Unit with your partner.

In Pair Programing you will work together on one computer alternating who is “driving”

with the keyboard and mouse. Professional coders work together to reduce errors and increase

creativity.

The first time you use an Arduino Microcontroller there are several steps, if you are doing this

lesson on your own these steps can be found on the Arduino home page. Link

This Unit will follow the step for a computer running Windows, click the above link for Mac.

Your teacher has complete Steps 1-4. 1. Get an Arduino board and USB cable

2. Download the Arduino environment

3. Connect the board

4. Install the drivers

Step 5 Launch the Arduino application: Double-Click the Arduino application.

Step 6 Open the blink example sketch: Open the LED blink example sketch: File >

Examples > 1.Basics > Blink.

Page 2: Arduino: Blink · Arduino: Blink Introduction What is Arduino? Arduino is a tool for making computers that can sense and control more of the physical world than your desktop computer

Step 7 Select your board: You'll need to select the entry in the Tools > Board menu that

corresponds to your Arduino.

Step 8 Select your serial port: Select the serial device of the Arduino board from the Tools

Serial Port menu. This is likely to beCOM3 or higher (COM1 and COM2 are usually reserved for

hardware serial ports). To find out, you can disconnect your Arduino board and re-open the

Page 3: Arduino: Blink · Arduino: Blink Introduction What is Arduino? Arduino is a tool for making computers that can sense and control more of the physical world than your desktop computer

menu; the entry that disappears should be the Arduino board. Reconnect the board and select

that serial port.

Step 9 Upload the program: Now, simply click the "Upload" button in the environment.

Wait a few seconds - you should see the RX and TX leds on the board flashing. If the upload is

successful, the message "Done uploading." will appear in the status bar. (Note: If you have an

Arduino Mini, NG, or other board, you'll need to physically press the reset button on the board

immediately before pressing the upload button.)

A few seconds after the upload finishes, you should see the pin 13 (L) LED on the board start to

blink (in orange). If it does, congratulations! You've gotten Arduino up-and-running.

In the next lesson you will program your Arduino to light an LED!

Page 4: Arduino: Blink · Arduino: Blink Introduction What is Arduino? Arduino is a tool for making computers that can sense and control more of the physical world than your desktop computer

Arduino: LED

Introduction

Arduino's are great for projects! In this lesson you will light a

LED on a breadboard.

Equipment

✦ Computer with Internet

✦ Arduino Uno

✦ Breadboard

✦ Jumper Wire (2)

✦ Resistors (1-4)

✦ LED (3-5mm)

✦ USB cable (A plug to B plug): the kind you would connect to a USB printer

Vocabulary

✦ Breadboard – a construction base for prototyping of electronics. The solderless

breadboard does not require soldering, it is reusable. This makes it easy to use for

creating temporary prototypes and experimenting with circuit design.

The green bubbles show the direction of the conductive stripes under the breadboard.

✦ Jumper Wire – a short electrical wire with a solid tip at each end used to

interconnect the components in a breadboard. ✦ Resistors – resist the flow of electricity and the higher the value of the resistor, the

more it resists and the less electrical current will flow through it. ✦ LED – light-emitting diode (LED) is a two-lead semiconductor light source. It is a

pn-junction diode, which emits light when activated. When voltage is applied to the

leads, electrons are able to recombine with electron holes within the device, releasing

energy in the form of photons. This effect is called electroluminescence, and the color of

the light (corresponding to the energy of the photon) is determined by the energy band

gap of the semiconductor.

Page 5: Arduino: Blink · Arduino: Blink Introduction What is Arduino? Arduino is a tool for making computers that can sense and control more of the physical world than your desktop computer

Procedure

1. Form pairs as instructed by your teacher. You will be completing this Unit with your partner.

In Pair Programing you will work together on one computer alternating who is “driving”

with the keyboard and mouse. Professional coders work together to reduce errors and increase

creativity.

2. Unplug your Arduino from the computer.

This is how your project will look when complete.

3. Connect the LED. You cannot directly connect an LED to a battery or voltage source, the

LED must be used with a resistor to limit or 'choke' the amount of current flowing through the

LED - otherwise the LED could burn out! The LED has a positive and negative lead. There are

two ways to tell which is the positive lead of the LED and which the negative.

The positive lead is longer.

Page 6: Arduino: Blink · Arduino: Blink Introduction What is Arduino? Arduino is a tool for making computers that can sense and control more of the physical world than your desktop computer

Where the negative lead enters the body of the LED, there is a flat edge to the case of the

LED.

If you happen to have an LED that has a flat side next to the longer lead, you should assume

that the longer lead is positive.

Connect the LED’s Negative lead to the outside blue line and connect the positive lead just to

the inside of the number.

4. Connect the resistor. If you

do not use a resistor with an

LED, then it may well be

destroyed almost immediately,

as too much current will flow

through the LED, heating it and destroying the 'junction'

where the light is produced.

Using this chart choose your

lowest number resistor. The

higher the value of the resistor,

the more it resists and the less

electrical current will flow

through it, therefore the higher

the value the dimmer the light.

Connect the resistor on the same number row as the LED,

direction does not matter.

5. Connect a red(if possible) jumper wire from the Arduino 5 Volt Power Pin (5V) to the outside

red + line.

6. Connect a blue or black(if possible) jumper from the Arduino ground (GND) to the outside

blue - line.

7. Connect your Arduino to your computer with the USB. It lights! Now try the other resistors.

This project did not need a Sketch (the program) because we are not controlling anything, we

are simply giving power to a LED.

Page 7: Arduino: Blink · Arduino: Blink Introduction What is Arduino? Arduino is a tool for making computers that can sense and control more of the physical world than your desktop computer

This lesson was adapted from the excellent set of lessons on the Learn Arduino section of the

Adafruit website, check it out!

https://learn.adafruit.com/category/learn-arduino

In the next lesson you will build with push buttons!

Page 8: Arduino: Blink · Arduino: Blink Introduction What is Arduino? Arduino is a tool for making computers that can sense and control more of the physical world than your desktop computer

Arduino: Push Buttons

Introduction

In this lesson you will program push button to control an

LED.

Equipment

✦ Computer with Internet

✦ Arduino Uno

✦ USB cable

✦ Breadboard

✦ Jumper Wire (6)

✦ Resistor

✦ LED (3-5mm)

✦ Push Switches (2)

Vocabulary

✦ Pair programing – two programmers working one program on one computer.

✦ Breadboard – a construction base for prototyping of electronics. The solderless

breadboard does not require soldering, it is reusable. This makes it easy to use for

creating temporary prototypes and experimenting with circuit design.

✦ Jumper Wire – a short electrical wire with a solid tip at each end used to

interconnect the components in a breadboard. ✦ Resistors – resist the flow of electricity and the higher the value of the resistor, the

more it resists and the less electrical current will flow through it. ✦ LED – light-emitting diode (LED) is a two-lead semiconductor light source. It is a

pn-junction diode, which emits light when activated. When voltage is applied to the

leads, electrons are able to recombine with electron holes within the device, releasing

energy in the form of photons. This effect is called electroluminescence, and the color of

the light (corresponding to the energy of the photon) is determined by the energy band

gap of the semiconductor.

Procedure

1. Form pairs as instructed by your teacher. You will be completing this Unit with your partner.

In Pair Programing you will work together on one computer alternating who is “driving”

with the keyboard and mouse. Professional coders work together to reduce errors and increase

creativity.

2. Unplug your Arduino from the computer.

Page 9: Arduino: Blink · Arduino: Blink Introduction What is Arduino? Arduino is a tool for making computers that can sense and control more of the physical world than your desktop computer

This is how your project will look when complete.

3. Connect the push buttons. Notice the legs of the push button this is how

you will insert it into the breadboard. In the diagram above you will see the legs in green.

3. Connect the LED. Using the diagram above insert your LED as shown with the short lead in

the in the negative line next to the edge of the breadboard.

4. Connect the resistor. The direction of the resistor does not matter.

5. Connect the jumper wires as shown.

Page 10: Arduino: Blink · Arduino: Blink Introduction What is Arduino? Arduino is a tool for making computers that can sense and control more of the physical world than your desktop computer

6. Connect your Arduino to your computer with the USB.

7. Launch the Arduino application and open a new file. Copy and paste this code into the file.

/*

Computer Science 4.4 Arduino: Push Buttons

*/

int ledPin = 5;

int buttonApin = 9;

int buttonBpin = 8;

byte leds = 0;

void setup()

{

pinMode(ledPin, OUTPUT);

pinMode(buttonApin, INPUT_PULLUP);

pinMode(buttonBpin, INPUT_PULLUP);

}

void loop()

{

if (digitalRead(buttonApin) == LOW)

{

digitalWrite(ledPin, HIGH);

}

if (digitalRead(buttonBpin) == LOW)

{

digitalWrite(ledPin, LOW);

}

}

8. Select your board. You'll need to select the entry in the Tools > Board menu that

corresponds to your Arduino Uno.

9. Select your serial port. Select the serial device of the Arduino board from the Tools | Serial

Port menu. This is likely to beCOM3 or higher (COM1 and COM2 are usually reserved for

hardware serial ports). To find out, you can disconnect your Arduino board and re-open the

menu; the entry that disappears should be the Arduino board. Reconnect the board and select

that serial port.

10. Upload the program. Now, simply click the "Upload" button in the environment, when

prompted save your file. Wait a few seconds - you should see the RX and TX leds on the board

flashing. If the upload is successful, the message "Done uploading." will appear in the status

bar.

Page 11: Arduino: Blink · Arduino: Blink Introduction What is Arduino? Arduino is a tool for making computers that can sense and control more of the physical world than your desktop computer

This lesson was adapted from the excellent set of lessons on the Learn Arduino section of the

AdaFruit website, check it out!

https://learn.adafruit.com/category/learn-arduino

In the next lesson you will find, build and show off your own project!

Page 12: Arduino: Blink · Arduino: Blink Introduction What is Arduino? Arduino is a tool for making computers that can sense and control more of the physical world than your desktop computer

Arduino: Gallery Walk

Equipment

✦ Computer with Internet

✦ Arduino Uno

✦ USB cable

✦ Breadboard

✦ Sensor kit(s)

Vocabulary

✦ Gallery Walk – Is a chance for you share your work with your classmates. You will set

up your project so the other students can interact with it. You will check out all the other

projects!

Procedure

1. Form pairs as instructed by your teacher. You will be completing this Unit with your

partner. In Pair Programing you will work together on one computer alternating who is“driving” with the keyboard and mouse. Professional coders work together to reduce errors

and increase creativity.

2. Choose a Lesson: Each team will choose their own Arduino Project and sign up for it with

your instructor. Every team will have a different project. The link will take you to the excellent

set of lessons on the Learn Arduino section of the Adafruit website. This a great place to learn!

3. Build your project.

4. Gallery Walk: Share your work

with class!