Hardware components | ||||||
![]() |
| × | 1 | |||
| × | 1 | ||||
| × | 1 | ||||
![]() |
| × | 1 | |||
Software apps and online services | ||||||
![]() |
| |||||
The main goal of the project is to show one of the possible applications of the Octowide digital light modules. This modules can be purchased on Ebay with wattages of 1W, 2W, 3W and 2 different color temperatures: Warm White 2700K and Cold White 5000K.
Each module has multiple pads to solder wires and/or connect to other modules. On each side you can find 12V / GND / 3.3V Signal to connect to a uC (like the Arduino) and PWM control each module (or group of modules).
In this application we used 4 modules (2 Warm / 2 Cold White) so that we could tweak the color temperature also.
You will find all the technical details regarding the Octowide Light digital modules on the datasheet, available at: http://www.octowide.com/octowide-light-datasheet-en.pdf
Octowide Digital Light - 2 Warm x 2 Cold
C/C++/* octowide.com Example
2 Warm White Octowide x 2 Cold White Octowide Light 3W modules Demo
[email protected]
Get Library at: https://github.com/shirriff/Arduino-IRremote
Unzip folder into Libraries. RENAME folder IRremote
*/
/*-----( Import needed libraries )-----*/
/* Get Library at: https://github.com/shirriff/Arduino-IRremote
Unzip folder into Libraries. RENAME folder IRremote
NOTE!! If you have a late version of Arduino with a library IRRobotRemote, it may conflict and you may have to remove that library.
Make sure to delete Arduino_Root/libraries/RobotIRremote.
Where Arduino_Root refers to the install directory of Arduino. The library RobotIRremote has similar definitions to IRremote and causes errors.
*/
#include "IRremote.h"
/*-----( Declare Constants )-----*/
const int ir_receiver = 12; // pin 1 of IR receiver to Arduino digital pin 12
/*-----( Declare objects )-----*/
IRrecv irrecv(ir_receiver); // create instance of 'irrecv'
decode_results results; // create instance of 'decode_results'
/*-----( Declare Variables )-----*/
int Warm_White_Level = 0; // brightness level of Octowide Warm White (0 - 255)
int New_Warm_White_Level = 0; // new brightness level of Octowide Warm White (0 - 255)
int Cold_White_Level = 0; // brightness level of Octowide Cold White (0 - 255)
int New_Cold_White_Level = 0; // new brightness level of Octowide Cold White (0 - 255)
int Step = 1; // brightness update step - 1 for the slowest transition to 255 for immediate transition
enum channel
{
WARM_WHITE = 9, // Arduino Digital pin 9 connected to Octowide (Warm White) Signal pin
COLD_WHITE = 10 // Arduino Digital pin 10 connected to Octowide (Cold White) Signal pin
};
enum channel channel_selected = WARM_WHITE; // Default Channel selected
void setup() /*----( SETUP: RUNS ONCE )----*/
{
analogWrite(WARM_WHITE, Warm_White_Level); // Set initial Warm White Level
analogWrite(COLD_WHITE, Cold_White_Level); // Set initial Cold White Level
Serial.begin(9600);
Serial.println("Octowide 2 Warm x 2 Cold Demo");
Serial.println("More Info: [email protected]");
irrecv.enableIRIn(); // Start the infrared receiver
}
void loop() /*----( LOOP: RUNS CONSTANTLY )----*/
{
static int cnt = 0;
if (cnt++ == 5) // Check for a new IR once each 50ms
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
translateIR();
irrecv.resume(); // receive the next value
}
cnt = 0;
}
// Update Warm White Channel (if needed)
if (Warm_White_Level != New_Warm_White_Level)
update_level(WARM_WHITE, Warm_White_Level, New_Warm_White_Level);
// Update Cold White Channel (if needed)
if (Cold_White_Level != New_Cold_White_Level)
update_level(COLD_WHITE, Cold_White_Level, New_Cold_White_Level);
delay(10); // Wait a bit
}
/*-----( Declare User-written Functions )-----*/
/* Low level brightness update function */
void update_level(enum channel ch, int &level, int &new_level)
{
if (level < new_level)
{
level += Step;
if (level > new_level)
level = new_level;
} else {
level -= Step;
if (level < new_level)
level = new_level;
}
analogWrite(ch, level);
}
/* Function stating what to do when receiving an IR code
* 1 - Warm White channel selected
* 2 - Cold White channel selected
* UP - increase brightness by aprox. 20% (on the channel selected)
* DWN - decrease brightness by aprox. 20% (on the channel selected)
* 0 - Fade down both channels
* 4 - Max Brightness Warm White channel
* 5 - Max Brightness Both channels
* 6 - Max Brightness Cold White channel
* 7 - Slow Fade (transition)
* 8 - Fast Fade (transition)
* 9 - No Fade
* Code received / action taken sent by serial port
*/
void translateIR() // takes action based on IR code received
// describing KEYES Remote IR codes
{
int level;
switch(results.value)
{
case 0xFF6897: Serial.println("WARM WHITE channel selected");
channel_selected = WARM_WHITE;
break;
case 0xFF9867: Serial.println("COLD WHITE channel selected");
channel_selected = COLD_WHITE;
break;
case 0xFF629D: Serial.println("UP 20%");
if (channel_selected == WARM_WHITE)
fade_channels(Warm_White_Level + 51, Cold_White_Level);
else fade_channels(Warm_White_Level, Cold_White_Level + 51);
break;
case 0xFFA857: Serial.println("DOWN 20%");
if (channel_selected == WARM_WHITE)
fade_channels(Warm_White_Level - 51, Cold_White_Level);
else fade_channels(Warm_White_Level, Cold_White_Level - 51);
break;
case 0xFF4AB5: Serial.println("Fade DOWN");
fade_channels(0, 0);
break;
case 0xFF30CF: Serial.println("MAX Warm White");
fade_channels(255, 0);
break;
case 0xFF18E7: Serial.println("MAX Both channels");
fade_channels(255, 255);
break;
case 0xFF7A85: Serial.println("MAX Cold White");
fade_channels(0, 255);
break;
case 0xFF10EF: Serial.println("SLOW fade");
Step = 1;
break;
case 0xFF38C7: Serial.println("FAST fade");
Step = 4;
break;
case 0xFF5AA5: Serial.println("NO fade");
Step = 255;
break;
}
}
/* Update global new brightness values to start fading
* Serial print of start and new brightness for each channel
*/
void fade_channels(int new_warm_level, int new_cold_level)
{
char buf[32];
// Sanitize both levels
New_Warm_White_Level = sanitize_level(new_warm_level);
New_Cold_White_Level = sanitize_level(new_cold_level);
sprintf(buf, "WARM %3d > %3d | COLD %3d > %3d", Warm_White_Level, New_Warm_White_Level, Cold_White_Level, New_Cold_White_Level);
Serial.println(buf);
}
/* Check the boundaries - max / min allowable brightness levels */
int sanitize_level(int level)
{
if (level > 255)
return 255;
else if (level < 0)
return 0;
return level;
}
/* ( THE END ) */



_ztBMuBhMHo.jpg?auto=compress%2Cformat&w=48&h=48&fit=fill&bg=ffffff)




Comments