source: rtos_arduino/trunk/arduino_lib/libraries/LuckyShield/examples/PresenceAlarm/PresenceAlarm.ino@ 175

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/*
2Presence Alarm
3
4A simple Arduino sketch that play a sound with the on board buzzer when a presence is
5detected by the PIR
6
7The buzzer is directly connected on the digital pin 5
8
9The following pins are defined in the Lucky Shield library, they directly map the digitals
10of the Lucky Shield
11
12LED1: on board first LED
13LED2: on board second LED
14
15REL1: on board first Relay
16REL2: on board second Relay
17
18JOYR: on board Joystick - moved right
19JOYL: on board Joystick - moved left
20JOYU: on board Joystick - moved up
21JOYD: on board Joystick - moved down
22JOYC: on board Joystick - central pressed
23
24PIR: on board (Passive Infrared Sensor) Presence Sensor
25
26PB1: on board first Push Button
27PB2: on board second Push Button
28
29created Mar 2016
30by 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
41void setup() {
42
43 lucky.begin();
44
45}
46
47void 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.