Professional Documents
Culture Documents
ابني روبوتك ببساطة PDF
ابني روبوتك ببساطة PDF
1
ف ل ا
هرس
2
إلى أمى وأبى
إلى أهلى وعشي برى
إلى أساتذبى
إلى زملابى وزميلابى
ي خ ل ض تل حي ت ت لا مشإل ال
ى وع ى رق ى لا رن
لع
إلى كل من متى خرفا
أهذي هذأ البحث إلمتوأضع زأجياً من إلموىل
ج بلا ت ق لا
عر وجل أن ذ ول و اح
ح ت
3
4
5
–
6
I dQ
dt
t Q
I Qt
I V R
R A L
ρ
R L
A
7
ρ
σ
V I L
A
I 1 V
A L
J E
J
E
R, R , R
8
I
R v, v , v
Vv v v
1 2 3
IR IR IR IR
1 3
R R R R Ri
1 2 3 i
9
I I I I
1 2 3
v v v v
R R R R
1 2 3
1 1 1 1 1
R R R R i Ri
1 2
R R
R 1 2
R R
1 2
R R
R 25 R
R R 1 2
R R
R R
1 2 6 R R 6
1 2
25 1 2
11
(25 R ) R 150
2 2
R 2 25 R 150 0
2 2
(R 10)(R 15) 0
2 2
R or Ω
R or Ω
R Ω , R Ω
A, B
11
I
n
r
R
nE
R nr
I nE
R nr
I nnEr E
r
12
I n E
R
E
R r n r n
I E
R r /n
13
I ER
I n E r
n
m
r
14
E
nr
nr m
R nr m
nE
nE nm E NE
I
R (nr / m) m R n r m R n r
N nm
mR n r
N mn , mR n r
15
Q V
C
Q CV
C, C ,
V C
Q Q Q
V
C C C
1 2 3
V Q 1 1
1
C C
C
1 3
2
V1 1 1 1 1
Q C C C C
1 2 3 i Ci
16
C C
C 1 2
C C
1 2
Q C V C V C V
1 2 3
Q
C C C
V 1 2 3
C C C C Ci
1 2 3 i
17
L, L , L
V
V L I L I L I
1 2 3
V L L L
I 1 2 3
LL L L
1 2 3
I I I I
1 2 3
V V V V
L L L L
1 2 3
1 1 1 1 1
L L L L L
1 2 3 i i
18
I I I I I 0
1 2 3 4 5
I I I I I
1 4 2 3 5
19
IR
IR
I R I R I R I R E E 0
1 1 2 2 3 3 4 4 1 2
I R I R I R I R E E
1 1 2 2 3 3 4 4 2 1
21
BE
F ABEFA
– I– I–I
I– I
CDEBC
I–I – I
I– I
21
I A , I A
I
I BE
I I–I – A
VBE x V
P EI I R W
P
P P
P x W
P x W
P W
x x x W P
Δ Y تحويالت
Δ
Y
Δ Y
22
, Δ R , R , R
a ,
b Y
b a
, a
R R
, , R
R R R
12 23 31
R R R
12 23 31
, b
R R
23
R R R
12 23 31
R R R R R
12 23 31 1 2
,
R R R
R R 23 31 12
2 3 R R R
12 23 31
R R R
R R 31 12 23
1 3 R R R
12 23 31
R R
R 12 31
1 R R R
12 23 31
R R
R 31 23
3 R R R
12 23 31
R
R R
R 23 12
2 R R R
12 23 31
Y Δ
, ,
24
R R
R R R 1 2 R
12 1 2 3
R R
R R R 2 3 R
23 2 3 1
R R
R R R 1 3
31 1 3 R
2
Y Δ r, r, r
Δ Y
R rx r r r
R rx r r r
25
R rx r r r
A, B
Δ , ,
Y
26
R x
R x
R x
27
,
,
Ω A, B
I VR Amp
28
E, F
Y Δ ABC
29
Δ Y , ,
31
Δ
31
E, F
E, F R
R x Ω
32
VC VR E
VC VR E
VR I R , VC Q C
C Q I
E I R Q C
dQ
R dI 1 0
dt C dt
dQ dt I
R dI I
dt C
dI 1 dt
I RC
33
ln ( I ) t K
RC
t=0 I = I0
ln I K
ln ( I ) t ln ( I )
RC 0
I
ln t
I RC
0
t
I I e RC
0
t
V I RI e RC
R 0
t
V E e RC
R
34
VC E– I R
t
V EI R e RC
C 0
t
V E 1 e RC
C
t
ER I
35
RC
A n t
H ω
E μ HA n ω si n ωt
t E
μ HA n ω μ HA n ω E
μ HA n ω
E μ HA n ω
ω t θ
θ t ω
F τ
36
2 2 F
E E si n ω t
si n
E
A
π
Phase and phase di f f erence
37
E E si n ω t φ
A A si n ω t
B B si n ω t φ
A B
φ B A φ
38
B
A
I I m si n ω t I m si n θ
39
2
2 2
I m sin d
I2 0
2
I 2 2
I 2 m sin 2 d
2 0
I 2 2
I 2 m 1 1 cos 2 d
2 0 2
2
1/ 2
I
I m
2
I
I r.m.s. m 0.707 I m
2
E
Er.m.s. m
2
I av
41
I I m sin
I d
I
I av 0 m sin d
0
I
I av m ( cos ) 0
I
m cos cos 0
2I
I av m
41
E Em si n ωt
R
E sin t
I m
R
I I m sin t
Im Em R
42
P EI
P Em I m sin 2 t
P 1 Em I m 1 cos 2 t
2
P 1 Em I m 1 Em I m cos 2 t
2 2
Em I m
43
1 E I cos 2 t
2 m m
1 E I cos 2 t
2 m m
E I
P m m
2 2
44
P Erms I rms
I m 2 I rms 0.707 A
R P 240
2
I rms
E L dI
dt
45
E Em sin t
E
dI m sin t dt
L
I m cos t m sin t / 2
E E
L L
π
Em
si n L
E
Im m
L
ωL
P Em I m sin ( t ) cos( t )
P 1 Em I m sin (2 t )
2
1
E I
2 m m
46
C
47
q CE
E Em sin t
q C Em sin t
dq
I
dt
I d C Em sin t
dt
Em
I C Em cos t cos t
1
C
I I m sin ( t / 2 )
Em
Im
1
C
48
1
C
π o
P 1 Em I m sin 2 t
2
1
E I
2 m m
49
L R
I I m si n ω t
V VR VL
V RI L d I
dt
V R I m sin t L cos t
V A sin ( t )
51
θ A
θ A
R I m A sin , L I m A cos
tan 1 ( R ) tan R
L L
cos L
R 2 ( L) 2
51
A I m R 2 ( L) 2
θ A
θ
R 2 L2
I I m si n ω t
V VR VC
V I R 1 I dt
C
52
V R I m sin t 1 cos t
C
V A sin ( t )
Im
R I m A cos , A sin
C
53
cos R
R2 1
( C ) 2
A Im R2 1
( C ) 2
θ A
1
C
V Im R2 1 sin t tan 1
( C ) 2 R
θ
R2 1
( C ) 2
R ωC
R ωC
L R
C
54
I I m si n ω t
V VR VL VC
V I R R I m sin t
R
V L d I L cos t
L dt
V 1 I dt 1 I m ( cos t )
C C C
V R I m sin t L 1 I m cos t
C
V A sin ( t )
55
V A sin t cos A cos t sin
A cos R I m , A sin I m ( L 1/ C)
( L 1/ C ) tan ( L 1/ C )
tan 1
R R
R 2 ( L 1/ c) 2
56
cos R
R 2 ( L 1/ c) 2
A Im R 2 ( L 1/ c) 2
θ A
R 2 ( L 1/ c) 2
ωL ωC
ω L ωC
ωL ωC
1
θ LC
diode
57
n p t ype
t ype
Di ode
semi conduct or
n t ype p t ype
f orward bi ased
reverse bi ased
, Si
58
AC
DC
rect i f i cat i on
Bl ock
59
Bri dge
61
61
Swi t ch Ampl i f i er
Hol es
Base
Col l ect or
Emi t t er
P
NPN n
62
p n
oo
BJ T
NPN
n PNP
p
BJ T
63
NPN Emt t er Base
64
barri er
IE Ib
Ic
IE Ib Ic
Ic B Ib
hf e B
65
Common Emi t t er
VBE VBB
RB
Ic B Ib
VBB Vcc
BJ T
66
VC
IB
IC
IE
RB
RL
VS
VC
VL
Vc
67
Vs
RL
Vs
ON T R T
Ic
V OFF T
68
NPN
NPN PNP
NPN , PNP
69
Col l ect or
Emi t t er
Base
71
h e
NPN
,
71
NPN
NPN
PNP
BC BC BCX
72
,
73
74
bi pol ar
uni pol ar
FET
TTL
DI GI TAL
DC AC Load Li ne •
Bi asi ng Ci rcui t s •
75
•
FET
B
E émet t eur C col l ect eur , base ,
BC
76
C&E
fig
C et E,
fig
IC B et E IB
ß ß IB
77
MOSFET
Met al Oxi deSemi conduct orFi el dEf f ect Transi st or
78
N
P
Hol es
N P
P N
Depl et i on Area
79
Barri erVol t age
N P
81
P N
81
MOSFET
N Subst rat e
P
P N
Source Drai n
SI O
Gat e
N P Cahnnel
Channel
MOS
82
MOSFET
Gat e
83
P
84
CMOS MOSFET
P LOW
P MOS FET
N Hi gh
N MOS FET
85
BJ T MOSFET
STR
MosFet
86
87
Mi crocont rol l er
C or Assembl y or Basi c
Programmer
… processor
Mi crochi p
PI C F PI C F Mi crochi p
PI C F A PI C F
Mi crocont rol l er
Mi croprocessor
Osci l l at or
RAM
ROM
Count ers
Ti mers
ADC
88
Mi croprocessor
Osci l l at or
pul ses
mi croprocessor
RAM
dat a
Vari abl es
ROM
dat a
ADC
Di gi t al Anal og
PI C f A
89
PI C f a
pi ns
Dat asheet
RA
RA
pi ns pi n PI C f a
Pi ns vol t
i nput s
processor
pi ns
pi ns
PORT A out put &i nput
pi ns PORT A PORT B
RB , RB , pi ns PORT B RA , RA , RA , RA , RA
RB , RB , RB , RB , RB , RB , RB
91
IC
VDD pi n
pi n no
Reset
MCLR pi n
rest art
91
Osci l l at or
processor
Osci l l at or
pi n no , OSC , OSC cryst al MH
92
Reset MCLR
Pi n push but t on
reset pi n
pi n
pi n
noi se
TRI S
pi ns di rect i ons regi st er TRI S
i nput pi ns
Pi ns out put
out put i nput s
l ed
out put l ed pi n
93
or pi n number port name regi st er name ;
port TRI S regi st er TRI SB b
l ed TRI SB port B l ed
port B pi n
out put B port Pi n
port A pi n
i nput
;TRI SA b di rect i on
swi t ch port TRI S regi st er
pi n swi t ch TRI SA port A
Pi n port A
i nput A port
out put pi n di rect i ons
i nput
94
Mi kroC V
C
mikro C
95
96
97
C
98
Preprocessor dat a
t ext repl acement
compi l at i on
#def i ne on
#def i ne of f
#def i ne l ed t ri sb b
on compi l er
ex Led on
Led
99
ex i nt x ; decl are a vari abl e x As I nt eger and assi gn
t o i t s val ue
not e
a every l i ne i n t he C code must be cl osed by ;
b i n t he C l anguage t here i s no t ype t o st ore st ri ng di rect l y
so we use array of charact er t o st ore st ri ngs
ex
i nt Add i nt x, i nt y ;
i mpl ement at i on
f unct i on
ret urn t ype f unct i on name vari abl es t hat t he f unct i on
recei ve
111
ex
i nt Add i nt x, i nt y
i nt z ;
z x y;
ret urn z ;
cal l i ng
f unct i on
Vari abl e name f unct i on name t he vari abl e t hat i want t o
send t o t he i mpl ement at i on
ex
voi d mai n
111
i nt z ; def i ne a vari abl e z As i nt eger
z x y;
ret urn z ; ret urn t he val ue of z and put i t i n resul t vari abl e
Voi d mai n
f unct i ons
preprocessor dat a
conf i gurat i on
if condi t i on
el se i f condi t i on
el se
if condi t i on &&condi t i on
112
wri t e t he code t hat you desi re t o execut e i f t he condi t i on and
condi t i on i s t rue
if condi t i on condi t i on
b l oops
I need t o l oop when i want t o repeat some of code f or n t i mes
For Loop
voi d mai n
i nt i ; def i ne vari abl e i As i nt eger
pri nt t he val ue of i i t wi l l be ……
113
c Swi t ch case
swi t ch vari abl e
case
wri t e t hat code you want t o execut e i f t he vari abl e mat chi ng
wi t h t he f i rst case
break ;
case
wri t e t hat code you want t o execut e i f t he vari abl e mat chi ng
wi t h t he f i rst case
break ;
def aul t
wri t e t hat code you want t o execut e i f t he vari abl e doesn’t
mat ch wi t h any of t he cases
break ;
114
I nt roduct i on To Mi crocont rol l er
si mul at i on
Prot eus
Prot eus
115
mi crocont rol l er
116
Led, But t on, Bat t ery,
Vol t met er, Resi st or, Ammet er
117
118
119
111
111
prot eus
112
113
Arduino
Arduino 1
Arduino
Desktop
Micro- Platform
Controller
IDE
Arduino
Sensors Switches
LED Motors
Arduino
Arduino 2
Micro-
Basic Stamp Parallax Controllers
114
Raspberry Pi Netmedia’s BX-24 Phidgets
Software
Arduino
Arduino
Arduino
05 Arduino
Datasheet Self-Assembly
Arduino
,windows
Linux Mac OS
Programming
Environment
C Open Source Software
Raspberry Pi Arduino 3
Raspberry Pi
Raspberry Pi Arduino
115
Arduino
USB Cable
Raspberry Pi
SD card USB Cable
HDMI
WiFi Dongle Ethernet Cable
Raspberry Pi
WiFi Ethernet
Arduino USB Dongle
Ethernet shield
WiFi Arduino
GSM Arduino
Processor
Arduino
Raspberry Pi Mhz61 ATMEG168
Arduino Due Mhz077 BCM2835
Mhz48 SAM3X8E Raspberry Pi
Raspberry Pi
Arduino IDE
Arduino
SSH ,Raspberry Pi
Python
116
Raspberry Pi Arduino
8
Arduino Hardware Schema
Creative commons
Arduino
GPL
5
,
Arduino
Twitter Facebook
Arduino
Arduino 6
Arduino Environment
Arduino
Starter-kit 0
117
Arduino Integrated Development Environment 4
Arduino Compiler
Arduino 9
118
Arduino Matlab C Java
Python Environment
17
57 4 Arduino
Arduino Datasheet
Arduino
Arduino 11
Arduino Boards 87
Arduino Uno
Shields Extensions
Arduino Nano
119
Arduino Uno Arduino Uno
Arduino Lilypad
121
Arduino
Arduino Input/Output
Arduino Shields 12
Arduino
WiFi Arduino I/O
Arduino Shields
Arduino Shields
Arduino Arduino Shields
Extensions 13
LED Motors LCD
Resistance
Arduino 18
Arduino 15
Arduino
Arduino 16
121
Creative commons Arduino
Arduino
Flutter
WiFi Arduino
Kickstarter
Pixy TinyDuino
Arduino
Arduino Ubuntu 12.04
Ubuntu Packages
IDEs 14
Arduino Compile
AVRStudio Makefiles
Arduino Library
Arduino Library 19
Codes
Arduino
Hardware
Arduino 27
122
LabVIEW
LabVIEW
VirtualInstruments 1
Front Panel 2
Block Diagram 3
Tools Palette 8
Controls Palette 5
Function Palette 6
Virtual Instruments
VirtualInstruments (VIs LabVIEW
vi
VIs
123
The Icon and The Block Diagram The Front Panel
Connectors Pane
124
Controls
125
Indicators
leds graphs VI
126
Block Controls
Block Diagram Diagram
Indicators
127
Front Panel Indicator Control
The Block Diagram terminal
128
SubVIs terminals The Block Diagram
Wires Structures Functions
Icon VI
Icon
129
VI VI VI Icon
SubVI
Connectors Pane
131
SubVI
BlockDiagram
SubVI
VI LabVIEW
VI SubVI
VI SubVI
131
Front Panel
VI
LabVIEW
Block Diagram
132
BlockDiagram
Highlight
Step Into
loops subVI
Step Over
Loop SubVI
Tools Palette
133
ToolsPalette
LabVIEW
VI
Labeling Tool
ScrollingTool
Breakpoint
Coloring Tool
Controls palette
Front Panel
135
136
ALLCONTROLS
Front Panel
137
AllControls
Functions Palette
Block Diagram
138
FunctionsPalette
139
Block
Diagram
AllFunctions
141
141
142
143
144
145
146
147
VI
VI
Tools Pallette
Tools Palette
Show Tools Palette Window
LabVIEW Automatic
Tools Manual
Palette
148
VI
The FrontPanel
Indicators Controls
Numeric Control
149
Label Numeric Control
Numeric Control
NumericIndicator
151
Numeric Indicator
Block Diagram
Numeric Control
Operating Tool
Operating Tool
ENTER
Control ToolBar
151
Boolean Controls and Indicators 2
False True
LEDs Push Buttons Switches
Controls Indicators
Control Indicator
152
The Block Diagram
153
Nodes
BlockDiagram Object
LaBVIEW
Functions Palette
154
SubVI
155
VI Block Diagram VI
Subroutine
Structures
Terminals
Data Type
Node Terminals
Node Terminals
157
Node Connector pane
Node
Wires
Data Type
159
Dataflow Programming
Dataflow LabVIEW
Node
Node Node
Control Flow
57
161
Y X
57
Z
161
162
1672
163
,
, 3
, ,
, 16 LCD1602
Hitachi HD44780 driver
Data bus 8 bit
164
...
RS
,
, R/W
enable pin
,
.
LCD RS ……..D12
LCD D4 ……D5
LCD D5……D4
165
LCD D6……D3
LCD D7……D2
16 15
.
166
.
,
LiquidCrystal
: ,
167
void setup
Hello world
#include <LiquidCrystal.h>
void setup() {
lcd.begin(16, 2);
lcd.print("hello, world!");
void loop(){}
A0 ,
.
#include <LiquidCrystal.h>
int t=300;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int y =1;
168
void setup()
{
lcd.begin(16, 2);
lcd.cursor();
lcd.autoscroll();
}
char Phone[]={"0786739233"};
void loop(){
timing_delay();
lcd.setCursor(15, 0);
for (int i=0;i<20;i++){
lcd.print(Name[i]);
timing_delay();
delay(t);
}
lcd.clear();
lcd.setCursor(15, 0);
for (int i=0;i<21;i++){
lcd.print(Email[i]);
timing_delay();
delay(t);
}
lcd.clear();
lcd.setCursor(15, 0);
for (int i=0;i<11;i++){
lcd.print(Phone[i]);
timing_delay();
delay(t);
}
delay(2000);
lcd.clear();
}
169
171
53 543
, ,
171
172
#include "Ultrasonic"
}
Voidloop ()
{
Serial.print(ultrasonic.Ranging(CM));
Serial.println("cm");
delay(100);
}
173
Ul t rasoni c ul t rasoni c Tri gger pi n, Echo pi n ;
ul t rasoni c Rangi ng CM ;
174
Shaf t Gear
,
175
,
Pul ses
176
Servo Li brary
,
,
177
Vcc
Gnd
Dat a
178
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
for(pos = 0; pos <= 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=0; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
Anal oge A A
PWM
D,D,D,D,D,D
UNO ATMEGA
#include<lib.h>
#include <Servo.h>
Servo Name;
179
Name
, pi n
Name.attach(Pin Number);
Name
Pin number
,
Name.write(val)
Name
– val
Anal oge A A
D,D,D,D,D,D PWM
UNO ATMEGA
181
L Shield
Shields
,
Adaf rui t Mot or L Adaf rui t
Dri ver L Shi el d
Servo DC Shi el d
St epper
181
DC
DC
Shi el d
L
KHz
182
183
,
M,M ,M ,M
, ,
,
,
,
J umper ,
184
EXT ,
Power
185
,
186
#include <AFMotor.h>
AF_DCMotor Rightmotor(1);
AF_DCMotor Leftmotor(2);
uint8_t i;
v oid setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Motor test!");
// turn on motor
Rightmotor.setSpeed(255);
Leftmotor.setSpeed(255);
Rightmotor.run(RELEASE);
Leftmotor.run(RELEASE);
}
v oid loop() {
Rightmotor.run(FORWARD);
Leftmotor.run(FORWARD);
for (i=0; i<255; i++) {
Rightmotor.setSpeed(i);
Leftmotor.setSpeed(i);
delay (10);
}
Rightmotor.run(BACKWARD);
Leftmotor.run(BACKWARD);
for (i=0; i<255; i++) {
Rightmotor.setSpeed(i);
Leftmotor.setSpeed(i);
delay (10);
}
Rightmotor.run(RELEASE);
Leftmotor.run(RELEASE);
delay (1000);
}
187
#include <AFMotor.h>
AF_DCMotor motor(motor #)
KHz
motor.setSpeed(255);
motor.run();
RELEASE
188
FORWARD
BACKWARD
189
Motor driver L
,
,
191
L Modul e
191
,
192
OUT IN IN IN
IN , OUT IN
OUT
OUT
,
, , , , , PWM
,
193
const int IN1=3;
const int IN2=5;
const int IN3=6;
const int IN4=9;
void setup() {
// fIRST , define the Motor's pin as an OUTPUT
pinMode( IN1 ,OUTPUT);
pinMode( IN2 ,OUTPUT);
pinMode( IN3 ,OUTPUT);
pinMode( IN4 ,OUTPUT);
}
void ClockWise(){
//When we want to let Motor To Rotate clock wise
// just void this part on the loop section .
digitalWrite(IN1,LOW);
digitalWrite(IN2,HIGH);
digitalWrite(IN3,HIGH);
digitalWrite(IN4,LOW);
}
void CounterClockWise(){
//When we want to let Motor To Rotate Counter clock wise
// just void this part on the loop section .
digitalWrite(IN1,HIGH);
digitalWrite(IN2,LOW);
digitalWrite(IN3,LOW);
digitalWrite(IN4,HIGH);
}
void Stop(){
//When we want to let Motor To Rotate clock wise
// just void this part on the loop section .
194
digitalWrite(IN1,LOW);
digitalWrite(IN2,LOW);
digitalWrite(IN3,LOW);
digitalWrite(IN4,LOW);
}
void loop() {
// put your main code here, to run repeatedly:
ClockWise();delay(2000);
Stop();delay(500);
CounterClockWise();delay(2000);
Stop();delay(500);
}
}
v oid ClockWise(int Speed){
//When we want to let Motor To Rotate clock wise
// just v oid this part on the loop section .
analogWrite(IN1,0);
analogWrite(IN2,Speed);
analogWrite(IN3,Speed);
analogWrite(IN4,0);
}
v oid CounterClockWise(int Speed){
//When we want to let Motor To Rotate Counter clock wise
// just v oid this part on the loop section .
analogWrite(IN1,Speed);
analogWrite(IN2,0);
analogWrite(IN3,0);
analogWrite(IN4,Speed);
}
v oid Stop(){
//When we want to let Motor To Rotate clock wise
// just v oid this part on the loop section .
analogWrite(IN1,0);
analogWrite(IN2,0);
analogWrite(IN3,0);
analogWrite(IN4,0);
}
v oid loop() {
//Rise Up
for(int i=0;i<255;i++){
195
ClockWise(i);
delay (10);
}
for(int i=255;i>0;i--){
ClockWise(i);
delay (10);
}
for(int i=0;i<255;i++){
CounterClockWise(i);
delay (10);
}
for(int i=255;i>0;i--){
CounterClockWise(i);
delay (10);
}
}
196
PI R Sensor
197
Mi crocont rol l er
H
IG H
198
199
,
211
, LED
uno
PI R sensor
LED
HC
Bread Board
211
212
boolean x;
void setup(){
pinMode(12,INPUT);
pinMode(11,OUTPUT);
Serial.begin(9600);
}
void loop (){
x= digitalRead(12);
if (x==1){
digitalWrite(11,HIGH);
delay(50);
Serial.println("There is motion");
}
if (x==0){
digitalWrite(11,LOW);
delay(50);
Serial.println("no motion");
}
}
213
#include <SoftwareSerial.h>// import the serial library
Genotronex.println("**There is motion**");
delay (1000);
}
delay (100);
}
214
KEYPAD
Keypad
,
215
Keypad
Keypad
but t on
216
Keypad
sol derl ess J umper
Breadboard
Keypad
Keypad
Col umns Rows
,
, Swi t ch But t on
217
Keypad
Rows
col umns
218
,
int t=10;
byte C1=6;
byte C2=7;
byte C3=8;
byte C4=9;
//............
byte R1=2;
byte R2=3;
byte R3=4;
byte R4=5;
//............
boolean Button_state=1;
//...........
byte col[]={6,7,8,9};
219
byte row[] ={2,3,4,5};
//...........
char Button[4][4] = {
{ '1','2','3','A' },
{ '4','5','6','B' },
{ '7','8','9','C' },
{ '*','0','#','D' }
};
voidsetup(){
Serial.begin(9600);
pinMode(R1,OUTPUT);
pinMode(R2,OUTPUT);
pinMode(R3,OUTPUT);
pinMode(R4,OUTPUT);
//........
pinMode(C1,INPUT);
pinMode(C2,INPUT);
pinMode(C3,INPUT);
pinMode(C4,INPUT);
//.......
digitalWrite(C1,HIGH);
digitalWrite(C2,HIGH);
digitalWrite(C3,HIGH);
digitalWrite(C4,HIGH);
//.............
digitalWrite(R1,HIGH);
digitalWrite(R2,HIGH);
digitalWrite(R3,HIGH);
digitalWrite(R4,HIGH);
}
voidloop(){
int x=0;
for (int i=0;i<4;i++){
digitalWrite(row[i],LOW);
delay(t);
for (int j=0;j<4;j++){
digitalWrite(row[i],LOW);
Button_state=digitalRead(col[j]);
digitalWrite(row[i],HIGH);
if (Button_state == 0){
Serial.print("Button Pushed ");
x=i+j;
Serial.println(Button[i][j]);
delay(500);
}
}
}
}
211
D D R
D D C
, I NPUT
digitalWrite(C1,HIGH);
digitalWrite(C2,HIGH);
digitalWrite(C3,HIGH);
digitalWrite(C4,HIGH);
Seri al Moni t or
211
,Bl uet oot h
IR I nf ared
HP, Di gi t al , I BM
Eri csson
,Haral d Bl at and
212
,Bl uet oot h Bl at and
GHz
B
Bl uet oot h Hardware Devi ce Address
Transmi ssi on BD ADDR
213
Recei ved Si gnal St rengt h I ndi cat i on
RSSI
HS
BD ADDR
214
Power
A DP
,AVRCP
,BI P
,FAX
,GAP
I RDA
I nf ared Dat a Associ at i on
Recei ver
215
,one t o one
216
217
,
218
,
219
,
MCU
,
, ,
,
ATMEGA
221
,
221
D C M otor gear
servo
DC
222
DC
, MCU
,
MCU
L L
223
,
224
,
,
225
,
, ,
,
226
,
Line Foloower
,
,
I nf rared
, ,
227
Uno
228
Rover
L Modul e
QTR A
229
Sensor Shi el d
231
J umper
Rover
,
L
Sensor Shi el d
bread board
L Modul e
231
QTR A
232
, IR ,
,
,
,
233
#include <QTRSensors.h>
#include "L298_MOTOR.h"
234
qtra.read(sensorValues);
delay(5);//delay 5ms
for(int i=0;i<4;i++){
Serial.print("sensorValues[ ");
Serial.print(i);
Serial.print(" ] = ");
Serial.println(sensorValues[i]);
}
}
void Get_QTR_Order(){
// 4 sensor
//sensorValues[0] ,sensorValues[1] ,sensorValues[2],sensorValues[3]
qtra.read(sensorValues);
//.....................
//forward movment state :
if(sensorValues[3]<Threshold && sensorValues[2]>Threshold
&&sensorValues[1]>Threshold &&sensorValues[0]<Threshold ){//0110
L298.FORWARD(SPEED);
// Serial.println("forward ");
}
if(sensorValues[3]<Threshold && sensorValues[2]>Threshold
&&sensorValues[1]<Threshold &&sensorValues[0]<Threshold ){//0100
L298.FORWARD(SPEED);
// Serial.println("forward ");
}
if(sensorValues[3]<Threshold && sensorValues[2]>Threshold
&&sensorValues[1]<Threshold &&sensorValues[0]<Threshold ){//0010
L298.FORWARD(SPEED);
// Serial.println("forward ");
}
//......................
//Right movment state
if(sensorValues[3]<Threshold && sensorValues[2]>Threshold
&&sensorValues[1]>Threshold &&sensorValues[0]>Threshold ){//0111
L298.TurnLEFT(SPEED);
delay(d);
//Serial.println("Right ");
}
if(sensorValues[3]<Threshold && sensorValues[2]<Threshold
&&sensorValues[1]>Threshold &&sensorValues[0]>Threshold ){//0011
L298.TurnLEFT(SPEED);
//Serial.println("Right ");
delay(d);
}
if(sensorValues[3]<Threshold && sensorValues[2]<Threshold
&&sensorValues[1]<Threshold &&sensorValues[0]>Threshold ){//0001
L298.TurnLEFT(SPEED);
//Serial.println("Right ");
delay(d);
}
//......................
//left movment state
if(sensorValues[3]>Threshold && sensorValues[2]>Threshold
&&sensorValues[1]>Threshold &&sensorValues[0]<Threshold ){//1110
L298.TurnRIGHT(SPEED);
//Serial.println("Left ");
delay(d);
}
if(sensorValues[3]>Threshold && sensorValues[2]>Threshold
&&sensorValues[1]<Threshold &&sensorValues[0]<Threshold ){//1100
235
L298.TurnRIGHT(SPEED);
//Serial.println("Left ");
delay(d);
}
if(sensorValues[3]>Threshold && sensorValues[2]<Threshold
&&sensorValues[1]<Threshold &&sensorValues[0]<Threshold ){//1000
L298.TurnRIGHT(SPEED);
//Serial.println("Left ");
delay(d);
}
//.....................
// stop State condtion !
// if(sensorValues[3]>Threshold && sensorValues[2]<Threshold
&&sensorValues[1]<Threshold &&sensorValues[0]>Threshold ){//1001
if(sensorValues[3]>Threshold && sensorValues[2]>Threshold
&&sensorValues[1]>Threshold &&sensorValues[0]>Threshold ){//1111
L298.STOP();
}
}
voidsetup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(13,OUTPUT);
for(int x=0;x<10;x++){
QTR_Sensor_test();
digitalWrite(13,1);
delay(250);
digitalWrite(13,0);
}
Serial.println("test Complete ");
}
voidloop() {
// put your main code here, to run repeatedly:
Get_QTR_Order();
}
236
1
, ,
.
" Avoiding Robot "
,
Ultrasonic
.
,
,
,
Dumilanova Uno 1
237
2
, Sparkfun
Wheel4
238
Ultrasonic HC-SR04 4
5 , 5
9
239
female-female , , 6
dc jack male+female ,8
1 pin header male ,
1
2
tri >>>"D12
echo>>"D13
vcc>> vcc
Gnd>>Gnd
9
5 V5
dc jack female , 4
,
,
VCC
Gnd
241
5
Serial monitor ,
/*
// This code to drive 2 DC Motor using L298 Module
// Connect :
IN1 >>>> D3
IN2 >>>> D5
IN3 >>>> D6
IN4 >>>> D9
ultrasonic connection :
Vcc>>>5V
Tri >>>D12
Echo>>>D13
Gnd>>>>Gnd
*/
241
#include "Ultrasonic.h"
int distance = 0;
Ultrasonic ultrasonic (12,13);
const int IN1=3;
const int IN2=5;
const int IN3=6;
const int IN4=9;
boolean Rotate=true;
voidsetup() {
// fIRST , define the Motor's pin as an OUTPUT
pinMode( IN1 ,OUTPUT);// Right Motor 1st wire
pinMode( IN2 ,OUTPUT);// Right Motor 2nd wire
pinMode( IN3 ,OUTPUT);// left Motor 1st wire
pinMode( IN4 ,OUTPUT);// left Motor 2nd wire
}
void forward(int Speed){
//When we want to let Motor To Rotate clock wise
// just void this part on the loop section .
analogWrite(IN1,0);
analogWrite(IN2,Speed);
analogWrite(IN3,Speed);
analogWrite(IN4,0);
}
void backward(int Speed){
//When we want to let Motor To Rotate Counter clock wise
// just void this part on the loop section .
analogWrite(IN1,Speed);
analogWrite(IN2,0);
analogWrite(IN3,0);
analogWrite(IN4,Speed);
}
void left(int Speed){
//When we want to let Motor To Rotate Counter clock wise
// just void this part on the loop section .
analogWrite(IN1,0);
analogWrite(IN2,Speed);
analogWrite(IN3,0);
analogWrite(IN4,Speed);
}
void right(int Speed){
//When we want to let Motor To Rotate Counter clock wise
// just void this part on the loop section .
analogWrite(IN1,Speed);
analogWrite(IN2,0);
analogWrite(IN3,Speed);
analogWrite(IN4,0);
}
void Stop(){
//When we want to let Motor To Rotate clock wise
// just void this part on the loop section .
analogWrite(IN1,0);
analogWrite(IN2,0);
analogWrite(IN3,0);
analogWrite(IN4,0);
}
voidloop() {
//Rise Up
242
distance=ultrasonic.Ranging(CM);
delay(40);
if(distance>20){
forward(160);
delay(20);
Rotate=!Rotate ;// Random direction
}
if(distance<=20 &&Rotate==true ){
right(120);
}
if(distance<=20 &&Rotate==false ){
left(120);
}
}
243
,
Android
244
Uno 1
245
3
246
Linvor HC-06 HC-05 4
5 , 5
9
247
4.4 6
female-female , , 7
dc jack male+female ,4
1 pin header male ,
248
A0,A1 L293 Motor driver
,
249
https://play.google.com/store/apps/details?id=braulio.calle.bluetoothRCco
ntroller
L293
#include <AFMotor.h>
#include <SoftwareSerial.h>// import the serial library
SoftwareSerial Genotronex(14, 15); // RX, TX
voidsetup() {
// put your setup code here, to run once:
Genotronex.begin(9600);
left_motor.setSpeed(200); // set the speed to 200/255
right_motor.setSpeed(180); // set the speed to 200/25
}
voidloop() {
// put your main code here, to run repeatedly:
if (Genotronex.available()){
BluetoothData=Genotronex.read();
delay(t);
251
switch(BluetoothData){
case'F':
left_motor.run(FORWARD);
right_motor.run(FORWARD);
delay(t);
break;
case'L':// right
left_motor.run(BACKWARD);
right_motor.run(FORWARD); // turn it on going forward
delay(t);
break;
case'R'://left
left_motor.run(FORWARD);
right_motor.run(BACKWARD);
delay(t);
break;
case'B':
left_motor.run(BACKWARD);
right_motor.run(BACKWARD);
delay(t);
break;
case'S':
left_motor.run(RELEASE);
right_motor.run(RELEASE);
delay(t);
break;
case'2':
left_motor.setSpeed(100); // set the speed to 200/255
right_motor.setSpeed(80); // set the speed to 200/25
break;
case'4':
left_motor.setSpeed(150); // set the speed to 200/255
right_motor.setSpeed(130); // set the speed to 200/25
break;
case'7':
left_motor.setSpeed(200); // set the speed to 200/255
right_motor.setSpeed(180); // set the speed to 200/25
break;
case'q':
left_motor.setSpeed(250); // set the speed to 200/255
right_motor.setSpeed(230); // set the speed to 200/25
}
}
251
25
:
zaafraniwissem@gmail.com
:
https://www.facebook.com/trez.hochrinada
:
https://twitter.com/ZaafraniWissem
:
+216 26664243
252
http://www.4shared.com/rar/Qu4wIm-w/Ultrasonic.html
aplication pour commander robot bluetooth
https://play.google.com/store/apps/details?id=braulio.calle.blue toothRCco
ntroller
ultrasonic
http://www.4shared.com/rar/Qu4wIm-w/Ultrasonic.html
Structure
Fonctions de base Structures de contrôle Syntaxe de base
Ces deux fonctions sont • if • ; (point virgule)
obligatoires dans tout • if...else • {} (accolades)
programme en langage • for • // (commentaire sur
Arduino : • switch case une ligne)
• void setup() • while • /* */ (commentaire
• void loop( ) • do... while Sur plusieurs lignes)
• break • #define
• continue • #include
• return
• goto
Opérateurs arithmétiques Opérateurs de Opérateurs
• = (égal ité) comparaison booléens
253
• + (addition) • == (égal à) • && (ET booléen)
• - (soustraction) • != (différent de) • || (OU booléen)
• * (multiplication) • < (inférieur à) • ! (NON booléen
• / (division) • > (supérieur à)
• % (modulo) • <= (inférieur ou
égal à)
• >= (supérieur ou
égal à)
Pointeurs Opérateurs bit à bit Opérateurs
• * pointeur • & (ET bit à bit) composés
• & pointeur • |(OU bit à bit) • ++ (incrémentation)
• ^(OU EXCLUSIF bit • -- (décrémentation)
à • += (addition
bit) composée)
• ˜(NON bit à bit) • -= (soustraction
• << (décalage à composée)
gauche) • *= (multiplication
• >> (décalage à composée)
Droite) • /= (division
composée)
• &= (ET bit à bit
composé)
254
Variables et constantes
Constantes prédéfinies Types des données Conversion des types
Les constantes Les variables peuvent de données
prédéfinies être de • char()
du type variés qui sont • byte()
langage Arduino sont des décrits cidessous. • int()
valeurs particulières Synthèse des types de • long()
ayant données Arduino • float()
une • boolean • word()
signification spécifique. • char Portée des variables
• HIGH | LOW • byte et
• INPUT | OUTPUT • int qualificateurs
• true | false • unsignedint • Portée des variables
A ajouter : constantes • long • static
décimales prédéfinies • unsigne d long • volatile
Expressions • float (nombres à • const
numériques virgules) Utilitaires
• Expressions • double (nombres à • sizeof() (opérateur
numériques entières virgules) sizeof )
• Expressions • Les chaînes de Référence
numériques à virgule caractères • Code ASCII
• objet String NEW
• Les tableaux de
variables
• le mot-clé void
(fonctions)
• word
• PROGMEM
255
Fonctions
Entrées/Sorties Temps Trigonométrie
Numériques • unsigned long millis() • sin (rad)
• pinMode (broche, • unsigned long • cos (rad)
mode) micros() • tan (rad)
• digitalWrite (broche, • delay (ms) Bits et Octets
valeur) • delayMicroseconds • lowByte ()
• intdigitalRead(broche) (us) • highByte ()
Entrées analogiques Math • bitRead ()
• intanalogRead(broche) • min (x, y) • bitWrite ()
• analogReference (type) • max (x, y) • bitSet ()
Sorties "analogiques" • abs (x) • bitClear ()
(génération d'impulsion) • constrain (x, a, b) • bit ()
• analogWrite (broche, • map (valeur, toLow, Interruptions
valeur) - PWM fromHigh, toLow, Externes
Entrées/Sorties toHigh) • attachInterrupt
Avancées • pow (base, (interrupti
• tone () exposant) on, fonction, mode)
• noTone () • sq (x) • detachInterrupt
• shiftOut (broche, • sqrt (x) (interrupt
BrocheHorloge, Pour davantage de ion)
OrdreBit, valeur) fonctions Interruptions
• unsigned long mathématiques, voir • interrupts ()
pulseIn(broche, valeur) aussi la • noInterrupts ()
Communication librairie math.h: log,
• Serial log10,
asin, atan, acos, etc...
Nombresrandomisés
(hasard)
• randomSeed (seed)
• long random(max)
• long random(min,
max)
256
https://www.hackster.io/arduino/projects
http://www.cytron.com.my
https://www.hackster.io
http://isnaha.com
http://horizon4electronics.blogspot.com
http://fablab-egypt.com
https://brainy-bits.com
https://www.pjrc.com
http://www.genotronex.com
257