Line 35... |
Line 35... |
35 |
pinMode(LAMP2, OUTPUT); |
35 |
pinMode(LAMP2, OUTPUT); |
36 |
pinMode(FW1, OUTPUT); |
36 |
pinMode(FW1, OUTPUT); |
37 |
pinMode(FW2, OUTPUT); |
37 |
pinMode(FW2, OUTPUT); |
38 |
pinMode(FW3, OUTPUT); |
38 |
pinMode(FW3, OUTPUT); |
39 |
|
39 |
|
- |
|
40 |
pinMode(6, OUTPUT); |
- |
|
41 |
analogWrite(6, 128); |
- |
|
42 |
|
40 |
// initialize the serial port: |
43 |
// initialize the serial port: |
41 |
Serial.begin(9600); |
44 |
Serial.begin(9600); |
42 |
|
45 |
|
43 |
Wire.begin(); // join i2c bus |
46 |
Wire.begin(); // join i2c bus |
44 |
} |
47 |
} |
45 |
|
48 |
|
46 |
|
49 |
|
47 |
void loop() |
50 |
void loop() |
48 |
{ |
51 |
{ |
- |
|
52 |
|
- |
|
53 |
while(TRUE); |
- |
|
54 |
|
49 |
byte i,n; // for fors |
55 |
byte i,n; // for fors |
50 |
byte present = 0; // for 1-Wire |
56 |
byte present = 0; // for 1-Wire |
51 |
byte data[12]; // data from temperature |
57 |
byte data[12]; // data from temperature |
52 |
byte inByte; // RS232 data |
58 |
byte inByte; // RS232 data |
53 |
int dd=0; // data from light |
59 |
int dd=0; // data from light |
54 |
|
60 |
|
55 |
digitalWrite(LAMP1, HIGH); // All outputs OFF |
61 |
digitalWrite(LAMP1, HIGH); // All outputs OFF |
56 |
digitalWrite(LAMP2, HIGH); |
62 |
digitalWrite(LAMP2, HIGH); |
57 |
digitalWrite(FW1, LOW); |
63 |
digitalWrite(FW1, HIGH); |
58 |
digitalWrite(FW2, LOW); |
64 |
digitalWrite(FW2, HIGH); |
59 |
digitalWrite(FW3, LOW); |
65 |
digitalWrite(FW3, HIGH); |
60 |
delay(300); |
66 |
delay(300); |
61 |
digitalWrite(LAMP1, LOW); // blik |
67 |
digitalWrite(LAMP1, LOW); // blik |
62 |
|
68 |
|
63 |
//--------------------------------------------------------- Serial Input |
69 |
//--------------------------------------------------------- Serial Input |
64 |
// if we get a valid byte |
70 |
// if we get a valid byte |
Line 127... |
Line 133... |
127 |
ds.reset(); |
133 |
ds.reset(); |
128 |
ds.select(addr); |
134 |
ds.select(addr); |
129 |
ds.write(0x44,1); // start conversion, with parasite power on at the end |
135 |
ds.write(0x44,1); // start conversion, with parasite power on at the end |
130 |
|
136 |
|
131 |
delay(800); // maybe 750ms is enough, maybe not |
137 |
delay(800); // maybe 750ms is enough, maybe not |
132 |
// digitalWrite(FW1, LOW); // blik |
138 |
digitalWrite(FW1, LOW); // blik |
133 |
|
139 |
|
134 |
present = ds.reset(); |
140 |
present = ds.reset(); |
135 |
ds.select(addr); |
141 |
ds.select(addr); |
136 |
ds.write(0xBE); // Read Scratchpad |
142 |
ds.write(0xBE); // Read Scratchpad |
137 |
|
143 |
|
Line 156... |
Line 162... |
156 |
Wire.send(0b11000000); // setup (eye light sensing; measurement range 1 [1000 lx]) |
162 |
Wire.send(0b11000000); // setup (eye light sensing; measurement range 1 [1000 lx]) |
157 |
Wire.endTransmission(); // stop transmitting |
163 |
Wire.endTransmission(); // stop transmitting |
158 |
|
164 |
|
159 |
// Delay for measurement, maybe 100ms is enough, maybe not |
165 |
// Delay for measurement, maybe 100ms is enough, maybe not |
160 |
delay(110); |
166 |
delay(110); |
161 |
// digitalWrite(FW2, LOW); // blik |
167 |
digitalWrite(FW2, LOW); // blik |
162 |
|
168 |
|
163 |
// Connect to device and set register light0 |
169 |
// Connect to device and set register light0 |
164 |
Wire.beginTransmission(light0); |
170 |
Wire.beginTransmission(light0); |
165 |
Wire.send(0x00); // sends light0 |
171 |
Wire.send(0x00); // sends light0 |
166 |
Wire.endTransmission(); // stop transmitting |
172 |
Wire.endTransmission(); // stop transmitting |
Line 203... |
Line 209... |
203 |
Wire.send(0b11000001); // setup (eye light sensing; measurement range 2 [4000 lx]) |
209 |
Wire.send(0b11000001); // setup (eye light sensing; measurement range 2 [4000 lx]) |
204 |
Wire.endTransmission(); // stop transmitting |
210 |
Wire.endTransmission(); // stop transmitting |
205 |
|
211 |
|
206 |
// Delay for measurement, maybe 100ms is enough, maybe not |
212 |
// Delay for measurement, maybe 100ms is enough, maybe not |
207 |
delay(110); |
213 |
delay(110); |
208 |
// digitalWrite(FW3, LOW); // blik |
214 |
digitalWrite(FW3, LOW); // blik |
209 |
|
215 |
|
210 |
// Connect to device and set register light0 |
216 |
// Connect to device and set register light0 |
211 |
Wire.beginTransmission(light1); |
217 |
Wire.beginTransmission(light1); |
212 |
Wire.send(0x00); // sends light0 |
218 |
Wire.send(0x00); // sends light0 |
213 |
Wire.endTransmission(); // stop transmitting |
219 |
Wire.endTransmission(); // stop transmitting |