source: rtos_arduino/trunk/arduino_lib/libraries/LuckyShield/examples/SimpleGPIO/SimpleGPIO.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.5 KB
Line 
1/*
2Simple GPIO
3
4A simple Arduino sketch that turn off and on the onboard relais and leds of the Lucky Shield.
5When the joystick is moved on the left, led n1 and relay n1 are turned on,
6when the joystick is moved on the right, led n2 and relay n2 are turned off.
7
8The following pins are defined in the Lucky Shield library, they directly map the digitals
9of the Lucky Shield
10
11LED1: on board first LED
12LED2: on board second LED
13
14REL1: on board first Relay
15REL2: on board second Relay
16
17JOYR: on board Joystick - moved right
18JOYL: on board Joystick - moved left
19JOYU: on board Joystick - moved up
20JOYD: on board Joystick - moved down
21JOYC: on board Joystick - central pressed
22
23PIR: on board (Passive Infrared Sensor) Presence Sensor
24
25PB1: on board first Push Button
26PB2: on board second Push Button
27
28created Mar 2016
29by andrea@arduino.org,
30 sergio@arduino.org
31*/
32
33#include <Lucky.h>
34#include <Wire.h>
35
36void setup() {
37 lucky.begin();
38
39}
40
41void loop() {
42
43 //Check if the the joystick is moved to the left
44 if(lucky.gpio().digitalRead(JOYL) == HIGH){
45 lucky.gpio().digitalWrite(LED1, HIGH);
46 lucky.gpio().digitalWrite(REL1, HIGH);
47 }
48 else {
49 lucky.gpio().digitalWrite(LED1, LOW);
50 lucky.gpio().digitalWrite(REL1, LOW);
51 }
52
53 //Check if the the joystick is moved to the right
54 if(lucky.gpio().digitalRead(JOYR) == HIGH){
55 lucky.gpio().digitalWrite(LED2, HIGH);
56 lucky.gpio().digitalWrite(REL2, HIGH);
57 }
58 else {
59 lucky.gpio().digitalWrite(LED2, LOW);
60 lucky.gpio().digitalWrite(REL2, LOW);
61 }
62}
Note: See TracBrowser for help on using the repository browser.