Открыть Электронные книги
Категории
Открыть Аудиокниги
Категории
Открыть Журналы
Категории
Открыть Документы
Категории
Brian W. Evans
................................................................................................................................................ 6
...................................................................................................................................................... 8
setup()....................................................................................................................................................... 8
loop() ........................................................................................................................................................ 9
................................................................................................................................................... 9
{} ............................................................................................................................... 10
; .................................................................................................................................... 10
* ... */ ..................................................................................................................... 11
............................................................................................................... 11
.............................................................................................................................................. 12
..................................................................................................................... 13
........................................................................................................................... 14
byte ......................................................................................................................................................... 15
int ............................................................................................................................................................ 15
long ......................................................................................................................................................... 15
float......................................................................................................................................................... 15
................................................................................................................................................. 16
............................................................................................................................................... 17
.................................................................................................................... 17
........................................................................................................................... 18
......................................................................................................................... 18
.................................................................................................................................................. 19
true/false ................................................................................................................................................ 19
high/low.................................................................................................................................................. 19
input/output ........................................................................................................................................... 19
.......................................................................................................................... 20
if .............................................................................................................................................................. 20
if...else .................................................................................................................................................... 21
for ........................................................................................................................................................... 22
while ....................................................................................................................................................... 23
do...while ................................................................................................................................................ 23
/ ............................................................................................................................. 24
pinMode (pin, mode).............................................................................................................................. 24
digitalRead (pin)...................................................................................................................................... 25
digitalWrite (pin, value) .......................................................................................................................... 25
analogRead (pin)..................................................................................................................................... 26
analogWtite (pin, value) ......................................................................................................................... 27
................................................................................................................................. 28
delay (ms) ............................................................................................................................................... 28
millis() ..................................................................................................................................................... 28
min (x, y) ................................................................................................................................................. 28
max (x, y) ................................................................................................................................................ 28
....................................................................................................................................... 29
randomSeed (seed) ................................................................................................................................ 29
random (max) ......................................................................................................................................... 29
random (min, max) ................................................................................................................................. 29
........................................................................................................................ 30
Serial.begin (rate) ................................................................................................................................... 30
Serial.println (data) ................................................................................................................................. 30
............................................................................................................................................... 31
................................................................................................................................... 32
...................................................................................................................................... 33
............................................................................................................................ 34
pwm ............................................................................................................................................ 35
.......................................................................................................................... 36
.......................................................................................................... 37
........................................................................................................................................... 38
, ,
Arduino. ,
,
- web, , . ,
Arduino ,
,
.
Arduino C,
.
Arduino,
. O'Sullivan Igoe Physical Computing.
Arduino Getting started
with Arduino, Banzi, aka Adruino Booklet. ,
,
, , ,
.
,
,
web- Arduino: http://www.arduino.cc.
:
vgololobov@yandex.ru http://vgololobov.narod.ru
:
http://robocraft.ru
Arduino ,
, . , ,
.
setup() , loop() .
.
setup - , , ,
. setup - , ,
,
(pinMode())
loop ,
, ..
Arduino .
setup()
setup() , .
. ,
.
c | 8
loop()
setup() loop() ,
, ,
- , Arduino.
, , ,
. void setup() void loop()
, .
,
.
, , . ,
, 'int' (integer) .
, void.
, , .
delayVal()
.
v, v ,
0 1023, 4,
0 255,
.
c | 9
{}
( )
, void loop()
(statements) for if.
{
}. , ,
. ,
,
.
Arduino,
. ,
, .
;
.
for.
: ,
.
, .
,
, ,
.
c | 10
/* ... */
,
. .
/* */ .
/* ,
!
*/
, , ,
, , ,
.
:
, .
//
// ()
. ,
.
//
,
,
.
c | 11
. - ,
, - , ,
, .
(), , - ,
. inputVariable,
, 2- :
'inputVariable' . ,
int, .
2. 2
.
, -,
, ,
. ,
. , 100
, , inputVariable 100,
, inputVariable, ,
, 100:
: ,
. tiltSensor pushButton
,
. var value, ,
, .
,
Arduino.
| 12
,
.
: int, long, float .., ,
.
,
.
, inputVariable
int, .
.
int inputVariable = 0;
, ,
, , .
| 13
void setup(),
, , for. ,
, ( ),
.
,
.
setup().
,
for. ,
. ,
,
. ,
,
.
,
, :
| 14
byte
8- .
0 255.
int
,
16- 32767 -32768.
: ,
.
, x = 32767 1 x, x = x +1
x++, x -32678.
long
, ,
32- 2147383647 -2147383648.
float
, .
,
32- 3.4028235E+38 -3.4028235E+38.
: ,
. ,
, , ,
.
| 15
, .
. ,
0. ,
, .
, ,
:
,
:
for,
.
. for
, 0, 0
flicker[], 180, PWM- (-
) 10; 200 ms,
.
| 16
, , .
, , ()
.
, ,
, 9/4 2 2.25, 9 4 int
. ,
, , .
,
. , () float,
, .
. , , ,
, , (0-1) (0- -32768). ,
, float,
: .
: ( )
, , (int)myFloat -
. , i = (int) 3.6 - i 3.
. for, .
:
: , x *= 3 x
x.
| 17
if, .
?? :
, ,
, . :
AND, OR NOT, if:
| 18
Arduino , .
, .
.
true/false
, . FALSE
0 (), TRUE, 1, - , .
-1, 2 200 TRUE.
high/low
HIGH LOW
. HIGH 1,
ON 5 (3-5), LOW 0, OFF 0 (0-2).
input/output
pinMode()
: INPUT (), OUTPUT ().
| 19
if
if , , , ,
, ,
- , true (). ,
. if :
someVariable (value),
, . ,
. ,
, ,
.
: =, if (x = 10),
, x 10, true.
==, if (x == 10),
x 10 . = - , == - ?
| 20
if...else
if...else , . ,
-, HIGH,
- , LOW, :
else if , ,
.
else . ,
:
: if ,
. ,
, , if (inputPin == HIGH).
if ,
5 .
| 21
for
for ,
.
. ,
, for:
, ,
.
. ,
, . ,
.
i 0, , i
20, , , i 1 :
: for ,
, Basic.
, .
,
.
.
| 22
while
while , ,
false (). - ,
. , , ,
, , , ,
.
, someVariable 200, ,
, ,
someVariable 200.
do...while
do , while,
, , ,
.
readSensor x, 50
, , x , 100.
| 23
/
pinMode (pin, mode)
void setup () ,
(INPUT) (OUTPUT).
Arduino ,
INPUT pinMode (). ,
INPUT, ().
Atmega, ,
20 .
:
, ,
. , pin
, .
, OUTPUT,
40 (, ).
!),
, .
Arduino
Atmega. ,
OUTPUT 470 1 .
/ | 24
digitalRead (pin)
(pin)
HIGH LOW. ,
(0-13).
, ,
LED (), ,
:
/ | 25
analogRead (pin)
(pin) 10-
. (0-5).
0 1023.
: ,
INPUT OUTPUT (
14-18).
- | 26
0 0
; 255 5 .
0 255 0 5
, HIGH (5 ). , 64
0 , 5 ;
128 0, 5 ;
192 0 5 .
( ),
analogWrite ,
analogWrite ( digitalRead digitalWrite
).
: , ,
INPUT OUTPUT.
,
4 PWM PWM :
- | 27
delay (ms)
( ),
1000 1 .
millis()
, unsigned long,
Arduino.
: ( ), ,
, 9 .
min (x, y)
.
max (x, y)
.
| 28
randomSeed (seed)
, ,
random().
Arduino , randomSeed
, random,
random .
, , ,
millis(), analogRead()
.
random (max)
random (min, max)
random ,
min max.
: randomSeed().
0 255 PWM
PWM , :
| 29
Serial.begin (rate)
.
9600, .
: , 0 (RX) 1
(TX) .
Serial.println (data)
,
. ,
Serial.print(), .
:
Serial.println() Serial.print() Arduino.
0
.
| 30
| 31
hello world,
-. 13
. , 13-
Arduino .
| 32
:
. ,
2. ,
HIGH .
| 33
, 40 Arduino.
MOSFET
. MOSFET
5 .
: , , ,
.
| 34
pwm
- (PWM)
.
.
LED,
for.
| 35
Arduino ( (ADC))
0-1023.
LED.
| 36
, ,
..
. ,
LED.
| 37
- , 1800. ,
20 .
servoPulse 100 1700 .
| 38
| 39
| 40