Professional Documents
Culture Documents
uk
.
" " http://SimplyArduino.com :
abdallah.ali.abdallah.elmasry@gmail.com
....
....
....
..
www.networkset.net
www.aabouzaid.com
www.shabayek.com
linuxac.org
( )0202 MOVE-IT
www.moveitgate.com
) 0 ( ....................................................................................
) 6 ( ........................................................................
) 8( ....................................
:
:)00( ......................................................................
: )44( ..............................................................
: )70( ..........................................................
: )39( ..............................................
: )004( ....................................................
: )006( ...................................
: )067( ..............................................................
: )074( ........................................................
)082( ................................................Fablab Egypt :
: ( +
))084( ..........................................
Arduino IDE
Examples
,
.
PDF Foxit PDF
Tablet Ipad
Good Reader
7 .
, , ,....
Integrated Circuits
) (IC
Nano Meter
.
Integrated Circuits
Micro Controllers
, ,
,
.
...
10
Arduino
Open Hardware
Arduino C
Arduino IDE: Integrated Development
Environment
http://arduino.cc
Source Codes
Arduino Boards Arduino
IDE
Arduino C
Mikro C
.
11
Micro Controllers Development boards
0222
, processing " "C
.
MATLAB Java
MATLAB ,
Java VB.NET
12
MATLAB
.MATLAB
MATLAB
82
0222
13
Arduino Boards
Sensors
14
Arduino Uno
Arduino Uno
ATmega328
( 04 | )
)USB
Development Board
USB
.
15
Power up
USB
AC\DC
3 4
0.2
Gnd Vin .
02- 6,
7
Pin 5V
2 ,
00
voltage regulator
, 7 00.
16
Power Inputs/Outputs
: Vin
,
,
.
: V5
,
Vin
USB
2.
: V3.3 9.9
22 .
: GND .
17
Microprocessor
ATmega328
61 Kilo Byte 90
%6
%3
%2
SRAM - 2 Killobyte
Flash Disk - 29 Killobyte
EEPROM - 1 Killobyte
%89
: Boot loader
:SRAM .
: Flash Disk
Arduino C
,
.
o
: EEPROM
Hard Disk .
18
19
:
:
20
,
, : ,
21
:
: Hardware & Tools
22
Arduino UNO :
( :
, " "
)(Breadboard
,
Half Sized Breadboard
23
( )Colored Leds
, 02
: , , ,,
Resistors
:
)Resistor 560 Ohm (x5
Resistor 10 Killo-Ohm (x5
)AVO Meter (multi-meter device
( )
Wires
.
24
Cat5
.
,
breadboard
25
.
http://www.fut-electronics.com
http://egyrobots.com
http://www.ram-e-shop.com
RAM Electronics
" "
Future Electronics
.
( )
http://www.buyincoins.com
:
http://arduino.cc/hu/Main/Buy
26
Arduino Uno
27
Software's
28
)Arduino (IDE
Arduino IDE
Arduino C
.
Arduino C
29
Source
, Open
] [ :
Ubuntu
http://www.simplyubuntu.com/
30
Arduino IDE
Windows, Linux, MAC
:
http://arduino.cc/hu/Main/Software
, 7zip
arduino.exe
31
Ubuntu
Software center
fedora
Open SUSE
Hardware
32
Arduino IDE
:
USB
Found
4
33
34
:
:
:
:
:
Tools Board
Arduino Uno
35
( Vista
)Windows 7 :
: Device Manager
36
" "
37
"
" Ok
, COM3
( ) .
38
39
New
File
New
40
Examples File
41
:
:
42
43
44
: Example 1: Blinking led
45
(:)1
Arduino Uno
Breadboard
262
02
:
Breadboard
:
(
)100%
Breadboard 4
pin-header
46
Pin-Header
Breadboard
: Arduino IDE
47
48
:
Verify
IDE
"
" Upload
leds (
)Tx/Rx
,
.
,
.
49
......
;const int LED = 13
constant = 09 LED
) (Input/Output Pins ,
09 LED
09
LED
09
) ( Void setup
{
;)pinMode(LED,OUTPUT
}
pin 09
LED
50
3 :
:
: Digital Pins
Pin 0 00 09
Pin 2 6
) ( setup
Pin
( ) .capital
} setup ( ) {write your configurations here
pin
pin :
51
) ( void setup
{
:
);(
;)pinMode(11,OUTPUT
;)pinMode(12,OUTPUT
;)pinMode(13,OUTPUT
;)pinMode(2,INPUT
verify
:
.
) (void loop
LED
0222
;)digitalWrite(LED, HIGH
;)delay(1000
LED
;)digitalWrite(LED, LOW
;)delay(1000
0222
52
} , void loop ( ) {your program
;) digitalWrite(LED, HIGH
HIGH = 5 Volt LOW = 0
HIGH
2 LOW = .
;) delay (1000
.
:
;)digitalWrite(LED, HIGH
;)delay(1000
2 HIGH
LED 0222
millisecond
Nano-second Micro-Second
Low
0222 = .
53
comments
, Arduino IDE
.
" "// .....:
54
:
() Push button
push button
.
55
(:)2
Arduino uno
Breadboard
Push button
Led 10 mm
02
262
5v
, Digital input
2 HIGH
LOW
HIGH
Arduino IDE
56
// Example_2_Blinking_with_Switch
}
void loop()
{
val = digitalRead(buttonPin);
if (val == HIGH)
{
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}
else {digitalWrite(ledPin, LOW); } }
57
Verify
,
Upload
......
: ledPin Pin 13
buttonPin
;int ledPin = 13
;int buttunPin = 2
;int val = 0
val
pin 2
: pin 13
ledPin
()void setup
{
;)pinMode(ledPin, OUTPUT
;)pinMode(inPin, INPUT
}
,
pin 2
HIGH or LOW
58
:
;)val = digitalRead(buttunPin
pin 2
val
) ( digitalRead
2 = HIGH = LOW
) = if.else .. ( ,
if
:
HIGH 2
val
HIGH
.
59
: 2
Push Button ON
OFF
60
(:)3
Arduino uno
Breadboard
Led 5 mm
0 02
262
0
, 0
push button
.
:
breadboard 4
Pin-Headers
61
: Arduino IDE
62
//Example_3_On_Off_with_2_Switchs_1
pinMode(inputPin1, INPUT);
pinMode(inputPin2, INPUT);
}
void loop ( )
{
if (digitalRead(inputPin1) == HIGH)
{digitalWrite(ledPin, LOW); }
else if (digitalRead(inputPin2) == HIGH)
{digitalWrite(ledPin, HIGH); }
}
63
if else if
else . if
:
}If (you like science) {you should read books
}else if (you like sport) {you should play football
}else if (you like art) { you should take art lessons
}else { you should search for a hobby to do in your summer
9 :
0 ...
(^_^)
64
//Example_3_On_Off_with_2_Switchs_2
const int ledPin= 13;
const int inputPin1 = 2;
const int inputPin2 = 3;
void setup ) (
{
pinMode(ledPin, OUTPUT);
pinMode(inputPin1, INPUT);
pinMode(inputPin2, INPUT);
}
void loop ) (
{
if (digitalRead(inputPin1) == HIGH)
{
digitalWrite(ledPin, HIGH);
delay(400);
digitalWrite(ledPin, LOW);
delay(400);
}
else if (digitalRead(inputPin2) == HIGH(
{
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(100);
}
}
65
( void setup
{}
void loop
{}
const
pin
INPUT or OUTPUT
pin )HIGH (1
)or LOW(0
;)example: digitalWrite(13,HIGH
;)digitalRead (pin number
pin
( 2
;)example: digitalRead(4
9.8 HIGH
66
0.8
) LOW
:
;)delay (time
;)example1: delay(100
;)example2: delay(1000
( ... .. ).....
==
=!
=>
=<
>
<
67
;int led = 13
Integers
90768 90768
Float
character
long
0.047.489.648
( ) 2
;byte number= 44
byte
022
http://www.arduino.cc/en/Reference/VariableDeclaration
68
:
:
69
70
Analog Inputs/Outputs and Sensors
71
Analog Signals
( (sensor ,
:
Photo-
Resistor
AVO-meter ..
72
: , , , , , , ,
...
Atmega 328-p Arduino
Uno 6
( ) A0 A5
4.8
TMP36 LM35
()
.. 02 (
) 0.1 ....
73
: TMP36, TMP35, LM35
.
:
-0 0.0 2.2
-0
-9 GND
74
:
-0 0 AAA 0.2
-0 0 0
-9 AVO
Meter
-4 :
TMP 35, TMP36, LM 35
0 AAA 1.5
9
( )
( )
, AVO
75
AVO meter 0.76
(
97
)
:
76
:
Potentiometer
(
)analog input
77
(:)4
Arduino Uno
Breadboard
led 5mm
262
9
02
:
9
022
022 ,
9
A0
78
79
//Example_4_Variable_Resistor_sensor
;const int sensorPin = A0
;const int ledPin = 13
;int sensorValue
( ) void setup
{
;)pinMode(ledPin, OUTPUT
}
( ) void loop
{
;)sensorValue = analogRead(sensorPin
;)digitalWrite(ledPin, HIGH
;)delay(sensorValue
;)digitalWrite(ledPin, LOW
;)delay(sensorValue
}
) analogRead(pin number
4.8 2
0204
Analog to digital converting
80
A0 :
4.4 = 6
44 = 61
441 = 611
= 214.33
2 = 461.11
5 = 6124
sensorVlaue
;(sensorValue = analogRead(sensorPin
blinking led
.A0
( )
(
) ,
light sensor
81
: (
) Photo resistor as light sensor
,
82
(:)5
Arduino Uno
Breadboard
led 5mm
262
83
84
//Example_5_Light_Sensor_led
const int lightPin = A0;
const int ledPin = 9;
int lightLevel;
void setup ( )
{
pinMode(ledPin, OUTPUT);
}
void loop ( )
{
lightLevel = analogRead(lightPin);
lightLevel = map(lightLevel, 0, 900, 0, 255);
lightLevel = constrain(lightLevel, 0, 255);
analogWrite(ledPin, lightLevel);
}
,
85
analog Output
( )Pulse-Width modulation
(~) . 6 9.2.6.3.02.00 :
PWM
,
2
255:
255 = 5 volt
128 = 2.5 volt
0 =0 volt
, 9
4
2 ..
86
() .
( 3 )PWM
.
: PWM
87
) 00
PWM
:
// Example_6_fading_led_light
;const int ledPin = 11
;int i = 0
) (void setup
{
;)pinMode(ledPin, OUTPUT
}
)(void loop
{
)for (i = 0; i < 255; i++
{
;)analogWrite(ledPin, i
;)delay(10
}
)for (i = 255; i > 0; i--
{
;)analogWrite(ledPin, i
;)delay(10
}
}
..
88
) for (i =0; i < 10; i++
loop
counters
, :
( i
) analogWrite(ledPin,i
( ) i
89
255
( ) i ( ) i
()i
;) delay(10
= 02
;) delay(20 22 = 2
.
90
:
:
91
92
Computer interfacing with Arduino
93
)lilypad, mini
computer interface
USB
,
Liliypad
FTDI interface
FTDI chip
serial interface
94
95
(:)7
Arduino Uno
Breadboard
TMP 36 LM35
USB
96
Verify
97
// Example_7_Temprature_Sensor
const int sensorPin = A0;
int reading;
float voltage;
float temperatureC;
void setup( )
{ Serial.begin(9600); }
void loop ( )
{
reading = analogRead(sensorPin);
voltage = reading * 5.0/1024;
Serial.print(voltage);
Serial.println(" volts");
temperatureC = (voltage - 0.5) * 100 ;
Serial.println("Temperature is: ");
Serial.print(temperatureC);
Serial.println(" degrees C");
delay(1000);
}
98
Serial
Monitor :
99
Tx
...
,
022 )
: ( ) -
100
;) Serial.begin(9600
USB
.
voltage temperatureC
float int
0.1
float .
;) reading = analogRead(sensorPin
reading
sesnorPin
. A0
0204
;voltage = reading * 5/1024
101
;)Serial.print(voltage
Serial
Monitor ;)" Serial.println ("voltage
voltage
Serial.print
;)Serial.print(temperatureC
;)" Serial.println(" degrees C
;) delay(1000
.
102
, led .
61
103
// Example_8_Light_Sensor_2
const int photocellPin = A0;
int photocellReading;
void setup(void)
{ Serial.begin(9600); }
void loop(void)
{
photocellReading = analogRead(photocellPin);
Serial.print("Analog reading = ");
Serial.print(photocellReading);
104
Serial Monitor :
105
:
o
o
o
Dim
Dark
Light
Bright Light
106
107
(:)9
Arduino Uno
led 5mm
262
,
,
USB Serial Monitor
Arduino IDE
108
:
// Example_9_Computer_Interfacing
;int ledPin=13
;int value
)( void setup
{
;)Serial.begin(9600
;)pinMode(ledPin,OUTPUT
}
)( void loop
{
;)(value = Serial.read
};)if (value == '1') {digitalWrite(ledPin,HIGH
};)else if (value == '0') {digitalWrite(ledPin,LOW
}
serial
Monitor 1 Send
,
...
109
110
;) ( Serial.read
USB =value
,USB
value
if.. else if :
value == 1
value == 0
:
Serial communication
:
http://arduino.cc/en/Reference/serial
111
112
113
The Motors
114
:
, , ..
DC Motor Servo Motor
.
DC Motor
Servo Motor
115
: CD
116
(:)7
Arduino Uno
Breadboard
DC motor
2N2222 PN2222
1N4001
0.0
USB
9 3
117
118
//Example_10_DC_Motor
int motorPin = 9 ;
int onTime = 2500 ;
int offTime = 1000 ;
void setup ) (
{pinMode(motorPin, OUTPUT); }
void loop ) (
{
analogWrite(motorPin,100);
delay(onTime);
digitalWrite(motorPin, LOW);
delay(offTime);
analogWrite(motorPin,190);
delay(onTime);
digitalWrite(motorPin, LOW);
delay(offTime);
analogWrite(motorPin,255);
delay(onTime);
digitalWrite(motorPin, LOW);
delay(offTime);
}
119
120
(:)7
Arduino Uno
Breadboard
DC motor
2N2222 PN2222
1N4001
0.0
USB
9 3
121
( :
)examples servo sweep
122
//Example_11_Servo_Motor
#include <Servo.h>
Servo myservo;
int pos = 0;
void setup()
{
myservo.attach(9);
}
void loop()
{
for(pos = 0; pos < 180; pos += 1)
{
myservo.write(pos);
delay(15);
}
for(pos = 180; pos>=1; pos-=1)
{
myservo.write(pos);
delay(15);
}
}
123
:
:
124
125
Advanced Inputs/Outputs
126
(
) Input ( )output
,
:
Keypad
Led matrix
Relays
127
Graphical LCD
Character LCD
Character LCD
Graphical LCD
128
Character LCD
) :
16x2 ( )0
129
: Character
LCD 16x2
16x2 ( )
02
130
Pin Headers
:
http://www.aaroncake.net/electronics/solder.htm
131
2
:
pin headers
132
61
133
pin header
134
5v
GND
135
06
02
5 v
:
USB
:
:
136
()
137
0
0
138
,
.
2 RW
139
4
7
6
8
140
14
12
09.00.00
00.02.02
141
FileExamplesLiquidCrystalHelloWorld
:
;)LiquidCrystal lcd(12, 11, 5, 4, 3, 2
:
;)LiquidCrystal lcd(7, 8, 9, 10, 11, 12
142
//Example_12_LCD_16x2
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup()
{
lcd.begin(16, 2);
lcd.print("hello, world!");
}
void loop()
{
lcd.setCursor(0, 1);
lcd.print(millis()/1000);
}
143
(^_^)
144
Character LCD
145
20x4
146
:
LCD
http://arduino.cc/en/Tutorial/LiquidCrystal
character LCD
http://www.instructables.com/id/Controlling-a-character-LCD-with-an-Arduino
http://www.instructables.com/id/How-To-Use-a-Nokia-Color-LCD/
147
Keypad
...
(*) ( )#
4x4
4x4
148
3x4
( 0 )
3x4 :
Weight: 7.5 grams
)"Keypad dimensions: 70mm x 77mm x 1mm (2.75" x 3" x 0.035
Length of cable + connector: 85mm
7-pin 0.1" pitch connector
149
() 3x4
7 ) Pin-Headers (7
Arduino Uno
Breadboard
150
0 8
# 0
.
Character LCD
Arduino IDE
: :
http://www.arduino.cc/playground/Code/Keypad
151
Arduino IDE
, keypad.zip
keypad Arduino IDE
libraries keypad :
152
1
2
153
:
//Example_13_Keypad_Input
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 3;
char keys[ROWS][COLS] =
{
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'#','0','*'}
};
byte rowPins[ROWS] = {5, 4, 3, 2};
byte colPins[COLS] = {8, 7, 6};
154
:
http://www.arduino.cc/playground/Code/Keypad
http://www.instructables.com/id/Access-control-with-Arduino-Keypad4x4-Servo
9 7:
http://www.instructables.com/id/Arduino-3-wire-Matrix-Keypad
( )
( ):
http://www.instructables.com/id/Password-Lock-with-Arduino
155
Relay
156
/ , ,
:
:
, :
/
.
157
158
,
,
.
, ,
.
110
220 . ,
5 ,
, 5
.
.
, ,
159
. , ,
:
, , :
- -
(
.
.
160
:
5 5
,
.
:
,
.
,
5 %01
2 ( 3 00)
2N2222
161
162
Relay Boards
:
163
002
.
:
002
http://www.sparkfun.com/tutorials/119
: relay
http://muslimlead.com/?p=2121
164
:
:
165
166
Arduino Shields
167
Arduino uno
Arduino Mega
PCI
,
Motherboard
network interface
card
..
( Ethernet
)
,
:
168
CAT5
,
169
Xbee Shield
170
Stepper Motors 9
( :
Robots CNC
171
lcd
,
0
4 (
0.2
http://shieldlist.org
172
:
:
173
AVR ARM Cortex FPGA
174
0222 Ivrea
, Microcontrollers
.. Arduino
"
" Massimo Banzi "
David
Cuartielles
" Gianluca Martino
Arduin of
Ivrea
022
Integrated Development
Environment
Development Boards
.
175
Wiring Platform
Hardware Design
Wiring
Processing Arduino C
C++ .
0222
ATmega168
AVR
Atmel
,
Arduino Serial V.1
arduino.cc
Source Codes
Arduino Boards Arduino IDE
.
176
:
Arduino UNO , Arduino Mega, Arduino lilyPad, Arduino
Duemilanove, Arduino Fio
AVR Atmel
922.222 .
2112
LeafLabs
The Maple
board ARM
Cortex
ARM
70
0.2 .
LeafLab AVR
ARM Cortex
Maple Board 94 .
177
ARM Cortex "
" ) Field-Programmable Gate Arrays (FPGA 0202
Papilio Arduino
FPGA Arduino C
FPGA
Decoding
,
: 022 ,
:
VHDL . Verilog
Papilio Arduino
Papilio
Arduino IDE
178
Arduino IDE
FPGA papilio boards
0202 42
papilio
http://papilio.cc
Papilio Arduino
.. ....
179
:
( )
:
3D printer
CNC machine
....
180
Arduino workshops
Young Fab.Academy
00 8
http://fablab-egypt.com
https://www.facebook.com/fablab.egypt
181
182
183
http://www.instructables.com/id/Arduino-Projects
http://www.oomlout.com
http://ladyada.net
http://bildr.org
http://hlt.media.mit.edu/?cat=5
http://circuit-projects.com/microcontroller
http://www.eeweb.com
http://www.lvl1.org
http://www.coolcircuit.com
http://www.instructables.com/id/Breadboard-How-To
http://blog.makezine.com/2009/12/11/arduinoshields-open-source-hardwar/
184
MATLAB
http://www.mathworks.com/academia/arduin
o-software/arduino-matlab.html
http://arduino.cc/playground/Interfacing/Matlab
http://fritzing.org/projects/
http://www.instructables.com/id/Arduino-Projects
http://www.ladyada.net/make/boarduino/index.html
http://www.ladyada.net/make/mshield/index.html
http://www.shapeoko.com/wiki/index.php/About
http://www.ladyada.net/make/monochron/index.html
http://www.ladyada.net/make/bedazzler/index.html
http://www.ladyada.net/make/mintyboost/index.html
http://dangerousprototypes.com/forum/viewtopic.php?f=56
&t=2892#p28410
http://www.ladyada.net/make/logshield/
http://www.wayneandlayne.com/projects/video-game-shield/
http://excamera.com/sphinx/gameduino/
http://dangerousprototypes.com/2012/03/24/arduino-voicecontrol-with-easyvr-shield/
http://blog.minibloq.org/p/documentation.html
http://www.doctormonk.com/2011/09/arduino-solar-radio.html
http://j4mie.org/blog/how-to-make-a-physical-gmail-notifier/
http://blog.tinyenormous.com/2008/11/25/gmail-notifierproject-for-dummies/
http://reprap.org/wiki/Arduino_Mega_Pololu_Shield
185
186