source: rtos_arduino/trunk/examples/MultiTaskText/SingleTask/r2ca_app.cpp@ 260

Last change on this file since 260 was 260, checked in by ertl-honda, 8 years ago

マクロ名を更新.
実行モデルを変更.

File size: 2.1 KB
Line 
1#include "r2ca.h"
2
3//#define LED_BLINK
4//#define CLED_BLINK
5//#define TOUCH_SENSE
6#define LUX_SENSE
7
8#include <Wire.h>
9#include <Digital_Light_TSL2561.h>
10#include <SeeedOLED.h>
11#include <ChainableLED.h>
12
13#define LED_PIN 4
14#define TOUCH_PIN 3
15
16#ifdef LED_BLINK
17
18void setup() {
19 pinMode(LED_PIN, OUTPUT);
20}
21
22void loop() {
23 digitalWrite(LED_PIN, HIGH);
24 delay(1000);
25 digitalWrite(LED_PIN, LOW);
26 delay(1000);
27}
28
29#endif /* LED_BLINK */
30
31#ifdef CLED_BLINK
32
33#define NUM_LEDS 1
34ChainableLED leds(8, 9, NUM_LEDS);
35
36void setup() {
37 leds.init();
38}
39
40void loop() {
41 int i;
42 for(i = 0; i < 25; i++){
43 leds.setColorRGB(0, i*10, 0, 0);
44 delay(10);
45 }
46 for(i = 0; i < 25; i++){
47 leds.setColorRGB(0, 0, i*10, 0);
48 delay(10);
49 }
50 for(i = 0; i < 25; i++){
51 leds.setColorRGB(0, 0, 0, i*10);
52 delay(10);
53 }
54}
55#endif /* CLED_BLINK */
56
57#ifdef TOUCH_SENSE
58
59int PreTouchValue = 0;
60int TouchState = 0;
61int LEDState = 0;
62
63void setup() {
64 pinMode(TOUCH_PIN, INPUT_PULLUP);
65 pinMode(LED_PIN, OUTPUT);
66 digitalWrite(LED_PIN, LOW);
67}
68
69void loop() {
70 int TouchValue = digitalRead(TOUCH_PIN);
71
72 if ((PreTouchValue == 0) && (TouchValue == 1) && (TouchState == 0)) {
73 TouchState = 1;
74 }
75
76 if ((PreTouchValue == 1) && (TouchValue == 0) && (TouchState == 1)) {
77 TouchState = 0;
78 if (LEDState == 0) {
79 LEDState = 1;
80 digitalWrite(LED_PIN, HIGH);
81 }
82 else {
83 LEDState = 0;
84 digitalWrite(LED_PIN, LOW);
85 }
86 }
87 PreTouchValue = TouchValue;
88}
89
90#endif /* TOUCH_SENSE */
91
92
93#ifdef LUX_SENSE
94void setup() {
95 Wire.begin();
96 TSL2561.init();
97 SeeedOled.init();
98 SeeedOled.deactivateScroll();
99 SeeedOled.setNormalDisplay();
100 SeeedOled.clearDisplay();
101}
102
103int OLEDCount = 0;
104
105void loop() {
106 int lux = TSL2561.readVisibleLux();
107
108 SeeedOled.setTextXY(0, 0);
109 SeeedOled.putString("Digital Light");
110 SeeedOled.setTextXY(1, 0);
111 SeeedOled.putString("Sensor Value is");
112 SeeedOled.setTextXY(2, 0);
113 SeeedOled.putNumber(lux);
114 SeeedOled.putString(" lux ");
115 SeeedOled.setTextXY(4, 0);
116 SeeedOled.putString("Count is");
117 SeeedOled.setTextXY(5, 0);
118 SeeedOled.putNumber(OLEDCount++);
119}
120#endif /* LUX_SENSE */
Note: See TracBrowser for help on using the repository browser.