//set up command lines tools:
//./arduino-cli.exe core install arduino:samd
//./arduino-cli.exe core list
//to compile and upload ./arduino-cli.exe compile './main/main.ino'
#include <IRremote.hpp>
// #include <IRLibRecvPCI.h>
//needed libraries for the RTC module for the arduino
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
bool demoView = false;
//create our IRsender object with IRremote.hpp
IRsend irSender;
int currentMinute = -1;
//RAW BUFFERS FOR YOUR REMOTE GOES HERE
static uint16_t pBtnRawBuffer[68]={
8910, 4578, 482, 1762, 478, 654, 478, 658, 478,
650, 482, 654, 478, 654, 482, 654, 478, 654, 478,
654, 478, 1762, 478, 1762, 478, 1766, 478,
1758, 478, 1786, 458, 1786, 454, 1762, 478,
654, 478, 654, 478, 658, 478, 654, 478, 654, 478,
654, 478, 658, 478, 654, 478, 1762, 478, 1762, 478,
1762, 478, 1762, 478, 1762, 478, 1762, 478, 1762,
478, 1762, 478, 1000};
static uint16_t m1RawBuffer[68]={
8914, 4582, 478, 1762, 478, 654, 478, 682,
450, 658, 478, 654, 478, 654, 478, 658,
474, 662, 474, 654, 478, 1762, 478, 1762,
478, 1762, 478, 1762, 478, 1762, 478, 1762,
478, 1762, 478, 654, 478, 1762, 478, 1762,
478, 1762, 478, 1762, 478, 654, 478, 654,
478, 658, 478, 1762, 478, 654, 478, 654,
478, 658, 478, 654, 478, 1762, 478, 1762,
478, 1762, 478, 1000};
static uint16_t m2RawBuffer[68]={
8934, 4562, 498, 1738, 506, 634, 498, 634,
498, 634, 502, 630, 502, 630, 502, 634,
502, 630, 502, 634, 498, 1742, 498, 1738,
506, 1738, 502, 1734, 506, 1738, 502, 1734,
506, 1734, 506, 1738, 502, 1738, 502, 1766,
474, 1738, 502, 1742, 498, 630, 506, 630,
502, 634, 498, 630, 502, 634, 502, 630,
502, 630, 502, 658, 478, 1738, 502, 1734,
502, 1738, 502, 1000};
static uint16_t m3RawBuffer[68]={
8930, 4566, 498, 1742, 498, 634, 498, 638,
494, 638, 498, 634, 498, 638, 494, 638,
498, 634, 498, 662, 470, 1746, 494, 1746,
494, 1746, 494, 1746, 494, 1746, 494, 1750,
490, 1750, 490, 1750, 490, 642, 494, 1746,
494, 1770, 470, 1746, 494, 638, 494, 1746,
494, 638, 494, 666, 470, 1746, 494, 638,
494, 642, 490, 642, 490, 1774, 470, 638,
494, 1746, 494, 1000};
static uint16_t m4RawBuffer[68]={
8886, 4582, 478, 1762, 478, 658, 474, 658, 478, 678, 454, 658, 474, 658, 478, 678, 454, 658, 474, 658, 478, 1766, 474, 1790, 450, 1766, 474, 1766, 478, 1762, 478, 1762, 478, 1766, 474, 658, 478, 658, 474, 1762, 478, 1766, 474, 1766, 478, 658, 474, 1762, 478, 658, 478, 1762, 478, 1762, 478, 678, 454, 658, 474, 658, 478, 1762, 478, 654, 478, 1766, 478, 1000};
static uint16_t whiteChannel[68]={
8906, 4586, 474, 1766, 474, 662, 470, 686, 450, 658, 474, 670, 470, 654, 474, 654, 478, 666, 474, 650, 474, 1766, 474, 1766, 474, 1778, 462, 1774, 466, 1766, 474, 1790, 450, 1766, 474, 658, 478, 1762, 478, 1762, 474, 682, 454, 1766, 474, 658, 474, 658, 482, 654, 474, 1762, 478, 658, 474, 682, 450, 1766, 482, 654, 478, 1758, 478, 1762, 474, 1766, 478, 1000};
static uint16_t whiteChannelDown[68]={
8886, 4582, 478, 1762, 478, 654, 482, 654, 478, 654, 478, 654, 478, 658, 478, 678, 454, 658, 474, 658, 478, 1762, 478, 1762, 478, 1762, 478, 1762, 478, 1762, 478, 1762, 478, 1762, 482, 654, 478, 1786, 454, 654, 478, 1766, 478, 1786, 454, 654, 478, 654, 478, 658, 478, 1762, 478, 658, 474, 1766, 478, 654, 478, 654, 478, 1762, 478, 1762, 482, 1762, 478, 1000};
static uint16_t redChannelDown[68]={
8910, 4578, 482, 1758, 482, 650, 482, 654, 482, 650, 482, 650, 482, 654, 478, 678, 454, 654, 482, 650, 482, 1758, 482, 1758, 482, 1758, 482, 1754, 482, 1762, 478, 1762, 478, 1782, 458, 1758, 482, 1758, 482, 650, 482, 1758, 482, 1758, 482, 650, 482, 650, 482, 654, 478, 654, 482, 650, 482, 1758, 482, 654, 478, 650, 486, 1758, 478, 1758, 482, 1762, 478, 1000};
static uint16_t redChannelUp[68]={
8918, 4574, 486, 1758, 482, 650, 482, 650, 482, 650, 482, 650, 486, 646, 486, 650, 482, 646, 486, 650, 486, 1754, 486, 1754, 486, 1754, 486, 1758, 482, 1758, 482, 1758, 482, 1758, 478, 1758, 482, 1758, 482, 1758, 482, 650, 486, 1758, 482, 650, 482, 650, 482, 650, 486, 650, 482, 646, 486, 650, 482, 1758, 482, 650, 486, 1758, 482, 1754, 486, 1754, 486, 1000};
static uint16_t blueChannelUp[68]={
8906, 4578, 478, 1786, 454, 654, 478, 654, 478, 654, 478, 658, 474, 654, 478, 654, 478, 658, 474, 658, 478, 1758, 478, 1762, 478, 1762, 478, 1762, 474, 1762, 478, 1762, 478, 1758, 478, 658, 474, 682, 454, 1758, 478, 658, 474, 1762, 478, 654, 478, 1786, 454, 654, 478, 1762, 478, 1762, 478, 654, 478, 1786, 450, 658, 478, 1762, 474, 654, 478, 1762, 478, 1000};
static uint16_t blueChannelDown[68]={
8910, 4574, 482, 1754, 486, 650, 482, 650, 486, 646, 486, 646, 486, 650, 482, 674, 458, 650, 486, 646, 486, 1778, 462, 1754, 482, 1754, 486, 1754, 486, 1754, 486, 1750, 486, 1758, 482, 650, 486, 646, 486, 646, 486, 1754, 486, 1754, 486, 646, 486, 1754, 482, 650, 486, 1754, 482, 1754, 486, 1778, 462, 646, 486, 650, 482, 1758, 482, 646, 486, 1754, 482, 1000};
void setup() {
Serial.begin(9600);
irSender.begin(3);
//irReciever.enableIRIn();
}
void loop() {
tmElements_t time;
if(RTC.read(time) && demoView == false){
int hour = time.Hour;
int minute = time.Minute;
setMode(hour, minute);
}else{
demoSchedule();
}
// decrementWhiteChannelFinnex();
delay(5000);
}
void repeatKey(unsigned int repeat){
static uint16_t repeatCommand[4]={
8878, 2370, 446, 1000
};
delay(10);
unsigned int i = 0;
do{
sendData(repeatCommand, sizeof(repeatCommand), sizeof(repeatCommand[0]), 68);
i++;
} while (i < repeat);
}
void incrementChannelFinnex(uint16_t *dataBuffPTR, int arrSize, int sizeOfFirstElement, int khz){
//oh finnex lights, first buffer commands white, then subsequent smaller buffers indicates hold down to incremement brightness gradually
irSender.sendRaw(dataBuffPTR, arrSize / sizeOfFirstElement, khz);
repeatKey(14);
}
void incrementWhiteChannelFinnex(){
incrementChannelFinnex(whiteChannel, sizeof(whiteChannel), sizeof(whiteChannel[0]), 68);
}
void decrementWhiteChannelFinnex(){
incrementChannelFinnex(whiteChannelDown, sizeof(whiteChannelDown), sizeof(whiteChannelDown[0]), 68);
}
void incrementRedChannelFinnex(){
incrementChannelFinnex(redChannelUp, sizeof(redChannelUp), sizeof(redChannelUp[0]), 68);
}
void decrementRedChannelFinnex(){
incrementChannelFinnex(redChannelDown, sizeof(redChannelDown), sizeof(redChannelDown[0]), 68);
}
void incrementBlueChannelFinnex(){
incrementChannelFinnex(blueChannelUp, sizeof(blueChannelUp), sizeof(blueChannelUp[0]), 68);
}
void decrementBlueChannelFinnex(){
incrementChannelFinnex(blueChannelDown, sizeof(blueChannelDown), sizeof(blueChannelDown[0]), 68);
}
void sendData(uint16_t *dataBuffPTR, int arrSize, int sizeOfFirstElement, int khz){
irSender.sendRaw(dataBuffPTR, arrSize / sizeOfFirstElement, khz);
}
void setMode(int hour, int minute){
Serial.print(hour);
Serial.print(", ");
Serial.print(minute);
Serial.println("");
if(currentMinute != minute){
currentMinute = minute;
//**YOUR CODE GOES HERE**
}
}
void demoSchedule(){
for( int hour = 10; hour < 24; hour++){
for(int minute = 0; minute < 60; minute++){
setMode(hour, minute);
delay(50);
}
}
}