| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

DC2218A.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC2218A Demonstration Board.
3 LT3965 - 8-Switch Matrix LED Dimmer
4
5 @verbatim
6
7 Setup:
8
9 Follow the procedure below:
10 1. Set the PATTERN SELECT rotary switch S1 to any position between 0 and 6.
11 Position 7 is reserved for use with the GUI (graphical user interface).
12 2. Connect 12V power to either the EMIVIN and GND banana jacks or to the
13 J7 2.1mm (inside diameter) barrel jack.
14 3. Observe the red LED indicator light (D32). When it begins flashing,
15 then the board is ready to start up.
16 4. When the red LED (D32) is flashing, push the Start button S3.
17 5. Observe the LED patterns and adjust the speed, brightness and pattern of
18 the LEDs with the manual blue potentiometer R14.
19 6. Change the Pattern Select rotary switch to positions 0-6 to observe
20 different patterns.
21 7. Press the Reset button S2 to start over again.
22
23
24
25 USER INPUT DATA FORMAT:
26 decimal : 1024
27 hex : 0x400
28 octal : 02000 (leading 0 "zero")
29 binary : B10000000000
30 float : 1024.0
31
32 @endverbatim
33
34 http://www.linear.com/product/LT3965
35
36 http://www.linear.com/product/LT3965#demoboards
37
38
39 Copyright 2018(c) Analog Devices, Inc.
40
41 All rights reserved.
42
43 Redistribution and use in source and binary forms, with or without
44 modification, are permitted provided that the following conditions are met:
45 - Redistributions of source code must retain the above copyright
46 notice, this list of conditions and the following disclaimer.
47 - Redistributions in binary form must reproduce the above copyright
48 notice, this list of conditions and the following disclaimer in
49 the documentation and/or other materials provided with the
50 distribution.
51 - Neither the name of Analog Devices, Inc. nor the names of its
52 contributors may be used to endorse or promote products derived
53 from this software without specific prior written permission.
54 - The use of this software may or may not infringe the patent rights
55 of one or more patent holders. This license does not release you
56 from the requirement that you obtain separate licenses from these
57 patent holders to use this software.
58 - Use of the software either in source or binary form, must be run
59 on or directly connected to an Analog Devices Inc. component.
60
61 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
62 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
63 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
64 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
65 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
66 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
67 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
68 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
69 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
70 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
71 */
72
73 /*! @file
74 @ingroup LT3965
75 */
76
77
78 #include <stdio.h>
79 #include "Linduino.h"
80 #include "LT_I2C.h"
81 #include "LT3965.h"
82
83
84 //******************Function Declarations******************
85 //******************Display Pattern Functions******************
86 void fadewave();
87 void analog();
88 void sidebend();
89 void sidebendAuto();
90 void dazzle();
91 void pulse();
92 void wave();
93 void steeringRightAndLeft();
94 void sectionalBlanking();
95 void orbit();
96 void GraphicUI();
97 int readpot();
98 void setThresh();
99
100
101 uint8_t updown;
102 int lastread;
103 int currentread;
104
105
106 //Setup message bytes
107 int16_t An2, An1, An0;
108 uint8_t inputByte_0;
109 uint8_t inputByte_1;
110 uint8_t inputByte_2;
111 uint8_t inputByte_3;
112 uint8_t inputByte_4;
113
114 uint8_t input;
115 uint8_t fade;
116 int set = 0;
117 uint8_t values[4];
118
119 bool startsequence = FALSE;
120
121 uint8_t startup = 0;
122 long interval = 250;
123 long previousTime = 0;
124 uint8_t ledState;
125
126
127 // Setup the hardware I2C interface.
128 // LT3965_i2c_enable or quikeval_I2C_init must be called before using any of the other I2C routines.
129 void LT3965_i2c_enable()
130 {
131 TWSR = (HARDWARE_I2C_PRESCALER_1 & 0x03); //! 1) set the prescaler bits
132 TWBR = 12; //! 2) set the bit rate
133 }
134
135
136 //! Initialize Linduino
137 void setup()
138 {
139 int8_t ack = 0; // I2C acknowledge bit
140
141 pinMode(REDLED, OUTPUT);
142 pinMode(LOADPIN, OUTPUT);
143 pinMode(BUTTONPIN, INPUT);
144 pinMode(PWMPIN, OUTPUT);
145 pinMode(ALERTPIN, INPUT);
146
147 digitalWrite(REDLED, HIGH);
148 digitalWrite(PWMPIN, LOW); // Pull pwm pin on LT3797 low to turn on with LEDs in OFF state
149 digitalWrite(LOADPIN, HIGH);
150
151 analogReference(EXTERNAL); // Set analog reference voltage to voltage sensed on AREF pin
152 currentread = analogRead(A3);
153 digitalWrite(PWMPIN, LOW);
154 lastread = currentread;
155 updown = DOWN;
156
157 delay(50);
158
159 An0 = analogRead(A0); // Read 8 position switch pin 1
160 An1 = analogRead(A1); // Read 8 position switch pin 2
161 An2 = analogRead(A2); // Read 8 position switch pin 3
162
163 if (!(An0 > 120 && An1 > 120 && An2 > 120))
164 {
165 int alertStatus = digitalRead(ALERTPIN);
166 while (alertStatus)
167 {
168 alertStatus = digitalRead(ALERTPIN);
169 }
170 }
171
172 LT3965_i2c_enable(); // Enable the I2C port
173 quikeval_I2C_connect(); // Connect I2C to main data port
174 delay(50);
175
176 // Change Open-Circuit Threshold to 4.5V and turn all LEDs ON; ADDRESS1
177 ack |= i2c_scwriteshort(address1, CHANNEL0, 0b0000);
178 ack |= i2c_scwriteshort(address1, CHANNEL1, 0b0000);
179 ack |= i2c_scwriteshort(address1, CHANNEL2, 0b0000);
180 ack |= i2c_scwriteshort(address1, CHANNEL3, 0b0000);
181 ack |= i2c_scwriteshort(address1, CHANNEL4, 0b0000);
182 ack |= i2c_scwriteshort(address1, CHANNEL5, 0b0000);
183 ack |= i2c_scwriteshort(address1, CHANNEL6, 0b0000);
184 ack |= i2c_scwriteshort(address1, CHANNEL7, 0b0000);
185 // Change Open-Circuit Threshold to 4.5V and turn all LEDs ON; ADDRESS2
186 ack |= i2c_scwriteshort(address2, CHANNEL0, 0b0000);
187 ack |= i2c_scwriteshort(address2, CHANNEL1, 0b0000);
188 ack |= i2c_scwriteshort(address2, CHANNEL2, 0b0000);
189 ack |= i2c_scwriteshort(address2, CHANNEL3, 0b0000);
190 ack |= i2c_scwriteshort(address2, CHANNEL4, 0b0000);
191 ack |= i2c_scwriteshort(address2, CHANNEL5, 0b0000);
192 ack |= i2c_scwriteshort(address2, CHANNEL6, 0b0000);
193 ack |= i2c_scwriteshort(address2, CHANNEL7, 0b0000);
194 // Change Short-Circuit Threshold to 1V and turn all LEDs ON; ADDRESS1
195 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0000, 1);
196 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0000, 1);
197 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0000, 1);
198 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0000, 1);
199 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0000, 1);
200 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0000, 1);
201 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0000, 1);
202 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0000, 1);
203 // Change Short-Circuit Threshold to 1V and turn all LEDs ON; ADDRESS2
204 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0000, 1);
205 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0000, 1);
206 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0000, 1);
207 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0000, 1);
208 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0000, 1);
209 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0000, 1);
210 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0000, 1);
211 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0000, 1);
212
213 delay(50);
214
215 if (!(An0 > 120 && An1 > 120 && An2 > 120))
216 {
217 // require a push-button press before doing anything. LED will blink until button is pressed, then stay illuminated.
218 while (digitalRead(BUTTONPIN))
219 {
220 unsigned long currentTime = millis();
221 if (currentTime - previousTime > interval)
222 {
223 previousTime = currentTime;
224 ledState = ! ledState;
225 digitalWrite(REDLED, ledState);
226 }
227 }
228 }
229 digitalWrite(REDLED, LOW);
230
231 An0 = analogRead(A0); // Read 8 position switch pin 1
232 An1 = analogRead(A1); // Read 8 position switch pin 2
233 An2 = analogRead(A2); // Read 8 position switch pin 3
234 }
235
236 //! Repeats Linduino loop
237 void loop()
238 {
239 int8_t ack = 0; // I2C acknowledge bit
240 int switch_pos; // New switch possition
241 int prev_switch_pos; // Previous swicth position
242
243 // require two consecutive switch readings, 50ms apart, before choosing a pattern.
244 do
245 {
246 An0 = analogRead(A0); // Read 8 position switch pin 1
247 An1 = analogRead(A1); // Read 8 position switch pin 2
248 An2 = analogRead(A2); // Read 8 position switch pin 3
249
250 prev_switch_pos = switch_pos;
251
252 //Interpret 3 bits from 8 position switch as decimal integer
253 if (An0 > 120 && An1 < 120 && An2 < 120)
254 switch_pos = 1;
255 else if (An0 < 120 && An1 > 120 && An2 < 120)
256 switch_pos = 2;
257 else if (An0 > 120 && An1 > 120 && An2 < 120)
258 switch_pos = 3;
259 else if (An0 < 120 && An1 < 120 && An2 > 120)
260 switch_pos = 4;
261 else if (An0 > 120 && An1 < 120 && An2 > 120)
262 switch_pos = 5;
263 else if (An0 < 120 && An1 > 120 && An2 > 120)
264 switch_pos = 6;
265 else if (An0 > 120 && An1 > 120 && An2 > 120)
266 switch_pos = 7;
267 else
268 switch_pos = 0;
269
270 delay(50);
271 }
272 while (prev_switch_pos != switch_pos);
273
274 // Call function associated with corresponding switch position value
275 switch (switch_pos)
276 {
277 case 0:
278 orbit();
279 break;
280 case 1:
281 wave(); // Select a DAC to update
282 break;
283 case 2:
284 steeringRightAndLeft(); // Select a DAC to update
285 break;
286 case 3:
287 sectionalBlanking(); // Select a DAC to update
288 break;
289 case 4:
290 sidebend(); // Select a DAC to update
291 break;
292 case 5:
293 analog(); // Select a DAC to update
294 break;
295 case 6:
296 fadewave(); // Select a DAC to update
297 break;
298 case 7:
299 GraphicUI(); // Select a DAC to update
300 break;
301 }
302 }
303
304 //! Function to write I2C bytes which are received from GUI.
305 int8_t write_bytes(uint8_t size, uint8_t byte1, uint8_t byte2, uint8_t byte3)
306 {
307 int8_t ret = 0 ;
308 uint8_t data[3];
309 if (i2c_start() != 0) //I2C START
310 return (1); //Stop and return 0 if START fail
311
312 if (size == 2)
313 {
314 ret |= i2c_write(byte1);
315 ret |= i2c_write(byte2);
316 }
317 else if (size == 3)
318 {
319 ret |= i2c_write(byte1);
320 ret |= i2c_write(byte2);
321 ret |= i2c_write(byte3);
322 }
323 else if (size == 1)
324 {
325 ret |= i2c_write(byte1);
326 }
327
328 i2c_stop(); //I2C STOP
329 if (ret != 0) //Returns 1 if failed
330 return (1);
331 return (0); //Returns 0 if success
332 }
333
334 //! Function to read I2C bytes depending on the bytes received from GUI.
335 int8_t read_bytes(uint8_t size, uint8_t byte1, uint8_t byte2, uint8_t byte3)
336 {
337 int8_t ret = 0 ;
338 if (size == 250 && byte1 == 1 && byte2 == 1 && byte3 == 1) // ALERT - ACMODE READ
339 {
340 uint8_t fault;
341 fault = 1;
342 fault = digitalRead(2); // digital pin2 is connected to ALERT/
343 if (!fault) // fault condition
344 Serial.write(0);
345 else
346 Serial.write(1);
347 }
348 else
349 {
350 uint8_t x;
351 if (i2c_start() != 0) //I2C START
352 return (1); //Stop and return 0 if START fail
353
354 // write byte1 and read size number of bytes
355 ret |= i2c_write(byte1);
356 if (ret == 0) // If response = ACK (slave responded)
357 {
358 for (x = 0; x < (size - 1); ++x)
359 {
360 Serial.write(i2c_read(WITH_ACK));
361 }
362 Serial.write(i2c_read(WITH_NACK));
363 }
364 else // If response = NACK (no slave responded
365 {
366 for (x = 0; x < size; ++x)
367 {
368 Serial.write(0); // The GUI is waiting to read back bytes, sending dummy bytes
369 }
370 }
371 i2c_stop(); //I2C STOP
372 }
373 if (ret != 0) //Returns 1 if failed
374 return (1);
375 return (0); //Returns 0 if success
376 }
377
378 //! Function to talk to GUI.
379 void GraphicUI() // DO NOT EDIT THIS FUNCTION
380 {
381
382 int8_t ack = 0; // I2C acknowledge bit
383 uint8_t data_SCMREG;
384 uint8_t brightness;
385 uint8_t channel;
386 uint8_t x = 0;
387 int toggle = 255;
388 uint8_t values[3];
389 uint8_t ARA;
390 char read_id;
391 setThresh();
392 Serial.begin(115200); // Initialize the serial port to the PC at baud rate of 115200 bps
393
394 An0 = analogRead(A0);
395 An1 = analogRead(A1);
396 An2 = analogRead(A2);
397
398 while (An0 > 120 && An1 > 120 && An2 > 120)
399 {
400 if (Serial.available() > 0)
401 {
402 inputByte_0 = Serial.read();
403 delay(10);
404
405 if (inputByte_0 == 'i') // Making Quikeval compatible
406 {
407 Serial.print("USBSPI,PIC,01,01,DC,DC590,----------------------\r\n");
408 }
409 else if (inputByte_0 == 'I') // Making Quikeval compatible
410 {
411 Serial.print("LT3965,Cls,D3965,01,01,DC,DC2218A,--------------\r\n");
412 }
413 else if (inputByte_0 == 16)
414 {
415 inputByte_1 = Serial.read();
416 delay(10);
417 inputByte_2 = Serial.read();
418 delay(10);
419 inputByte_3 = Serial.read();
420 delay(10);
421 inputByte_4 = Serial.read();
422 delay(10);
423
424 //Detect Command type
425 if (inputByte_1 == 128)
426 {
427 Serial.print("HELLO FROM ARDUINO");
428
429 ack |= i2c_scwriteshort(address1, CHANNEL0, 0b0000);
430 ack |= i2c_scwriteshort(address1, CHANNEL1, 0b0000);
431 ack |= i2c_scwriteshort(address1, CHANNEL2, 0b0000);
432 ack |= i2c_scwriteshort(address1, CHANNEL3, 0b0000);
433 ack |= i2c_scwriteshort(address1, CHANNEL4, 0b0000);
434 ack |= i2c_scwriteshort(address1, CHANNEL5, 0b0000);
435 ack |= i2c_scwriteshort(address1, CHANNEL6, 0b0000);
436 ack |= i2c_scwriteshort(address1, CHANNEL7, 0b0000);
437
438 ack |= i2c_scwriteshort(address2, CHANNEL0, 0b0000);
439 ack |= i2c_scwriteshort(address2, CHANNEL1, 0b0000);
440 ack |= i2c_scwriteshort(address2, CHANNEL2, 0b0000);
441 ack |= i2c_scwriteshort(address2, CHANNEL3, 0b0000);
442 ack |= i2c_scwriteshort(address2, CHANNEL4, 0b0000);
443 ack |= i2c_scwriteshort(address2, CHANNEL5, 0b0000);
444 ack |= i2c_scwriteshort(address2, CHANNEL6, 0b0000);
445 ack |= i2c_scwriteshort(address2, CHANNEL7, 0b0000);
446
447 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0000, 0);
448 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0000, 0);
449 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0000, 0);
450 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0000, 0);
451 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0000, 0);
452 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0000, 0);
453 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0000, 0);
454 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0000, 0);
455
456 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0000, 0);
457 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0000, 0);
458 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0000, 0);
459 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0000, 0);
460 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0000, 0);
461 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0000, 0);
462 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0000, 0);
463 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0000, 0);
464
465 ack |= i2c_acwrite(address1, 0b00000000);
466 ack |= i2c_acwrite(address2, 0b00000000);
467
468 startsequence = TRUE;
469 delay(50);
470 digitalWrite(PWMPIN, HIGH);
471 delay(50);
472 digitalWrite(LOADPIN, LOW);
473 delay(10);
474 }
475 else
476 {
477 write_bytes(inputByte_1, inputByte_2, inputByte_3, inputByte_4);
478 }
479
480 }
481 else if (inputByte_0 == 17)
482 {
483 inputByte_1 = Serial.read();
484 delay(10);
485 inputByte_2 = Serial.read();
486 delay(10);
487 inputByte_3 = Serial.read();
488 delay(10);
489 inputByte_4 = Serial.read();
490 delay(10);
491
492 read_bytes(inputByte_1, inputByte_2, inputByte_3, inputByte_4);
493 }
494 }
495 An0 = analogRead(A0);
496 An1 = analogRead(A1);
497 An2 = analogRead(A2);
498 }
499 }
500
501 //! Func Desc: All LEDs illuminated to the same brightness level depending on potentiometer value.
502 void analogAuto()
503 {
504 setThresh();
505
506 int8_t ack = 0; // I2C acknowledge bit
507 uint8_t i;
508 int j;
509 An0 = analogRead(A0); // Read 8 position switch pin 1
510 An1 = analogRead(A1); // Read 8 position switch pin 2
511 An2 = analogRead(A2); // Read 8 position switch pin 3
512 int analog_in = readpot(); // Read value of potentiometer
513
514 while (An0 > 120 && An1 < 120 && An2 > 120)
515 {
516 if (!startsequence)
517 {
518 ack |= i2c_acwrite(address1, 0);
519 ack |= i2c_acwrite(address2, 0);
520 delay(10);
521 digitalWrite(PWMPIN, HIGH);
522 delay(10);
523 startsequence = TRUE;
524 }
525
526 for (j = 0; j <= 511; j++)
527 {
528 An0 = analogRead(A0);
529 An1 = analogRead(A1);
530 An2 = analogRead(A2);
531 analog_in = readpot();
532 if (j > 255)
533 i = 511 - j;
534 else
535 i = j;
536
537
538 if (i < 1)
539 {
540 ack |= i2c_acwrite(address1, 0b00000000);
541 ack |= i2c_acwrite(address2, 0b00000000);
542 }
543 else if (i > 254)
544 {
545 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0001, i);
546 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0001, i);
547 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0001, i);
548 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0001, i);
549 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0001, i);
550 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0001, i);
551 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0001, i);
552 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0001, i);
553 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0001, i);
554 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0001, i);
555 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0001, i);
556 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0001, i);
557 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0001, i);
558 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0001, i);
559 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0001, i);
560 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0001, i);
561 }
562 else
563 {
564 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, i);
565 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, i);
566 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, i);
567 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, i);
568 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, i);
569 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, i);
570 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, i);
571 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, i);
572 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, i);
573 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, i);
574 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, i);
575 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, i);
576 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, i);
577 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, i);
578 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, i);
579 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, i);
580 }
581 delay(5);
582 if (i < 1)
583 delay(500);
584 if (i == 255)
585 delay(500);
586 }
587 }
588 }
589
590 //! All sixteen LEDs adjust PWM dimming duty cycle and brightness based upon
591 //! the position of the steering wheel (interactive potentiometer). This pattern
592 //! represents a light that bends around the side of a car, projecting a
593 //! turning headlight pattern that is linked to the steering wheel.
594 void sidebendAuto()
595 {
596 setThresh();
597
598 int8_t ack = 0; // I2C acknowledge bit
599 int ch[8];
600 int i;
601 An0 = analogRead(A0); // Read 8 position switch pin 1
602 An1 = analogRead(A1); // Read 8 position switch pin 2
603 An2 = analogRead(A2); // Read 8 position switch pin 3
604 int analog_in;
605
606
607 while (An0 < 120 && An1 < 120 && An2 > 120)
608 {
609 if (!startsequence)
610 {
611 ack |= i2c_acwrite(address1, 0);
612 ack |= i2c_acwrite(address2, 0);
613 delay(10);
614 digitalWrite(PWMPIN, HIGH);
615 delay(10);
616 startsequence = TRUE;
617 }
618
619 for (int a = 0; a < 3; a++)
620 {
621 An0 = analogRead(A0);
622 An1 = analogRead(A1);
623 An2 = analogRead(A2);
624 int increment = 5;
625 int analogStart = 400;
626 int analogMax = 530;
627
628 if (a == 2)
629 {
630 analogMax = 650;
631 increment = 8;
632 }
633
634 delay(500);
635
636 for (analog_in = analogStart; analog_in > analogStart - 1; analog_in += increment)
637 {
638
639 delay(25);
640 An0 = analogRead(A0);
641 An1 = analogRead(A1);
642 An2 = analogRead(A2);
643 ch[0] = (analog_in) - 425;
644 ch[1] = (analog_in) - 450;
645 ch[2] = (analog_in) - 475;
646 ch[3] = (analog_in) - 500;
647 ch[4] = (analog_in) - 525;
648 ch[5] = (analog_in) - 550;
649 ch[6] = (analog_in) - 575;
650 ch[7] = (analog_in) - 600;
651
652 for (i = 0; i < 8; i++)
653 {
654 if (ch[i] < 0)
655 ch[i] = 0;
656 else if (ch[i] > 255)
657 ch[i] = 255;
658 An0 = analogRead(A0);
659 An1 = analogRead(A1);
660 An2 = analogRead(A2);
661
662 }
663
664 if (ch[0] == 0)
665 {
666 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0000, ch[0]);
667 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0000, ch[0]);
668 }
669 else if (ch[0] == 255)
670 {
671 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0001, ch[0]);
672 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0001, ch[0]);
673 }
674 else
675 {
676 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, ch[0]);
677 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, ch[0]);
678 }
679
680 if (ch[1] == 0)
681 {
682 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0000, ch[1]);
683 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0000, ch[1]);
684 }
685 else if (ch[1] == 255)
686 {
687 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0001, ch[1]);
688 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0001, ch[1]);
689 }
690 else
691 {
692 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, ch[1]);
693 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, ch[1]);
694 }
695
696 if (ch[2] == 0)
697 {
698 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0000, ch[2]);
699 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0000, ch[2]);
700 }
701 else if (ch[2] == 255)
702 {
703 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0001, ch[2]);
704 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0001, ch[2]);
705 }
706 else
707 {
708 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, ch[2]);
709 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, ch[2]);
710 }
711
712 if (ch[3] == 0)
713 {
714 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0000, ch[3]);
715 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0000, ch[3]);
716 }
717 else if (ch[3] == 255)
718 {
719 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0001, ch[3]);
720 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0001, ch[3]);
721 }
722 else
723 {
724 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, ch[3]);
725 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, ch[3]);
726 }
727
728 if (ch[4] == 0)
729 {
730 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0000, ch[4]);
731 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0000, ch[4]);
732 }
733 else if (ch[4] == 255)
734 {
735 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0001, ch[4]);
736 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0001, ch[4]);
737 }
738 else
739 {
740 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, ch[4]);
741 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, ch[4]);
742 }
743
744 if (ch[5] == 0)
745 {
746 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0000, ch[5]);
747 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0000, ch[5]);
748 }
749 else if (ch[5] == 255)
750 {
751 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0001, ch[5]);
752 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0001, ch[5]);
753 }
754 else
755 {
756 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, ch[5]);
757 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, ch[5]);
758 }
759
760 if (ch[6] == 0)
761 {
762 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0000, ch[6]);
763 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0000, ch[6]);
764 }
765 else if (ch[6] == 255)
766 {
767 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0001, ch[6]);
768 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0001, ch[6]);
769 }
770 else
771 {
772 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, ch[6]);
773 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, ch[6]);
774 }
775
776 if (ch[7] == 0)
777 {
778 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0000, ch[7]);
779 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0000, ch[7]);
780 }
781 else if (ch[7] == 255)
782 {
783 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0001, ch[7]);
784 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0001, ch[7]);
785 }
786 else
787 {
788 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, ch[7]);
789 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, ch[7]);
790 }
791 An0 = analogRead(A0);
792 An1 = analogRead(A1);
793 An2 = analogRead(A2);
794 if (analog_in >= analogMax)
795 {
796 delay(250);
797 increment *= -1;
798 }
799 }
800 }
801 }
802 }
803
804 //! Consecutive LEDs alternate fading up and down. Speed of fading controlled by
805 //! the position of the potentiometer.
806 void dazzle()
807 {
808 setThresh();
809
810 int8_t ack = 0; // I2C acknowledge bit
811 int8_t bright = -127;
812 uint8_t brightness;
813 An0 = analogRead(A0); // Read 8 position switch pin 1
814 An1 = analogRead(A1); // Read 8 position switch pin 2
815 An2 = analogRead(A2); // Read 8 position switch pin 3
816 int analog_in = analogRead(A3); // Read value of potentiometer
817
818 while ( An0 > 120 && An1 < 120 && An2 < 120)
819 {
820 An0 = analogRead(A0); // Read 8 position switch pin 1
821 An1 = analogRead(A1); // Read 8 position switch pin 2
822 An2 = analogRead(A2); // Read 8 position switch pin 3
823 analog_in = analogRead(A3); // Read value of potentiometer
824
825 brightness = abs(bright) * 2;
826
827 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, brightness); // Single channel write command to control a single LED
828 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, brightness);
829 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, brightness);
830 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, brightness);
831 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, brightness);
832 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, brightness);
833 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, brightness);
834 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, brightness);
835
836 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, 255 - brightness);
837 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, 255 - brightness);
838 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, 255 - brightness);
839 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, 255 - brightness);
840 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, 255 - brightness);
841 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, 255 - brightness);
842 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, 255 - brightness);
843 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, 255 - brightness);
844
845 delay(analog_in / 20);
846
847 bright = bright + 2;
848 if (bright >= 127)
849 bright = -127;
850 }
851 }
852
853 //! Center headlight LEDs stay on to face directly forward while the right and
854 //! left side LEDs turn on with brightness proportional to the amount that the
855 //! steering wheel (interactive potentiometer) is turned.
856 void steeringRightAndLeft()
857 {
858 setThresh();
859
860 int8_t ack = 0; // I2C acknowledge bit
861 int ch[6]; // only need 8 channels - four right and four left
862 int i;
863 uint8_t j = 0;
864 An0 = analogRead(A0); // Read 8 position switch pin 1
865 An1 = analogRead(A1); // Read 8 position switch pin 2
866 An2 = analogRead(A2); // Read 8 position switch pin 3
867 int analog_in = analogRead(A3); // Read value of potentiometer
868
869
870
871 while (An0 < 120 && An1 > 120 && An2 < 120)
872 {
873 An0 = analogRead(A0); // Read 8 position switch pin 1
874 An1 = analogRead(A1); // Read 8 position switch pin 2
875 An2 = analogRead(A2); // Read 8 position switch pin 3
876 analog_in = analogRead(A3); // Read value of potentiometer
877
878 ch[0] = 250 - (analog_in);
879 ch[1] = 325 - (analog_in);
880 ch[2] = 400 - (analog_in);
881 ch[3] = (analog_in) - 650;
882 ch[4] = (analog_in) - 725;
883 ch[5] = (analog_in) - 800;
884
885 // calculate right and left bending lights update
886 for (i = 0; i < 6; i++)
887 {
888 if (ch[i] < 0)
889 ch[i] = 0;
890 else if (ch[i] > 255)
891 ch[i] = 255;
892 }
893
894 if (!startsequence)
895 {
896 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, 1);
897 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, 1);
898 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, 1);
899 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, 1);
900 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, 1);
901 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, 1);
902 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, 1);
903 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, 1);
904 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, 1);
905 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, 1);
906 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, 1);
907 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, 1);
908 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, 1);
909 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, 1);
910 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, 1);
911 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, 1);
912
913 delay(500);
914 digitalWrite(PWMPIN, HIGH);
915 delay(10);
916 digitalWrite(LOADPIN, LOW);
917 delay(10);
918
919 while (j < 255)
920 {
921 if (ch[0] >= j)
922 {
923 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, ch[0]);
924 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, ch[0]);
925 }
926 if (ch[1] >= j)
927 {
928 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, ch[1]);
929 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, ch[1]);
930 }
931 if (ch[2] >= j)
932 {
933 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, ch[2]);
934 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, ch[2]);
935 }
936
937 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, j);
938 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, j);
939 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, j);
940 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, j);
941
942 if (ch[3] >= j)
943 {
944 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, ch[3]);
945 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, ch[3]);
946 }
947 if (ch[4] >= j)
948 {
949 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, ch[4]);
950 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, ch[4]);
951 }
952 if (ch[5] >= j)
953 {
954 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, ch[5]);
955 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, ch[5]);
956 }
957 j++;
958 delay(8);
959 }
960 // delay(2500);
961 startsequence = TRUE;
962 }
963
964 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0001, 255);
965 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0001, 255);
966 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0001, 255);
967 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0001, 255);
968
969 // write to right and left bending lights update
970 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, ch[0]);
971 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, ch[0]);
972 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, ch[1]);
973 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, ch[1]);
974 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, ch[2]);
975 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, ch[2]);
976
977 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, ch[3]);
978 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, ch[3]);
979 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, ch[4]);
980 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, ch[4]);
981 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, ch[5]);
982 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, ch[5]);
983 }
984 }
985
986
987 //! All LEDs are illluminated to full brightness simulating a car
988 //! with its high-beams turned on. Two LEDs will turn off creating
989 //! a blank zone. This pattern shows how segments of a high-beam
990 //! LED cluster can be turned off to avoid blinding oncomming traffic.
991 void sectionalBlanking()
992 {
993 setThresh();
994
995 int8_t ack = 0; // I2C acknowledge bit
996 uint8_t j = 0;
997 An0 = analogRead(A0); // Read 8 position switch pin 1
998 An1 = analogRead(A1); // Read 8 position switch pin 2
999 An2 = analogRead(A2); // Read 8 position switch pin 3
1000 int analog_in = analogRead(A3); // Read value of potentiometer
1001
1002 if (!startsequence) // Checks if start-up sequence has already been run to fade LEDs on
1003 {
1004 while (j < 255)
1005 {
1006 if (j < 1)
1007 {
1008 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0000, j);
1009 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0000, j);
1010 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0000, j);
1011 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0000, j);
1012 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0000, j);
1013 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0000, j);
1014 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0000, j);
1015 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0000, j);
1016 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0000, j);
1017 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0000, j);
1018 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0000, j);
1019 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0000, j);
1020 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0000, j);
1021 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0000, j);
1022 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0000, j);
1023 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0000, j);
1024
1025 digitalWrite(PWMPIN, HIGH);
1026 delay(10);
1027 digitalWrite(LOADPIN, LOW);
1028 delay(10);
1029 }
1030 else if (j >= 254)
1031 {
1032 if (analog_in <= 146)
1033 {
1034 // Swtich OFF LED5 and LED8 of BOARD1
1035 ack |= i2c_acwrite(address1, 0b11110110);
1036 ack |= i2c_acwrite(address2, 0b11111111);
1037 }
1038 else if (analog_in > 146 && analog_in <= 292)
1039 {
1040 // Swtich OFF LED5 and LED4 of BOARD1
1041 ack |= i2c_acwrite(address1, 0b11100111);
1042 ack |= i2c_acwrite(address2, 0b11111111);
1043 }
1044 else if (analog_in > 292 && analog_in <= 438)
1045 {
1046 // Swtich OFF LED4 and LED1 of BOARD1
1047 ack |= i2c_acwrite(address1, 0b01101111);
1048 ack |= i2c_acwrite(address2, 0b11111111);
1049 }
1050 else if (analog_in > 438 && analog_in <= 584)
1051 {
1052 // Swtich OFF LED1 of BOARD1 and LED8 of BOARD2
1053 ack |= i2c_acwrite(address1, 0b01111111);
1054 ack |= i2c_acwrite(address2, 0b11111110);
1055 }
1056 else if (analog_in > 584 && analog_in <= 730)
1057 {
1058 // Swtich OFF LED8 and LED5 of BOARD2
1059 ack |= i2c_acwrite(address1, 0b11111111);
1060 ack |= i2c_acwrite(address2, 0b11110110);
1061 }
1062 else if (analog_in > 730 && analog_in <= 876)
1063 {
1064 // Swtich OFF LED5 and LED4 of BOARD2
1065 ack |= i2c_acwrite(address1, 0b11111111);
1066 ack |= i2c_acwrite(address2, 0b11100111);
1067 }
1068 else
1069 {
1070 // Swtich OFF LED4 and LED1 of BOARD2
1071 ack |= i2c_acwrite(address1, 0b11111111);
1072 ack |= i2c_acwrite(address2, 0b01101111);
1073 }
1074 startsequence = TRUE;
1075 }
1076 else
1077 {
1078 if (analog_in <= 146)
1079 {
1080 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, j);
1081 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, j);
1082 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, j);
1083 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, j);
1084 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, j);
1085 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, j);
1086 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, j);
1087 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, j);
1088 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, j);
1089 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, j);
1090 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, j);
1091 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, j);
1092 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, j);
1093 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, j);
1094 }
1095 else if (analog_in > 146 && analog_in <= 292)
1096 {
1097 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, j);
1098 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, j);
1099 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, j);
1100 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, j);
1101 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, j);
1102 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, j);
1103 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, j);
1104 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, j);
1105 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, j);
1106 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, j);
1107 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, j);
1108 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, j);
1109 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, j);
1110 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, j);
1111 }
1112 else if (analog_in > 292 && analog_in <= 438)
1113 {
1114 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, j);
1115 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, j);
1116 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, j);
1117 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, j);
1118 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, j);
1119 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, j);
1120 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, j);
1121 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, j);
1122 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, j);
1123 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, j);
1124 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, j);
1125 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, j);
1126 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, j);
1127 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, j);
1128 }
1129 else if (analog_in > 438 && analog_in <= 584)
1130 {
1131 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, j);
1132 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, j);
1133 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, j);
1134 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, j);
1135 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, j);
1136 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, j);
1137 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, j);
1138 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, j);
1139 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, j);
1140 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, j);
1141 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, j);
1142 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, j);
1143 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, j);
1144 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, j);
1145 }
1146 else if (analog_in > 584 && analog_in <= 730)
1147 {
1148 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, j);
1149 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, j);
1150 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, j);
1151 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, j);
1152 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, j);
1153 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, j);
1154 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, j);
1155 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, j);
1156 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, j);
1157 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, j);
1158 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, j);
1159 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, j);
1160 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, j);
1161 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, j);
1162 }
1163 else if (analog_in > 730 && analog_in <= 876)
1164 {
1165 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, j);
1166 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, j);
1167 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, j);
1168 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, j);
1169 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, j);
1170 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, j);
1171 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, j);
1172 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, j);
1173 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, j);
1174 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, j);
1175 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, j);
1176 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, j);
1177 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, j);
1178 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, j);
1179 }
1180 else
1181 {
1182 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, j);
1183 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, j);
1184 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, j);
1185 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, j);
1186 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, j);
1187 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, j);
1188 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, j);
1189 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, j);
1190 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, j);
1191 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, j);
1192 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, j);
1193 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, j);
1194 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, j);
1195 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, j);
1196 }
1197 }
1198 delay(2);
1199 j++;
1200 }
1201 }
1202
1203 while (An0 > 120 && An1 > 120 && An2 < 120)
1204 {
1205 An0 = analogRead(A0); // Read 8 position switch pin 1
1206 An1 = analogRead(A1); // Read 8 position switch pin 2
1207 An2 = analogRead(A2); // Read 8 position switch pin 3
1208 analog_in = analogRead(A3);
1209
1210 if (analog_in <= 146)
1211 {
1212 // Swtich OFF LED5 and LED8 of BOARD1
1213 ack |= i2c_acwrite(address1, 0b11110110);
1214 ack |= i2c_acwrite(address2, 0b11111111);
1215 }
1216 else if (analog_in > 146 && analog_in <= 292)
1217 {
1218 // Swtich OFF LED5 and LED4 of BOARD1
1219 ack |= i2c_acwrite(address1, 0b11100111);
1220 ack |= i2c_acwrite(address2, 0b11111111);
1221 }
1222 else if (analog_in > 292 && analog_in <= 438)
1223 {
1224 // Swtich OFF LED4 and LED1 of BOARD1
1225 ack |= i2c_acwrite(address1, 0b01101111);
1226 ack |= i2c_acwrite(address2, 0b11111111);
1227 }
1228 else if (analog_in > 438 && analog_in <= 584)
1229 {
1230 // Swtich OFF LED1 of BOARD1 and LED8 of BOARD2
1231 ack |= i2c_acwrite(address1, 0b01111111);
1232 ack |= i2c_acwrite(address2, 0b11111110);
1233 }
1234 else if (analog_in > 584 && analog_in <= 730)
1235 {
1236 // Swtich OFF LED8 and LED5 of BOARD2
1237 ack |= i2c_acwrite(address1, 0b11111111);
1238 ack |= i2c_acwrite(address2, 0b11110110);
1239 }
1240 else if (analog_in > 730 && analog_in <= 876)
1241 {
1242 // Swtich OFF LED5 and LED4 of BOARD2
1243 ack |= i2c_acwrite(address1, 0b11111111);
1244 ack |= i2c_acwrite(address2, 0b11100111);
1245 }
1246 else
1247 {
1248 // Swtich OFF LED4 and LED1 of BOARD2
1249 ack |= i2c_acwrite(address1, 0b11111111);
1250 ack |= i2c_acwrite(address2, 0b01101111);
1251 }
1252 }
1253 }
1254
1255 //! Func Desc: Varying number of brightened LEDs depending on pot
1256 void sidebend()
1257 {
1258 setThresh();
1259
1260 int8_t ack = 0; // I2C acknowledge bit
1261 int ch[8];
1262 int i;
1263 uint8_t j = 0;
1264 An0 = analogRead(A0); // Read 8 position switch pin 1
1265 An1 = analogRead(A1); // Read 8 position switch pin 2
1266 An2 = analogRead(A2); // Read 8 position switch pin 3
1267 int analog_in = readpot(); // Read value of potentiometer
1268
1269 while (An0 < 120 && An1 < 120 && An2 > 120)
1270 {
1271 An0 = analogRead(A0);
1272 An1 = analogRead(A1);
1273 An2 = analogRead(A2);
1274
1275 analog_in = 1023 - readpot();
1276
1277 ch[0] = (analog_in) - 425;
1278 ch[1] = (analog_in) - 450;
1279 ch[2] = (analog_in) - 475;
1280 ch[3] = (analog_in) - 500;
1281 ch[4] = (analog_in) - 525;
1282 ch[5] = (analog_in) - 550;
1283 ch[6] = (analog_in) - 575;
1284 ch[7] = (analog_in) - 600;
1285
1286 for (i = 0; i < 8; i++)
1287 {
1288 if (ch[i] < 0)
1289 ch[i] = 0;
1290 else if (ch[i] > 255)
1291 ch[i] = 255;
1292 }
1293
1294 if (!startsequence)
1295 {
1296 if (ch[0] <= 0)
1297 {
1298 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0000, 0);
1299 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0000, 0);
1300 }
1301 else
1302 {
1303 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, 1);
1304 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, 1);
1305 }
1306 if (ch[1] <= 0)
1307 {
1308 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0000, 0);
1309 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0000, 0);
1310 }
1311 else
1312 {
1313 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, 1);
1314 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, 1);
1315 }
1316 if (ch[2] <= 0)
1317 {
1318 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0000, 0);
1319 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0000, 0);
1320 }
1321 else
1322 {
1323 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, 1);
1324 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, 1);
1325 }
1326 if (ch[3] <= 0)
1327 {
1328 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0000, 0);
1329 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0000, 0);
1330 }
1331 else
1332 {
1333 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, 1);
1334 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, 1);
1335 }
1336 if (ch[4] <= 0)
1337 {
1338 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0000, 0);
1339 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0000, 0);
1340 }
1341 else
1342 {
1343 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, 1);
1344 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, 1);
1345 }
1346 if (ch[5] <= 0)
1347 {
1348 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0000, 0);
1349 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0000, 0);
1350 }
1351 else
1352 {
1353 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, 1);
1354 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, 1);
1355 }
1356 if (ch[6] <= 0)
1357 {
1358 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0000, 0);
1359 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0000, 0);
1360 }
1361 else
1362 {
1363 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, 1);
1364 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, 1);
1365 }
1366 if (ch[7] <= 0)
1367 {
1368 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0000, 0);
1369 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0000, 0);
1370 }
1371 else
1372 {
1373 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, 1);
1374 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, 1);
1375 }
1376
1377 delay(500);
1378 digitalWrite(PWMPIN, HIGH);
1379 delay(10);
1380 digitalWrite(LOADPIN, LOW);
1381 delay(10);
1382
1383 while (j < 255)
1384 {
1385 if ((ch[0] >= j) && (ch[0] > 0))
1386 {
1387 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, j);
1388 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, j);
1389 }
1390 if ((ch[1] >= j) && (ch[1] > 0))
1391 {
1392 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, j);
1393 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, j);
1394 }
1395 if ((ch[2] >= j) && (ch[2] > 0))
1396 {
1397 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, j);
1398 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, j);
1399 }
1400 if ((ch[3] >= j) && (ch[3] > 0))
1401 {
1402 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, j);
1403 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, j);
1404 }
1405 if ((ch[4] >= j) && (ch[4] > 0))
1406 {
1407 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, j);
1408 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, j);
1409 }
1410 if ((ch[5] >= j) && (ch[5] > 0))
1411 {
1412 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, j);
1413 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, j);
1414 }
1415 if ((ch[6] >= j) && (ch[6] > 0))
1416 {
1417 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, j);
1418 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, j);
1419 }
1420 if ((ch[7] >= j) && (ch[7] > 0))
1421 {
1422 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, j);
1423 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, j);
1424 }
1425 j++;
1426 delay(8);
1427 }
1428 startsequence = TRUE;
1429 }
1430
1431 if (ch[0] == 0)
1432 {
1433 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0000, ch[0]);
1434 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0000, ch[0]);
1435 }
1436 else if (ch[0] == 255)
1437 {
1438 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0001, ch[0]);
1439 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0001, ch[0]);
1440 }
1441 else
1442 {
1443 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, ch[0]);
1444 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, ch[0]);
1445 }
1446
1447 if (ch[1] == 0)
1448 {
1449 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0000, ch[1]);
1450 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0000, ch[1]);
1451 }
1452 else if (ch[1] == 255)
1453 {
1454 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0001, ch[1]);
1455 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0001, ch[1]);
1456 }
1457 else
1458 {
1459 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, ch[1]);
1460 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, ch[1]);
1461 }
1462
1463 if (ch[2] == 0)
1464 {
1465 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0000, ch[2]);
1466 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0000, ch[2]);
1467 }
1468 else if (ch[2] == 255)
1469 {
1470 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0001, ch[2]);
1471 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0001, ch[2]);
1472 }
1473 else
1474 {
1475 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, ch[2]);
1476 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, ch[2]);
1477 }
1478
1479 if (ch[3] == 0)
1480 {
1481 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0000, ch[3]);
1482 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0000, ch[3]);
1483 }
1484 else if (ch[3] == 255)
1485 {
1486 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0001, ch[3]);
1487 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0001, ch[3]);
1488 }
1489 else
1490 {
1491 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, ch[3]);
1492 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, ch[3]);
1493 }
1494
1495 if (ch[4] == 0)
1496 {
1497 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0000, ch[4]);
1498 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0000, ch[4]);
1499 }
1500 else if (ch[4] == 255)
1501 {
1502 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0001, ch[4]);
1503 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0001, ch[4]);
1504 }
1505 else
1506 {
1507 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, ch[4]);
1508 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, ch[4]);
1509 }
1510
1511 if (ch[5] == 0)
1512 {
1513 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0000, ch[5]);
1514 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0000, ch[5]);
1515 }
1516 else if (ch[5] == 255)
1517 {
1518 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0001, ch[5]);
1519 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0001, ch[5]);
1520 }
1521 else
1522 {
1523 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, ch[5]);
1524 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, ch[5]);
1525 }
1526
1527 if (ch[6] == 0)
1528 {
1529 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0000, ch[6]);
1530 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0000, ch[6]);
1531 }
1532 else if (ch[6] == 255)
1533 {
1534 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0001, ch[6]);
1535 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0001, ch[6]);
1536 }
1537 else
1538 {
1539 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, ch[6]);
1540 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, ch[6]);
1541 }
1542
1543 if (ch[7] == 0)
1544 {
1545 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0000, ch[7]);
1546 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0000, ch[7]);
1547 }
1548 else if (ch[7] == 255)
1549 {
1550 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0001, ch[7]);
1551 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0001, ch[7]);
1552 }
1553 else
1554 {
1555 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, ch[7]);
1556 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, ch[7]);
1557 }
1558 }
1559 }
1560
1561 //! Func Desc: All LEDs lighted up to the same level depending on pot value.
1562 void analog()
1563 {
1564 setThresh();
1565
1566 int8_t ack = 0; // I2C acknowledge bit
1567 uint8_t i;
1568 uint8_t j = 0;
1569 An0 = analogRead(A0); // Read 8 position switch pin 1
1570 An1 = analogRead(A1); // Read 8 position switch pin 2
1571 An2 = analogRead(A2); // Read 8 position switch pin 3
1572 int analog_in = readpot(); // Read value of potentiometer
1573
1574 if (!startsequence) // Checks if start-up sequence has already been run to fade LEDs on
1575 {
1576 analog_in = 1023 - readpot();
1577 i = analog_in / 4;
1578
1579 while (j <= i)
1580 {
1581 if (j < 1)
1582 {
1583 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0000, j);
1584 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0000, j);
1585 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0000, j);
1586 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0000, j);
1587 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0000, j);
1588 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0000, j);
1589 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0000, j);
1590 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0000, j);
1591 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0000, j);
1592 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0000, j);
1593 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0000, j);
1594 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0000, j);
1595 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0000, j);
1596 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0000, j);
1597 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0000, j);
1598 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0000, j);
1599 digitalWrite(PWMPIN, HIGH);
1600 delay(10);
1601 digitalWrite(LOADPIN, LOW);
1602 delay(10);
1603 }
1604 else if (j > 254)
1605 {
1606 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0001, j);
1607 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0001, j);
1608 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0001, j);
1609 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0001, j);
1610 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0001, j);
1611 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0001, j);
1612 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0001, j);
1613 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0001, j);
1614 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0001, j);
1615 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0001, j);
1616 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0001, j);
1617 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0001, j);
1618 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0001, j);
1619 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0001, j);
1620 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0001, j);
1621 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0001, j);
1622 startsequence = TRUE;
1623 break;
1624 }
1625 else
1626 {
1627 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, j);
1628 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, j);
1629 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, j);
1630 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, j);
1631 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, j);
1632 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, j);
1633 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, j);
1634 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, j);
1635 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, j);
1636 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, j);
1637 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, j);
1638 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, j);
1639 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, j);
1640 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, j);
1641 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, j);
1642 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, j);
1643 if (j == i)
1644 {
1645 startsequence = TRUE;
1646 break;
1647 }
1648 }
1649 delay(2);
1650 j++;
1651 }
1652 }
1653
1654 while (An0 > 120 && An1 < 120 && An2 > 120)
1655 {
1656 An0 = analogRead(A0);
1657 An1 = analogRead(A1);
1658 An2 = analogRead(A2);
1659 analog_in = 1023 - readpot();
1660 i = analog_in / 4;
1661 // i = 128;
1662
1663 if (i < 1)
1664 {
1665 ack |= i2c_acwrite(address1, 0b00000000);
1666 ack |= i2c_acwrite(address2, 0b00000000);
1667 }
1668 else if (i > 254)
1669 {
1670 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0001, i);
1671 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0001, i);
1672 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0001, i);
1673 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0001, i);
1674 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0001, i);
1675 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0001, i);
1676 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0001, i);
1677 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0001, i);
1678 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0001, i);
1679 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0001, i);
1680 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0001, i);
1681 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0001, i);
1682 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0001, i);
1683 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0001, i);
1684 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0001, i);
1685 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0001, i);
1686 }
1687 else
1688 {
1689 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, i);
1690 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, i);
1691 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, i);
1692 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, i);
1693 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, i);
1694 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, i);
1695 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, i);
1696 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, i);
1697 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, i);
1698 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, i);
1699 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, i);
1700 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, i);
1701 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, i);
1702 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, i);
1703 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, i);
1704 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, i);
1705 }
1706 }
1707 }
1708
1709
1710 //! LEDs illuminate around the outside of the board, giving the effect of
1711 //! a comet with a tail traveling around the board. The traveling speed of
1712 //! the comet is controlled by the posititon of the potentiometer. The
1713 //! pattern will continue running after the pattern select switch is changed
1714 //! from this position until the orbit() function has completed its pattern.
1715 void orbit()
1716 {
1717 setThresh();
1718
1719 int8_t ack = 0; // I2C acknowledge bit
1720 uint8_t i, j, k, l;
1721 int up_down = 1; //1 = up, 0 = down, 2 = startup wait, 3 = wait
1722 int delay_var = 5;
1723 uint8_t ch[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; ; //channel count variables
1724 int ud[16] = {1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}; //count up or down variables; 1 = up, 0 = down, 2 = wait
1725 int waitcount[16]; // wait count for unusued LEDs
1726 int analog_in = analogRead(A3); // Read value of potentiometer
1727 An0 = analogRead(A0); // Read 8 position switch pin 1
1728 An1 = analogRead(A1); // Read 8 position switch pin 2
1729 An2 = analogRead(A2); // Read 8 position switch pin 3
1730
1731 waitcount[0] = 0;
1732 waitcount[1] = 15;
1733 waitcount[2] = 14;
1734 waitcount[3] = 13;
1735 waitcount[4] = 12;
1736 waitcount[5] = 11;
1737 waitcount[6] = 10;
1738 waitcount[7] = 9;
1739 waitcount[8] = 8;
1740 waitcount[9] = 7;
1741 waitcount[10] = 6;
1742 waitcount[11] = 5;
1743 waitcount[12] = 4;
1744 waitcount[13] = 3;
1745 waitcount[14] = 2;
1746 waitcount[15] = 1;
1747
1748 // start with this brightness
1749 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0000, 0);
1750 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0000, 0);
1751 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0000, 0);
1752 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0000, 0);
1753 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0000, 0);
1754 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0000, 0);
1755 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0000, 0);
1756 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0000, 0);
1757
1758 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0000, 0);
1759 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0000, 0);
1760 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0000, 0);
1761 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0000, 0);
1762 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0000, 0);
1763 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0000, 0);
1764 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0000, 0);
1765 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0000, 0);
1766
1767
1768 delay(50);
1769 if (!startsequence)
1770 {
1771 digitalWrite(PWMPIN, HIGH);
1772 delay(50);
1773 digitalWrite(LOADPIN, LOW);
1774 delay(10);
1775 startsequence = TRUE;
1776 }
1777 delay(500);
1778
1779 for (j = 0; j < 64; j++)
1780 {
1781 for (i = 0; i <= 9 ; i++)
1782 {
1783 for (k = 0; k <= 15; k++)
1784 {
1785 if (ud[k] == 1)
1786 ch[k] = ch[k] + 25;
1787 else if (ud[k] == 0)
1788 ch[k] = ch[k] - 5;
1789 else
1790 ch[k] = ch[k];
1791 }
1792
1793 if (ch[0] == 0)
1794 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0000, ch[0]);
1795 else
1796 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, ch[0]);
1797
1798 if (ch[1] == 0)
1799 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0000, ch[1]);
1800 else
1801 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, ch[1]);
1802
1803 if (ch[2] == 0)
1804 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0000, ch[2]);
1805 else
1806 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, ch[2]);
1807
1808 if (ch[3] == 0)
1809 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0000, ch[3]);
1810 else
1811 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, ch[3]);
1812
1813 if (ch[12] == 0)
1814 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0000, ch[12]);
1815 else
1816 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, ch[12]);
1817
1818 if (ch[13] == 0)
1819 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0000, ch[13]);
1820 else
1821 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, ch[13]);
1822
1823 if (ch[14] == 0)
1824 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0000, ch[14]);
1825 else
1826 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, ch[14]);
1827
1828 if (ch[15] == 0)
1829 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0000, ch[15]);
1830 else
1831 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, ch[15]);
1832
1833 if (ch[8] == 0)
1834 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0000, ch[8]);
1835 else
1836 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, ch[8]);
1837
1838 if (ch[9] == 0)
1839 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0000, ch[9]);
1840 else
1841 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, ch[9]);
1842
1843 if (ch[10] == 0)
1844 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0000, ch[10]);
1845 else
1846 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, ch[10]);
1847
1848 if (ch[11] == 0)
1849 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0000, ch[11]);
1850 else
1851 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, ch[11]);
1852
1853 if (ch[4] == 0)
1854 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0000, ch[4]);
1855 else
1856 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, ch[4]);
1857
1858 if (ch[5] == 0)
1859 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0000, ch[5]);
1860 else
1861 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, ch[5]);
1862
1863 if (ch[6] == 0)
1864 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0000, ch[6]);
1865 else
1866 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, ch[6]);
1867
1868 if (ch[7] == 0)
1869 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0000, ch[7]);
1870 else
1871 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, ch[7]);
1872
1873
1874 analog_in = analogRead(A3);
1875 delay (analog_in / 24);
1876 }
1877
1878 // check to see if up, down, or wait and increment or change
1879 for (l = 0; l <= 15; l++)
1880 {
1881 if (ud[l] == 1 && ch[l] >= 250)
1882 {
1883 ud[l] = 0;
1884 waitcount[l]++;
1885 }
1886 else if (ud[l] == 2)
1887 {
1888 if (waitcount[l] >= 15)
1889 {
1890 ud[l] = 1;
1891 waitcount[l] = 0;
1892 }
1893 else
1894 waitcount[l]++;
1895 }
1896 else if (ud[l] == 0 && ch[l] <= 5)
1897 {
1898 ud[l] = 2;
1899 waitcount[l]++;
1900 }
1901 else
1902 {
1903 ud[l] = ud[l];
1904 waitcount[l]++;
1905 }
1906 }
1907 }
1908 // run to finish then pause
1909 ud[0] = 2;
1910 ch[0] = 0;
1911 waitcount[0] = 1;
1912 for (j = 0; j < 6; j++)
1913 {
1914 for (i = 0; i <= 9 ; i++)
1915 {
1916 for (k = 0; k <= 15; k++)
1917 {
1918 if (ud[k] == 1)
1919 ch[k] = ch[k] + 25;
1920 else if (ud[k] == 0)
1921 ch[k] = ch[k] - 5;
1922 else
1923 ch[k] = ch[k];
1924 }
1925
1926 if (ch[0] == 0)
1927 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0000, ch[0]);
1928 else
1929 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, ch[0]);
1930
1931 if (ch[1] == 0)
1932 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0000, ch[1]);
1933 else
1934 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, ch[1]);
1935
1936 if (ch[2] == 0)
1937 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0000, ch[2]);
1938 else
1939 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, ch[2]);
1940
1941 if (ch[3] == 0)
1942 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0000, ch[3]);
1943 else
1944 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, ch[3]);
1945
1946 if (ch[12] == 0)
1947 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0000, ch[12]);
1948 else
1949 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, ch[12]);
1950
1951 if (ch[13] == 0)
1952 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0000, ch[13]);
1953 else
1954 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, ch[13]);
1955
1956 if (ch[14] == 0)
1957 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0000, ch[14]);
1958 else
1959 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, ch[14]);
1960
1961 if (ch[15] == 0)
1962 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0000, ch[15]);
1963 else
1964 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, ch[15]);
1965
1966 if (ch[8] == 0)
1967 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0000, ch[8]);
1968 else
1969 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, ch[8]);
1970
1971 if (ch[9] == 0)
1972 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0000, ch[9]);
1973 else
1974 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, ch[9]);
1975
1976 if (ch[10] == 0)
1977 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0000, ch[10]);
1978 else
1979 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, ch[10]);
1980
1981 if (ch[11] == 0)
1982 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0000, ch[11]);
1983 else
1984 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, ch[11]);
1985
1986 if (ch[4] == 0)
1987 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0000, ch[4]);
1988 else
1989 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, ch[4]);
1990
1991 if (ch[5] == 0)
1992 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0000, ch[5]);
1993 else
1994 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, ch[5]);
1995
1996 if (ch[6] == 0)
1997 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0000, ch[6]);
1998 else
1999 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, ch[6]);
2000
2001 if (ch[7] == 0)
2002 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0000, ch[7]);
2003 else
2004 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, ch[7]);
2005
2006 analog_in = analogRead(A3);
2007 delay (analog_in / 24);
2008 }
2009
2010 // check to see if up, down, or wait and increment or change
2011 for (l = 0; l <= 15; l++)
2012 {
2013 if (ud[l] == 1 && ch[l] >= 250)
2014 {
2015 ud[l] = 0;
2016 waitcount[l]++;
2017 }
2018 else if (ud[l] == 2)
2019 {
2020 if (waitcount[l] >= 15)
2021 {
2022 ud[l] = 2;
2023 waitcount[l] = 0;
2024 }
2025 else
2026 waitcount[l]++;
2027 }
2028 else if (ud[l] == 0 && ch[l] <= 5)
2029 {
2030 ud[l] = 2;
2031 waitcount[l]++;
2032 }
2033 else
2034 {
2035 ud[l] = ud[l];
2036 waitcount[l]++;
2037 }
2038 }
2039 }
2040 // restart in the other direction
2041 for (i = 0; i < 16; ++i)
2042 ch[i] = 0;
2043
2044
2045 for (i = 0; i < 15; ++i)
2046 ud[i] = 2;
2047 ud[i] = 1;
2048
2049 waitcount[15] = 0;
2050 waitcount[14] = 15;
2051 waitcount[13] = 14;
2052 waitcount[12] = 13;
2053 waitcount[11] = 12;
2054 waitcount[10] = 11;
2055 waitcount[9] = 10;
2056 waitcount[8] = 9;
2057 waitcount[7] = 8;
2058 waitcount[6] = 7;
2059 waitcount[5] = 6;
2060 waitcount[4] = 5;
2061 waitcount[3] = 4;
2062 waitcount[2] = 3;
2063 waitcount[1] = 2;
2064 waitcount[0] = 1;
2065
2066 // restart with this brightness for the other direction
2067 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0000, 0);
2068 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0000, 0);
2069 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0000, 0);
2070 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0000, 0);
2071 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0000, 0);
2072 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0000, 0);
2073 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0000, 0);
2074 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0000, 0);
2075
2076 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0000, 0);
2077 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0000, 0);
2078 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0000, 0);
2079 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0000, 0);
2080 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0000, 0);
2081 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0000, 0);
2082 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0000, 0);
2083 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0000, 0);
2084
2085 delay(500);
2086 for (j = 0; j < 64; j++)
2087 {
2088 for (i = 0; i <= 9 ; i++)
2089 {
2090 for (k = 0; k <= 15; k++)
2091 {
2092 if (ud[k] == 1)
2093 ch[k] = ch[k] + 25;
2094 else if (ud[k] == 0)
2095 ch[k] = ch[k] - 5;
2096 else ch[k] = ch[k];
2097 }
2098
2099 if (ch[0] == 0)
2100 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0000, ch[0]);
2101 else
2102 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, ch[0]);
2103
2104 if (ch[1] == 0)
2105 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0000, ch[1]);
2106 else
2107 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, ch[1]);
2108
2109 if (ch[2] == 0)
2110 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0000, ch[2]);
2111 else
2112 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, ch[2]);
2113
2114 if (ch[3] == 0)
2115 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0000, ch[3]);
2116 else
2117 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, ch[3]);
2118
2119 if (ch[12] == 0)
2120 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0000, ch[12]);
2121 else
2122 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, ch[12]);
2123
2124 if (ch[13] == 0)
2125 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0000, ch[13]);
2126 else
2127 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, ch[13]);
2128
2129 if (ch[14] == 0)
2130 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0000, ch[14]);
2131 else
2132 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, ch[14]);
2133
2134 if (ch[15] == 0)
2135 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0000, ch[15]);
2136 else
2137 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, ch[15]);
2138
2139 if (ch[8] == 0)
2140 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0000, ch[8]);
2141 else
2142 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, ch[8]);
2143
2144 if (ch[9] == 0)
2145 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0000, ch[9]);
2146 else
2147 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, ch[9]);
2148
2149 if (ch[10] == 0)
2150 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0000, ch[10]);
2151 else
2152 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, ch[10]);
2153
2154 if (ch[11] == 0)
2155 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0000, ch[11]);
2156 else
2157 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, ch[11]);
2158
2159 if (ch[4] == 0)
2160 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0000, ch[4]);
2161 else
2162 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, ch[4]);
2163
2164 if (ch[5] == 0)
2165 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0000, ch[5]);
2166 else
2167 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, ch[5]);
2168
2169 if (ch[6] == 0)
2170 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0000, ch[6]);
2171 else
2172 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, ch[6]);
2173
2174 if (ch[7] == 0)
2175 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0000, ch[7]);
2176 else
2177 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, ch[7]);
2178
2179 analog_in = analogRead(A3);
2180 delay (analog_in / 24);
2181 }
2182
2183 // check to see if up, down, or wait and increment or change
2184 for (l = 0; l <= 15; l++)
2185 {
2186 /* analog_in = analogRead(A3); */
2187 if (ud[l] == 1 && ch[l] >= 250)
2188 {
2189 ud[l] = 0;
2190 waitcount[l]++;
2191 }
2192 else if (ud[l] == 2)
2193 {
2194 if (waitcount[l] >= 15)
2195 {
2196 ud[l] = 1;
2197 waitcount[l] = 0;
2198 }
2199 else
2200 waitcount[l]++;
2201 }
2202 else if (ud[l] == 0 && ch[l] <= 5)
2203 {
2204 ud[l] = 2;
2205 waitcount[l]++;
2206 }
2207 else
2208 {
2209 ud[l] = ud[l];
2210 waitcount[l]++;
2211 }
2212 }
2213 }
2214 // run to finish then pause
2215 ud[15] = 2;
2216 ch[15] = 0;
2217 waitcount[15] = 1;
2218 for (j = 0; j < 6; j++)
2219 {
2220 for (i = 0; i <= 9 ; i++)
2221 {
2222 for (k = 0; k <= 15; k++)
2223 {
2224 if (ud[k] == 1)
2225 ch[k] = ch[k] + 25;
2226 else if (ud[k] == 0)
2227 ch[k] = ch[k] - 5;
2228 else
2229 ch[k] = ch[k];
2230 }
2231
2232 if (ch[0] == 0)
2233 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0000, ch[0]);
2234 else
2235 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, ch[0]);
2236
2237 if (ch[1] == 0)
2238 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0000, ch[1]);
2239 else
2240 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, ch[1]);
2241
2242 if (ch[2] == 0)
2243 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0000, ch[2]);
2244 else
2245 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, ch[2]);
2246
2247 if (ch[3] == 0)
2248 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0000, ch[3]);
2249 else
2250 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, ch[3]);
2251
2252 if (ch[12] == 0)
2253 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0000, ch[12]);
2254 else
2255 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, ch[12]);
2256
2257 if (ch[13] == 0)
2258 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0000, ch[13]);
2259 else
2260 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, ch[13]);
2261
2262 if (ch[14] == 0)
2263 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0000, ch[14]);
2264 else
2265 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, ch[14]);
2266
2267 if (ch[15] == 0)
2268 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0000, ch[15]);
2269 else
2270 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, ch[15]);
2271
2272 if (ch[8] == 0)
2273 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0000, ch[8]);
2274 else
2275 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, ch[8]);
2276
2277 if (ch[9] == 0)
2278 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0000, ch[9]);
2279 else
2280 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, ch[9]);
2281
2282 if (ch[10] == 0)
2283 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0000, ch[10]);
2284 else
2285 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, ch[10]);
2286
2287 if (ch[11] == 0)
2288 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0000, ch[11]);
2289 else
2290 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, ch[11]);
2291
2292 if (ch[4] == 0)
2293 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0000, ch[4]);
2294 else
2295 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, ch[4]);
2296
2297 if (ch[5] == 0)
2298 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0000, ch[5]);
2299 else
2300 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, ch[5]);
2301
2302 if (ch[6] == 0)
2303 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0000, ch[6]);
2304 else
2305 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, ch[6]);
2306
2307 if (ch[7] == 0)
2308 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0000, ch[7]);
2309 else
2310 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, ch[7]);
2311
2312 analog_in = analogRead(A3);
2313 delay (analog_in / 24);
2314 }
2315
2316 // check to see if up, down, or wait and increment or change
2317 for (l = 0; l <= 15; l++)
2318 {
2319 if (ud[l] == 1 && ch[l] >= 250)
2320 {
2321 ud[l] = 0;
2322 waitcount[l]++;
2323 }
2324 else if (ud[l] == 2)
2325 {
2326 if (waitcount[l] >= 15)
2327 {
2328 ud[l] = 2;
2329 waitcount[l] = 0;
2330 }
2331 else
2332 waitcount[l]++;
2333 }
2334 else if (ud[l] == 0 && ch[l] <= 5)
2335 {
2336 ud[l] = 2;
2337 waitcount[l]++;
2338 }
2339 else
2340 {
2341 ud[l] = ud[l];
2342 waitcount[l]++;
2343 }
2344 }
2345 }
2346 }
2347
2348 //! Using the PWM dim WITH FADE commands, a wave of light is created by fading
2349 //! the LED brightnesses up and down. WITH FADE option uses the logarithmic
2350 //! fade function of the LT3965 and allows the brightness to fade from low to
2351 //! high or from high to low with a single I2C bus command. This pattern has
2352 //! low bus traffic.
2353 void fadewave()
2354 {
2355 setThresh();
2356
2357 int8_t ack = 0; // I2C acknowledge bit
2358 An0 = analogRead(A0); // Read 8 position switch pin 1
2359 An1 = analogRead(A1); // Read 8 position switch pin 2
2360 An2 = analogRead(A2); // Read 8 position switch pin 3
2361
2362 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0000, 1);
2363 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0000, 1);
2364 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0000, 1);
2365 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0000, 1);
2366 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0000, 1);
2367 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0000, 1);
2368 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0000, 1);
2369 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0000, 1);
2370 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0000, 1);
2371 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0000, 1);
2372 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0000, 1);
2373 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0000, 1);
2374 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0000, 1);
2375 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0000, 1);
2376 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0000, 1);
2377 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0000, 1);
2378 delay(250);
2379
2380 if (!startsequence)
2381 {
2382 digitalWrite(PWMPIN, HIGH);
2383 delay(30);
2384 digitalWrite(LOADPIN, LOW);
2385 delay(30);
2386 startsequence = TRUE;
2387 delay(150);
2388 }
2389
2390 while (An0 < 120 && An1 > 120 && An2 > 120)
2391 {
2392 An0 = analogRead(A0);
2393 An1 = analogRead(A1);
2394 An2 = analogRead(A2);
2395
2396 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0011, 255);
2397 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0011, 255);
2398 delay(200);
2399 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0011, 255);
2400 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0011, 255);
2401 delay(200);
2402 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0011, 255);
2403 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0011, 255);
2404 delay(200);
2405 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0011, 255);
2406 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0011, 255);
2407 delay(200);
2408 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0011, 255);
2409 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0011, 255);
2410 delay(200);
2411 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0011, 255);
2412 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0011, 255);
2413 delay(200);
2414 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0011, 255);
2415 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0011, 255);
2416 delay(200);
2417 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0011, 255);
2418 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0011, 255);
2419 delay(1000);
2420
2421 An0 = analogRead(A0);
2422 An1 = analogRead(A1);
2423 An2 = analogRead(A2);
2424
2425 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0011, 1);
2426 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0011, 1);
2427 delay(200);
2428 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0011, 1);
2429 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0011, 1);
2430 delay(200);
2431 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0011, 1);
2432 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0011, 1);
2433 delay(200);
2434 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0011, 1);
2435 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0011, 1);
2436 delay(200);
2437 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0011, 1);
2438 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0011, 1);
2439 delay(200);
2440 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0011, 1);
2441 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0011, 1);
2442 delay(200);
2443 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0011, 1);
2444 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0011, 1);
2445 delay(200);
2446 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0011, 1);
2447 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0011, 1);
2448 delay(1000);
2449
2450 An0 = analogRead(A0);
2451 An1 = analogRead(A1);
2452 An2 = analogRead(A2);
2453 }
2454 }
2455
2456 //! A wave of light from right to left and from left to right changing PWM
2457 //! dimming brightness quickly increasing and decreasing at rates that look
2458 //! like a wave running from one side of the LEDs to the other. The interactive
2459 //! potentiometer controls the speed of the wave.
2460 void wave() // wave function
2461 {
2462 setThresh();
2463
2464 int8_t ack = 0; // I2C acknowledge bit
2465 uint8_t i, j, k, l;
2466 int up_down = 1; //1 = up, 0 = down, 2 = startup wait, 3 = wait
2467 int delay_var = 20;
2468 uint8_t ch[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
2469 ; //channel count variables
2470 int ud[16] = {1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1}; //count up or down variables; 1 = up, 0 = down, 2 = wait
2471 int waitcount[16]; // wait count for unusued LEDs
2472 uint16_t analog_in; // potentiometer reading 0 - 255?
2473
2474 waitcount[0] = -8;
2475 waitcount[1] = 15;
2476 waitcount[2] = 14;
2477 waitcount[3] = 13;
2478 waitcount[4] = 12;
2479 waitcount[5] = 11;
2480 waitcount[6] = 10;
2481 waitcount[7] = 9;
2482 waitcount[8] = 9;
2483 waitcount[9] = 10;
2484 waitcount[10] = 11;
2485 waitcount[11] = 12;
2486 waitcount[12] = 13;
2487 waitcount[13] = 14;
2488 waitcount[14] = 15;
2489 waitcount[15] = -8;
2490
2491 /// start with this brightness
2492 // delay (1000);
2493 if (ch[0] == 0)
2494 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0000, ch[0]);
2495 else
2496 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, ch[0]);
2497
2498 if (ch[1] == 0)
2499 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0000, ch[1]);
2500 else
2501 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, ch[1]);
2502
2503 if (ch[2] == 0)
2504 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0000, ch[2]);
2505 else
2506 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, ch[2]);
2507
2508 if (ch[3] == 0)
2509 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0000, ch[3]);
2510 else
2511 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, ch[3]);
2512
2513
2514 if (ch[4] == 0)
2515 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0000, ch[4]);
2516 else
2517 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, ch[4]);
2518
2519 if (ch[5] == 0)
2520 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0000, ch[5]);
2521 else
2522 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, ch[5]);
2523
2524 if (ch[6] == 0)
2525 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0000, ch[6]);
2526 else
2527 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, ch[6]);
2528
2529 if (ch[7] == 0)
2530 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0000, ch[7]);
2531 else
2532 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, ch[7]);
2533
2534 if (ch[8] == 0)
2535 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0000, ch[8]);
2536 else
2537 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, ch[8]);
2538
2539 if (ch[9] == 0)
2540 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0000, ch[9]);
2541 else
2542 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, ch[9]);
2543
2544 if (ch[10] == 0)
2545 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0000, ch[10]);
2546 else
2547 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, ch[10]);
2548
2549 if (ch[11] == 0)
2550 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0000, ch[11]);
2551 else
2552 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, ch[11]);
2553
2554 if (ch[12] == 0)
2555 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0000, ch[12]);
2556 else
2557 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, ch[12]);
2558
2559 if (ch[13] == 0)
2560 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0000, ch[13]);
2561 else
2562 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, ch[13]);
2563
2564 if (ch[14] == 0)
2565 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0000, ch[14]);
2566 else
2567 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, ch[14]);
2568
2569 if (ch[15] == 0)
2570 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0000, ch[15]);
2571 else
2572 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, ch[15]);
2573
2574 if (!startsequence)
2575 {
2576 digitalWrite(PWMPIN, HIGH);
2577 delay(1);
2578 digitalWrite(LOADPIN, LOW);
2579 delay(1);
2580 startsequence = TRUE;
2581 }
2582 for (j = 0; j < 21; j++)
2583 {
2584 for (i = 0; i <= 4 ; i++)
2585 {
2586 for (k = 0; k <= 15; k++)
2587 {
2588 if (ud[k] == 1)
2589 ch[k] = ch[k] + 50;
2590 else if (ud[k] == 0)
2591 ch[k] = ch[k] - 5;
2592 else
2593 ch[k] = ch[k];
2594 }
2595
2596 if (ch[0] == 0)
2597 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0000, ch[0]);
2598 else
2599 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, ch[0]);
2600
2601 if (ch[1] == 0)
2602 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0000, ch[1]);
2603 else
2604 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, ch[1]);
2605
2606 if (ch[2] == 0)
2607 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0000, ch[2]);
2608 else
2609 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, ch[2]);
2610
2611 if (ch[3] == 0)
2612 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0000, ch[3]);
2613 else
2614 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, ch[3]);
2615
2616
2617 if (ch[4] == 0)
2618 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0000, ch[4]);
2619 else
2620 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, ch[4]);
2621
2622 if (ch[5] == 0)
2623 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0000, ch[5]);
2624 else
2625 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, ch[5]);
2626
2627 if (ch[6] == 0)
2628 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0000, ch[6]);
2629 else
2630 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, ch[6]);
2631
2632 if (ch[7] == 0)
2633 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0000, ch[7]);
2634 else
2635 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, ch[7]);
2636
2637 if (ch[8] == 0)
2638 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0000, ch[8]);
2639 else
2640 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, ch[8]);
2641
2642 if (ch[9] == 0)
2643 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0000, ch[9]);
2644 else
2645 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, ch[9]);
2646
2647 if (ch[10] == 0)
2648 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0000, ch[10]);
2649 else
2650 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, ch[10]);
2651
2652 if (ch[11] == 0)
2653 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0000, ch[11]);
2654 else
2655 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, ch[11]);
2656
2657 if (ch[12] == 0)
2658 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0000, ch[12]);
2659 else
2660 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, ch[12]);
2661
2662 if (ch[13] == 0)
2663 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0000, ch[13]);
2664 else
2665 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, ch[13]);
2666
2667 if (ch[14] == 0)
2668 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0000, ch[14]);
2669 else
2670 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, ch[14]);
2671
2672 if (ch[15] == 0)
2673 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0000, ch[15]);
2674 else
2675 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, ch[15]);
2676
2677 analog_in = analogRead(A3);
2678 delay (analog_in / 100);
2679 }
2680
2681 // check to see if up, down, or wait and increment or change
2682 for (l = 0; l <= 15; l++)
2683 {
2684 if (ud[l] == 1 && ch[l] >= 250)
2685 {
2686 ud[l] = 0;
2687 waitcount[l]++;
2688 }
2689 else if (ud[l] == 2)
2690 {
2691 if (waitcount[l] >= 15)
2692 {
2693 ud[l] = 1;
2694 waitcount[l] = -8;
2695 }
2696 else
2697 waitcount[l]++;
2698 }
2699 else if (ud[l] == 0 && ch[l] <= 5)
2700 {
2701 ud[l] = 2;
2702 waitcount[l]++;
2703 }
2704 else
2705 {
2706 ud[l] = ud[l];
2707 waitcount[l]++;
2708 }
2709 }
2710 }
2711 // delay (1000);
2712 delay(50);
2713 // Run Wave Backwards
2714 waitcount[0] = 9;
2715 waitcount[1] = 10;
2716 waitcount[2] = 11;
2717 waitcount[3] = 12;
2718 waitcount[4] = 13;
2719 waitcount[5] = 14;
2720 waitcount[6] = 15;
2721 waitcount[7] = -8;
2722 waitcount[8] = -8;
2723 waitcount[9] = 15;
2724 waitcount[10] = 14;
2725 waitcount[11] = 13;
2726 waitcount[12] = 12;
2727 waitcount[13] = 11;
2728 waitcount[14] = 10;
2729 waitcount[15] = 9;
2730
2731
2732 ud[0] = 2;
2733 ud[1] = 2;
2734 ud[2] = 2;
2735 ud[3] = 2;
2736 ud[4] = 2;
2737 ud[5] = 2;
2738 ud[6] = 2;
2739 ud[7] = 1;
2740 ud[8] = 1;
2741 ud[9] = 2;
2742 ud[10] = 2;
2743 ud[11] = 2;
2744 ud[12] = 2;
2745 ud[13] = 2;
2746 ud[14] = 2;
2747 ud[15] = 2;
2748
2749
2750 /// start with this brightness
2751 if (ch[0] == 0)
2752 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0000, ch[0]);
2753 else
2754 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, ch[0]);
2755
2756 if (ch[1] == 0)
2757 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0000, ch[1]);
2758 else
2759 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, ch[1]);
2760
2761 if (ch[2] == 0)
2762 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0000, ch[2]);
2763 else
2764 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, ch[2]);
2765
2766 if (ch[3] == 0)
2767 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0000, ch[3]);
2768 else
2769 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, ch[3]);
2770
2771
2772 if (ch[4] == 0)
2773 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0000, ch[4]);
2774 else
2775 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, ch[4]);
2776
2777 if (ch[5] == 0)
2778 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0000, ch[5]);
2779 else
2780 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, ch[5]);
2781
2782 if (ch[6] == 0)
2783 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0000, ch[6]);
2784 else
2785 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, ch[6]);
2786
2787 if (ch[7] == 0)
2788 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0000, ch[7]);
2789 else
2790 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, ch[7]);
2791
2792 if (ch[8] == 0)
2793 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0000, ch[8]);
2794 else
2795 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, ch[8]);
2796
2797 if (ch[9] == 0)
2798 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0000, ch[9]);
2799 else
2800 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, ch[9]);
2801
2802 if (ch[10] == 0)
2803 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0000, ch[10]);
2804 else
2805 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, ch[10]);
2806
2807 if (ch[11] == 0)
2808 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0000, ch[11]);
2809 else
2810 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, ch[11]);
2811
2812 if (ch[12] == 0)
2813 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0000, ch[12]);
2814 else
2815 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, ch[12]);
2816
2817 if (ch[13] == 0)
2818 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0000, ch[13]);
2819 else
2820 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, ch[13]);
2821
2822 if (ch[14] == 0)
2823 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0000, ch[14]);
2824 else
2825 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, ch[14]);
2826
2827 if (ch[15] == 0)
2828 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0000, ch[15]);
2829 else
2830 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, ch[15]);
2831
2832 for (j = 0; j < 21; j++)
2833 {
2834 for (i = 0; i <= 4; i++)
2835 {
2836 for (k = 0; k <= 15; k++)
2837 {
2838 if (ud[k] == 1)
2839 ch[k] = ch[k] + 50;
2840 else if (ud[k] == 0)
2841 ch[k] = ch[k] - 5;
2842 else
2843 ch[k] = ch[k];
2844 }
2845
2846 if (ch[0] == 0)
2847 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0000, ch[0]);
2848 else
2849 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0010, ch[0]);
2850
2851 if (ch[1] == 0)
2852 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0000, ch[1]);
2853 else
2854 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0010, ch[1]);
2855
2856 if (ch[2] == 0)
2857 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0000, ch[2]);
2858 else
2859 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0010, ch[2]);
2860
2861 if (ch[3] == 0)
2862 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0000, ch[3]);
2863 else
2864 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0010, ch[3]);
2865
2866 if (ch[4] == 0)
2867 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0000, ch[4]);
2868 else
2869 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0010, ch[4]);
2870
2871 if (ch[5] == 0)
2872 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0000, ch[5]);
2873 else
2874 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0010, ch[5]);
2875
2876 if (ch[6] == 0)
2877 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0000, ch[6]);
2878 else
2879 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0010, ch[6]);
2880
2881 if (ch[7] == 0)
2882 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0000, ch[7]);
2883 else
2884 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0010, ch[7]);
2885
2886 if (ch[8] == 0)
2887 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0000, ch[8]);
2888 else
2889 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0010, ch[8]);
2890
2891 if (ch[9] == 0)
2892 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0000, ch[9]);
2893 else
2894 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0010, ch[9]);
2895
2896 if (ch[10] == 0)
2897 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0000, ch[10]);
2898 else
2899 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0010, ch[10]);
2900
2901 if (ch[11] == 0)
2902 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0000, ch[11]);
2903 else
2904 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0010, ch[11]);
2905
2906 if (ch[12] == 0)
2907 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0000, ch[12]);
2908 else
2909 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0010, ch[12]);
2910
2911 if (ch[13] == 0)
2912 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0000, ch[13]);
2913 else
2914 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0010, ch[13]);
2915
2916 if (ch[14] == 0)
2917 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0000, ch[14]);
2918 else
2919 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0010, ch[14]);
2920
2921 if (ch[15] == 0)
2922 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0000, ch[15]);
2923 else
2924 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0010, ch[15]);
2925
2926 analog_in = analogRead(A3);
2927 delay (analog_in / 100);
2928 }
2929
2930 // check to see if up, down, or wait and increment or change
2931 for (l = 0; l <= 15; l++)
2932 {
2933 if (ud[l] == 1 && ch[l] >= 250)
2934 {
2935 ud[l] = 0;
2936 waitcount[l]++;
2937 }
2938 else if (ud[l] == 2)
2939 {
2940 if (waitcount[l] >= 15)
2941 {
2942 ud[l] = 1;
2943 waitcount[l] = -8;
2944 }
2945 else
2946 waitcount[l]++;
2947 }
2948 else if (ud[l] == 0 && ch[l] <= 5)
2949 {
2950 ud[l] = 2;
2951 waitcount[l]++;
2952 }
2953 else
2954 {
2955 ud[l] = ud[l];
2956 waitcount[l]++;
2957 }
2958 }
2959 }
2960
2961 }
2962
2963
2964 //! Performs an analog read on the potentiometer pin using hysteresis to
2965 //! reduce variation in ADC values. This prevents the read value of the potentiomter
2966 //! from bouncing between different values when the potentiometer is not
2967 //! being moved.
2968 int readpot(void)
2969 {
2970 uint8_t tempupdown;
2971 currentread = analogRead(A3);
2972
2973 if ((currentread - lastread) > 0)
2974 tempupdown = UP;
2975 if ((currentread - lastread) < 0)
2976 tempupdown = DOWN;
2977
2978 if (tempupdown == updown)
2979 {
2980 lastread = currentread;
2981 return (lastread);
2982 }
2983 else
2984 {
2985 if (((abs(currentread - lastread)) > 3))
2986 {
2987 if (updown == UP)
2988 updown = DOWN;
2989 else if (updown == DOWN)
2990 updown = UP;
2991 lastread = currentread;
2992 return (lastread);
2993 }
2994 else
2995 {
2996 return (lastread);
2997 }
2998 }
2999 }
3000
3001 //! Sets the short circuit and open circuit thresholds defined for
3002 //! DC2218A. This function performs a series of single channel and all
3003 //! channel writes to ensure that threshold registers are set, as well
3004 //! as ensuring all fault registers are cleared.
3005 void setThresh()
3006 {
3007 int8_t ack = 0;
3008
3009 ack |= i2c_scwriteshort(address1, CHANNEL0, 0b0000);
3010 ack |= i2c_scwriteshort(address1, CHANNEL1, 0b0000);
3011 ack |= i2c_scwriteshort(address1, CHANNEL2, 0b0000);
3012 ack |= i2c_scwriteshort(address1, CHANNEL3, 0b0000);
3013 ack |= i2c_scwriteshort(address1, CHANNEL4, 0b0000);
3014 ack |= i2c_scwriteshort(address1, CHANNEL5, 0b0000);
3015 ack |= i2c_scwriteshort(address1, CHANNEL6, 0b0000);
3016 ack |= i2c_scwriteshort(address1, CHANNEL7, 0b0000);
3017
3018 ack |= i2c_scwriteshort(address2, CHANNEL0, 0b0000);
3019 ack |= i2c_scwriteshort(address2, CHANNEL1, 0b0000);
3020 ack |= i2c_scwriteshort(address2, CHANNEL2, 0b0000);
3021 ack |= i2c_scwriteshort(address2, CHANNEL3, 0b0000);
3022 ack |= i2c_scwriteshort(address2, CHANNEL4, 0b0000);
3023 ack |= i2c_scwriteshort(address2, CHANNEL5, 0b0000);
3024 ack |= i2c_scwriteshort(address2, CHANNEL6, 0b0000);
3025 ack |= i2c_scwriteshort(address2, CHANNEL7, 0b0000);
3026
3027 ack |= i2c_scwritelong(address1, CHANNEL0, 0b0000, 0);
3028 ack |= i2c_scwritelong(address1, CHANNEL1, 0b0000, 0);
3029 ack |= i2c_scwritelong(address1, CHANNEL2, 0b0000, 0);
3030 ack |= i2c_scwritelong(address1, CHANNEL3, 0b0000, 0);
3031 ack |= i2c_scwritelong(address1, CHANNEL4, 0b0000, 0);
3032 ack |= i2c_scwritelong(address1, CHANNEL5, 0b0000, 0);
3033 ack |= i2c_scwritelong(address1, CHANNEL6, 0b0000, 0);
3034 ack |= i2c_scwritelong(address1, CHANNEL7, 0b0000, 0);
3035
3036 ack |= i2c_scwritelong(address2, CHANNEL0, 0b0000, 0);
3037 ack |= i2c_scwritelong(address2, CHANNEL1, 0b0000, 0);
3038 ack |= i2c_scwritelong(address2, CHANNEL2, 0b0000, 0);
3039 ack |= i2c_scwritelong(address2, CHANNEL3, 0b0000, 0);
3040 ack |= i2c_scwritelong(address2, CHANNEL4, 0b0000, 0);
3041 ack |= i2c_scwritelong(address2, CHANNEL5, 0b0000, 0);
3042 ack |= i2c_scwritelong(address2, CHANNEL6, 0b0000, 0);
3043 ack |= i2c_scwritelong(address2, CHANNEL7, 0b0000, 0);
3044
3045 ack |= i2c_acwrite(address1, 0b00000000);
3046 ack |= i2c_acwrite(address2, 0b00000000);
3047 }
3048
GraphicUI
static void GraphicUI()
Function to talk to GUI.
Definition: DC2218A.ino:379
ret
long ret
Definition: EVAL-AD7124-8.ino:145
lastread
static int lastread
Definition: DC2218A.ino:102
An1
static int16_t An1
Definition: DC2218A.ino:107
CHANNEL0
#define CHANNEL0
Definition: LT3965.h:91
setup
static void setup()
Initialize Linduino.
Definition: DC2218A.ino:137
CHANNEL4
#define CHANNEL4
Definition: LT3965.h:95
inputByte_0
static uint8_t inputByte_0
Definition: DC2218A.ino:108
orbit
static void orbit()
LEDs illuminate around the outside of the board, giving the effect of a comet with a tail traveling a...
Definition: DC2218A.ino:1715
FALSE
#define FALSE
Definition: LT3965.h:105
DOWN
#define DOWN
Definition: LT3965.h:102
readpot
static int readpot()
Performs an analog read on the potentiometer pin using hysteresis to reduce variation in ADC values...
Definition: DC2218A.ino:2968
Linduino.h
Header File for Linduino Libraries and Demo Code.
UP
#define UP
Definition: LT3965.h:101
inputByte_2
static uint8_t inputByte_2
Definition: DC2218A.ino:110
CHANNEL3
#define CHANNEL3
Definition: LT3965.h:94
input
static uint8_t input
Definition: DC2218A.ino:114
dazzle
static void dazzle()
Consecutive LEDs alternate fading up and down.
Definition: DC2218A.ino:806
channel
static uint8_t channel
LTC2305 Channel selection.
Definition: DC1444A.ino:127
HARDWARE_I2C_PRESCALER_1
#define HARDWARE_I2C_PRESCALER_1
Definition: LT_I2C.h:53
wave
static void wave()
A wave of light from right to left and from left to right changing PWM dimming brightness quickly inc...
Definition: DC2218A.ino:2460
i2c_stop
void i2c_stop()
Write stop bit to the hardware I2C port.
Definition: LT_I2C.cpp:462
write_bytes
static int8_t write_bytes(uint8_t size, uint8_t byte1, uint8_t byte2, uint8_t byte3)
Function to write I2C bytes which are received from GUI.
Definition: DC2218A.ino:305
loop
static void loop()
Repeats Linduino loop.
Definition: DC2218A.ino:237
ALERTPIN
#define ALERTPIN
Definition: LT3965.h:107
PWMPIN
#define PWMPIN
Definition: LT3965.h:108
i2c_start
int8_t i2c_start()
Write start bit to the hardware I2C port.
Definition: LT_I2C.cpp:425
inputByte_1
static uint8_t inputByte_1
Definition: DC2218A.ino:109
read_bytes
static int8_t read_bytes(uint8_t size, uint8_t byte1, uint8_t byte2, uint8_t byte3)
Function to read I2C bytes depending on the bytes received from GUI.
Definition: DC2218A.ino:335
An0
static int16_t An0
Definition: DC2218A.ino:107
data
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
WITH_NACK
#define WITH_NACK
Use with i2c_read(WITH_NACK) to read without an acknowledge.
Definition: LT_I2C.h:91
CHANNEL5
#define CHANNEL5
Definition: LT3965.h:96
CHANNEL7
#define CHANNEL7
Definition: LT3965.h:98
address2
#define address2
Definition: LT3965.h:81
startup
static uint8_t startup
Definition: DC2218A.ino:121
i2c_scwriteshort
int8_t i2c_scwriteshort(uint8_t address, uint8_t channel, uint8_t data_SCMREG)
SCMODE Write Command Short Format to write a "value" byte to device at "address". ...
Definition: LT3965.cpp:93
i2c_write
int8_t i2c_write(uint8_t data)
Send a data byte to hardware I2C port.
Definition: LT_I2C.cpp:470
fadewave
static void fadewave()
Using the PWM dim WITH FADE commands, a wave of light is created by fading the LED brightnesses up an...
Definition: DC2218A.ino:2353
updown
static uint8_t updown
Definition: DC2218A.ino:101
interval
long interval
Definition: DC2218A.ino:122
pulse
static void pulse()
previousTime
long previousTime
Definition: DC2218A.ino:123
BUTTONPIN
#define BUTTONPIN
Definition: LT3965.h:110
startsequence
bool startsequence
Definition: DC2218A.ino:119
inputByte_3
static uint8_t inputByte_3
Definition: DC2218A.ino:111
steeringRightAndLeft
static void steeringRightAndLeft()
Center headlight LEDs stay on to face directly forward while the right and left side LEDs turn on wit...
Definition: DC2218A.ino:856
LT3965.h
LT3965 - Octal Matrix LED Bypass Switch.
analogAuto
static void analogAuto()
Func Desc: All LEDs illuminated to the same brightness level depending on potentiometer value...
Definition: DC2218A.ino:502
i2c_acwrite
int8_t i2c_acwrite(uint8_t address, uint8_t value)
ACMODE Write Command to write a "value" byte to device at "address".
Definition: LT3965.cpp:73
sectionalBlanking
static void sectionalBlanking()
All LEDs are illluminated to full brightness simulating a car with its high-beams turned on...
Definition: DC2218A.ino:991
LT_I2C.h
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
fade
static uint8_t fade
Definition: DC2218A.ino:115
REDLED
#define REDLED
Definition: LT3965.h:111
CHANNEL6
#define CHANNEL6
Definition: LT3965.h:97
LOADPIN
#define LOADPIN
Definition: LT3965.h:109
sidebend
static void sidebend()
Func Desc: Varying number of brightened LEDs depending on pot.
Definition: DC2218A.ino:1256
LT3965_i2c_enable
static void LT3965_i2c_enable()
Definition: DC2218A.ino:129
ledState
static uint8_t ledState
Definition: DC2218A.ino:124
i2c_scwritelong
int8_t i2c_scwritelong(uint8_t address, uint8_t channel, uint8_t data_SCMREG, uint8_t dimming_value)
SCMODE Write Command Long Format to write 2 "value" bytes to device at "address". ...
Definition: LT3965.cpp:107
x
int32_t x
Definition: LTC2492_Thermocouple_Meter.ino:119
currentread
static int currentread
Definition: DC2218A.ino:103
i2c_read
uint8_t i2c_read(int8_t ack)
Read a data byte from the hardware I2C port.
Definition: LT_I2C.cpp:491
An2
static int16_t An2
Definition: DC2218A.ino:107
CHANNEL1
#define CHANNEL1
Definition: LT3965.h:92
quikeval_I2C_connect
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
Definition: LT_I2C.cpp:401
i
static int i
Definition: DC2430A.ino:184
analog
static void analog()
Func Desc: All LEDs lighted up to the same level depending on pot value.
Definition: DC2218A.ino:1562
WITH_ACK
#define WITH_ACK
Use with i2c_read(WITH_ACK) to read with an acknowledge.
Definition: LT_I2C.h:90
TRUE
#define TRUE
Definition: LT3965.h:104
address1
#define address1
Definition: LT3965.h:80
CHANNEL2
#define CHANNEL2
Definition: LT3965.h:93
values
static uint8_t values[4]
Definition: DC2218A.ino:117
setThresh
static void setThresh()
Sets the short circuit and open circuit thresholds defined for DC2218A.
Definition: DC2218A.ino:3005
sidebendAuto
static void sidebendAuto()
All sixteen LEDs adjust PWM dimming duty cycle and brightness based upon the position of the steering...
Definition: DC2218A.ino:594
inputByte_4
static uint8_t inputByte_4
Definition: DC2218A.ino:112