Last change
on this file since 175 was 175, checked in by ertl-honda, 8 years ago |
ライブラリを Arduino IDE 1.7.9 にupdate
|
File size:
1.1 KB
|
Line | |
---|
1 | /*
|
---|
2 | Presence Alarm
|
---|
3 |
|
---|
4 | A simple Arduino sketch that play a sound with the on board buzzer when a presence is
|
---|
5 | detected by the PIR
|
---|
6 |
|
---|
7 | The buzzer is directly connected on the digital pin 5
|
---|
8 |
|
---|
9 | The following pins are defined in the Lucky Shield library, they directly map the digitals
|
---|
10 | of the Lucky Shield
|
---|
11 |
|
---|
12 | LED1: on board first LED
|
---|
13 | LED2: on board second LED
|
---|
14 |
|
---|
15 | REL1: on board first Relay
|
---|
16 | REL2: on board second Relay
|
---|
17 |
|
---|
18 | JOYR: on board Joystick - moved right
|
---|
19 | JOYL: on board Joystick - moved left
|
---|
20 | JOYU: on board Joystick - moved up
|
---|
21 | JOYD: on board Joystick - moved down
|
---|
22 | JOYC: on board Joystick - central pressed
|
---|
23 |
|
---|
24 | PIR: on board (Passive Infrared Sensor) Presence Sensor
|
---|
25 |
|
---|
26 | PB1: on board first Push Button
|
---|
27 | PB2: on board second Push Button
|
---|
28 |
|
---|
29 | created Mar 2016
|
---|
30 | by andrea@arduino.org,
|
---|
31 | sergio@arduino.org
|
---|
32 | */
|
---|
33 |
|
---|
34 | #include <Lucky.h>
|
---|
35 | #include <Wire.h>
|
---|
36 |
|
---|
37 | #define BUZ 5
|
---|
38 | #define NOTE_1 220
|
---|
39 | #define NOTE_2 300
|
---|
40 |
|
---|
41 | void setup() {
|
---|
42 |
|
---|
43 | lucky.begin();
|
---|
44 |
|
---|
45 | }
|
---|
46 |
|
---|
47 | void loop() {
|
---|
48 |
|
---|
49 | if(lucky.gpio().digitalRead(PIR) == LOW ){
|
---|
50 | for(int i = 0; i < 5; i++){
|
---|
51 | tone(BUZ, NOTE_2);
|
---|
52 | delay(500);
|
---|
53 | tone(BUZ, NOTE_1);
|
---|
54 | delay(500);
|
---|
55 | }
|
---|
56 | noTone(BUZ);
|
---|
57 | }
|
---|
58 |
|
---|
59 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.