Lesson 1 Blinking LED
Lesson 1 Blinking LED
What is Arduino?
ARDUINO BOARD
Arduino senses the environment by receiving inputs from many sensors, and
affects its surroundings by controlling lights, motors, and other actuators.
ARDUINO SOFTWARE
You can tell your Arduino what to do by writing code in the Arduino
programming language and using the Arduino development environment.
Before the development of Arduino program, the first thing you have to do is to
install Arduino IDE software. The software provides you with the basic
development environment that is required for developing Arduino program.
You need the following URL to download Arduino IDE:
http://www.arduino.cc /en/Main/Software
For different operating system platforms, the way of using Arduino IDE is
different. Please refer to the following links:
Windows User:http://www.arduino.cc /en/Guide/Windows
Mac OS X User:http://www.arduino.cc /en/Guide/MacOSX
Linux User:http://playground.arduino.cc /Learning/Linux
For more detailed information about Arduino IDE, please refer to the following
link:
http://www.arduino.cc /en/Guide/HomePage
-1-
Lesson 1 Blinking LED
Overview
In this tutorial, we will start the journey of learning Arduino UNO. In the first
lesson, we will learn how to make a LED blinking.
Requirement
- 1* Arduino UNO
- 1* USB Cable
- 1* 220Ω Resistor
- 1* LED
- 1* Breadboard
- 2* Jumper Wires
Principle
In this lesson, we will program the Arduino's GPIO output high(+5V) and low
level(0V), and then make the LED which is connected to the Arduino’s GPIO
flicker with a certain frequency.
1. What is the LED?
In general, the drive current for LED is 5-20mA. Therefore, in reality it usually
needs an extra resistor for current limitation so as to protect the LED.
-2-
2. What is the resistor?
The main function of the resistor is to limit current. In the circuit, the character
‘R’ represents resistor, and the unit of resistor is ohm(Ω).
The band resistor is used in this experiment. A band resistor is one whose
surface is coated with some particular color through which the resistance can
be identified directly.
R = U / I = 5V / (5~20mA) = 250Ω~1KΩ
Since the LED has a certain resistance, thus we choose a 220ohm resistor.
-3-
3. Key functions:
● setup()
The setup() function is called when a sketch starts. Use it to initialize variables,
pin modes, start using libraries, etc. The setup function will only run once,
after each powerup or reset of the Arduino board.
●loop()
After creating a setup() function, which initializes and sets the initial values,
the loop() function does precisely what its name suggests, and loops
consecutively, allowing your program to change and respond. Use it to actively
control the Arduino board.
●pinMode()
●digitalWrite()
If the pin has been configured as an OUTPUT with pinMode(), its voltage will be
set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V
(ground) for LOW.
●delay()
Pauses the program for the amount of time (in miliseconds) specified as
parameter. (There are 1000 milliseconds in a second.)
Procedures
-4-
2. Program
/***********************************************************
File name: 01_blinkingLed.ino
Description: Lit LED, let LED blinks.
Website: www.adeept.com
E-mail: [email protected]
Author: Tom
Date: 2015/05/02
***********************************************************/
int ledPin=8; //definition digital 8 pins as pin to control the LED
void setup()
{
pinMode(ledPin,OUTPUT); //Set the digital 8 port mode, OUTPUT:
Output mode
}
void loop()
{
digitalWrite(ledPin,HIGH); //HIGH is set to about 5V PIN8
delay(1000); //Set the delay time, 1000 = 1S
digitalWrite(ledPin,LOW); //LOW is set to about 5V PIN8
delay(1000); //Set the delay time, 1000 = 1S
}
-5-
3. Compile the program and upload to Arduino UNO board
Now, you can see the LED is blinking.
-6-