Beruflich Dokumente
Kultur Dokumente
1 pc RGB LED
Basic Arduino Manual
1 pc Potentiometer
30 pcs Resistors
1 pc Photoresistor
1 pc LCD
1 pc 4-Digit 7-Segment
Display
1 pc Buzzer
1
Potentiometer
A simple knob that provides a variable resistance.
Buzzer
An electric component that comes in different shapes and sizes, which can
be used to create sound waves after providing electrical signal.
Basic Arduino Manual
What is Arduino?
Arduino by definition is an open-source prototyping platform based on easy-to-use hardware
and software. Arduino boards are able to read
inputs - light on a sensor, a finger on a button and turn it into an output - activating a motor,
turning on an LED.
You can tell your board what to do by sending
a set of instructions to the microcontroller on the
board. To do so you use the Arduino programming language (based on Wiring), and the Arduino Software (IDE), based on Processing.
Its applications range from simple LED projects
to products for IoT applications, wearable, and
3D printing. All Arduino boards are completely
open-source, empowering users to build them
independently and eventually adapt them to
their particular needs. The software, too, is opensource, and it is growing through the contributions of users worldwide.
www.arduino.cc
Hardware
There are a couple of parts on the board:
Power
The Uno board can be powered via the USB connection or with an external power supply.
5V.This pin outputs a regulated 5V from the regulator on the board.
GND. Ground pins.
Input and Output
The Uno has 6 analog inputs, labeled A0 through A5.
Each of the 14 digital pins, labeled 0 through 13 on the Uno can be used as an input or
output, using pinMode(), digitalWrite(), and digialRead() functions.
In addition, some pins have specialized functions:
PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.
LED: 13. There is a built-in LED driven by digital pin 13. When the pin is HIGH value, the LED
is on, when the pin is LOW, its off.
Reset. Bring this line LOW to reset the microcontroller.
Software
The Arduino Integrated Development Environment - or Arduino Software (IDE) - contains a text editor for writing code, a message area, a text console, a toolbar with
buttons for common functions and a series
of menus.
It connects to the Arduino and Genuino
hardware to upload programs and communicate with them.
Writing Sketches
Programs written using Arduino Software
(IDE) are called sketches. These sketches are
written in the text editor and are saved with
the file extension .ino.
The toolbar buttons allow you to verify and
upload programs, create, open, and save
sketches, and open the serial monitor.
Verify
Checks your code for errors compiling it.
Upload
Compiles your code and uploads it to the configured board.
New
Creates a new sketch.
Open
Presents a menu of all the sketches in your sketchbook. Clicking
one will open it within the current window overwriting its content.
Save
Saves your sketch.
Serial Monitor
Opens the serial monitor.
Additional commands are found within the five menus: File, Edit, Sketch, Tools, Help.
Basic Arduino Manual
3. A well lighted table or any workspace where you will be placing your
components next to your desktop or laptop PC to enable you to upload
the code to the Arduino.
4. A notepad and pen will also come in handy for drawing out rough schematics, working out concepts and designs, etc.
5. And most importantly, the enthusiasm and willingness to learn!
Instructions:
1. Connect the arduino to the computer using the USB cable
2. Open the file lesson_no._1_built_in_LED_blink.ino
3. The Arduino IDE will open
4. Click Upload
10
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000);
// wait for a second
11
Materials:
1pc LED
1pc 220ohm resistor
Breadboard
Jumper wires
Instructions:
1. Connect the arduino to the computer
2. Open the file lesson_no._2_LED_blink.ino
3. The Arduino IDE will open
4. Click Upload
5. Construct the circuit as shown in the figure. You can check
the larger version of the picture which is located in the folder
lesson_no._2_LED_blink
12
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000);
// wait for a second
13
Materials:
1pc LED
1pc 220ohm resistor
1pc 10kohm resistor
1 pc tact switch
Breadboard
Jumper wires
Instructions:
1. Connect the arduino to the computer
2. Open the file lesson_no._3_LED_control.ino
3. The Arduino IDE will open
4. Click Upload
5. Construct the circuit as shown in the figure. You can check
the larger version of the picture which is located in the folder
lesson_no._3_LED_control
14
pinMode(ledpin,OUTPUT); //define the ledpin as OUTPUT, we will be connecting the LED here
pinMode(inpin,INPUT);
//define the inpin as INPUT, we will be connecting the switch here
/* pinMode: This command, which goes in the setup() function, is used to set the direction of a
digital I/O pin.
Set the pin to OUTPUT if the pin is driving and LED, motor or other device.
Set the pin to INPUT if the pin is reading a switch or other sensor.
On power up or reset, all pins default to inputs. */
}
void loop()
{
val=digitalRead(inpin); //read the value of inpin then save it to variable val
/* digitalRead: Reads the value from a specified pin, it will be either HIGH or LOW.*/
if(val==LOW) //if the button pressed;
/*If the condition is true, the program will execute the commands between the braces. If the
condition is not true, the program will skip to the statement following the braces.*/
{ digitalWrite(ledpin,LOW);} //turn off the LED
else
{ digitalWrite(ledpin,HIGH);} //if not pressed, turn on the LED
/*digitalWrite: This command sets an I/O pin high (+5V) or low (0V) and is
the workhorse for commanding the outside world of lights, motors,
and anything else interfaced to your board.*/
15
Materials:
3 pcs LED
(1 green, 1 yellow, 1 red)
3pcs 220ohm resistor
Breadboard
Jumper wires
Instructions:
1. Connect the arduino to the computer
2. Open the file lesson_no._4_3_LED_blink.ino
3. The Arduino IDE will open
4. Click Upload
5. Construct the circuit as shown in the figure. You can
check the larger version of the picture which is located in
the folder lesson_no._4_3_LED_blink
16
17
Materials:
3 pcs LED
(1 green, 1 yellow, 1 red)
3pcs 220ohm resistor
Breadboard
Jumper wires
Instructions:
1. Connect the arduino to the computer
2. Open the file lesson_no._5_traffic_lights.ino
3. The Arduino IDE will open
4. Click Upload
5. The circuit will be the same as in lesson_no._4_3_LED_blink
18
19
Materials:
10pcs LED
(3 green, 4 yellow, 3 red) ,
10pcs 220ohm resistor,
Potentiometer
Breadboard
Jumper wires
Instructions:
1. Connect the arduino to the computer
2. Open the file lesson_no._6_LED_bar_graph.ino
3. The Arduino IDE will open
4. Click Upload
5. Construct the circuit as shown in the figure. You can check
the larger version of the picture which is located in the folder
lesson_no._6_LED_bar_graph
20
The circuit:
* LEDs from pins 2 through 11 to ground
created 4 Sep 2010
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/BarGraph
*/
// these constants wont change:
const int analogPin = A0; // the pin that the potentiometer is attached to
const int ledCount = 10; // the number of LEDs in the
bar graph
int ledPins[] = {
2, 3, 4, 5, 6, 7, 8, 9, 10, 11
}; // an array of pin numbers to which LEDs are attached
void setup() {
// loop over the pin array and set them all to output:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
}
}
void loop() {
// read the potentiometer:
int sensorReading = analogRead(analogPin);
// map the result to a range from 0 to the number of
LEDs:
int ledLevel = map(sensorReading, 0, 1023, 0, ledCount);
21
Materials:
1pc RGB LED
3pcs 220ohm resistor
Breadboard
Jumper wires
Instructions:
1. Connect the arduino to the computer
2. Open the file lesson_no._7_RGB_LED
3. The Arduino IDE will open
4. Click Upload
5. Construct the circuit as shown in the figure. You can check
the larger version of the picture which is located in the folder
lesson_no._7_RGB_LED
22
void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop()
{
setColor(255, 0, 0); // red
delay(1000);
setColor(0, 255, 0); // green
delay(1000);
setColor(0, 0, 255); // blue
delay(1000);
setColor(255, 255, 0); // yellow
delay(1000);
setColor(80, 0, 80); // purple
delay(1000);
setColor(0, 255, 255); // aqua
delay(1000);
}
23
Materials:
1pc RGB LED
3pcs 220ohm resistor
3pcs 10kohm resistor
3pcs tact switch
Breadboard
Jumper wires
Instructions:
1. Connect the arduino to the computer
2. Open the file lesson_no._8_RGB_switch.ino
3. The Arduino IDE will open
3. Click Upload
4. Construct the circuit as shown in the figure. You can check
the larger version of the picture which is located in the folder
esson_no._8_RGB_switch
24
delay(10);
25
Lesson 9: Photoresistor
Overview:
In this lesson we will be using the
component called the photoresistor. It acts like an automatic
switch where in whenever it detects presence of light it will turn
the LED off, otherwise if detects
the absence of light it will turn the
LED on.
Materials:
1pc LDR
1pc LED
1pc 220ohm resistor
1pc 10kohm resistor
Breadboard
Jumper wires
Instructions:
1. Connect the arduino to the computer
2. Open the file lesson_no._9_photoresistor.ino
3. The Arduino IDE will open
4. Click Upload
5. Construct the circuit as shown in the figure. You can check
the larger version of the picture which is located in the folder
lesson_no._9_photoresistor
26
delay(1000);
27
Instructions:
1. Connect the arduino to the computer
2. Open the file lesson_no._10_buzzer.ino
3. The Arduino IDE will open
3. Click Upload
4. Construct the circuit as shown in the figure. You can check
the larger version of the picture which is located in the folder
lesson_no._10_buzzer
5. This time upload lesson_no._10_buzzer_super_mario.ino
your buzzer will play on the tune of super mario
Basic Arduino Manual
28
29
Materials:
4-digit 7 segment display
8pcs 220ohm resistor
Breadboard
Jumper wires
Instructions:
1. Connect the arduino to the computer
2. Open the file lesson_no._11_7segment.ino
3. The Ardiuno IDE will open
4. Click Upload
5. Construct the circuit as shown in the figure. You can check
the larger version of the picture which is located in the folder
lesson_no._11_7segment
30
Materials:
LCD
Potentiometer
Breadboard
Jumper wires
Instructions:
1. Connect the arduino to the computer
2. Open the file lesson_no._12_LCD_hello_world.ino
3. The Arduino IDE will open
4. Click Upload
5. Construct the circuit as shown in the figure. You can check
the larger version of the picture which is located in the folder
lesson_no._12_LCD_hello_world
31
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting
begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis() / 1000);
}
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal
*/
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the
interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of columns and
rows:
lcd.begin(16, 2);
32