TheReefNinja
Imagination superfreak
ok so elaborate on this ir code you got working could you post the sketch somewhere?
/*
* GLCDexample
*
* Basic test code for the Arduino KS0108 GLCD library.
* This code exercises a range of graphic functions supported
* by the library and is an example of its use.
* It also gives an indication of performance, showing the
* number of frames drawn per second.
*/
#include <ks0108.h>
#include "Arial14.h" // proportional font
#include "SystemFont5x7.h" // system font
//#include "ArduinoIcon.h" // bitmap
#include "SunRise.h" // bitmap
#include "SunSet.h" // bitmap
#include "SunUp.h" // bitmap
#include "Dawn.h" // bitmap
#include "Dusk.h" // bitmap
#include "MoonUp.h" // bitmap
#include "seahorse.h" // bitmap
#include "seahorse2.h" // bitmap
#define DS1307_I2C_ADDRESS 0x68 //set rtc
#include "Wire.h"
#include "RTClib.h"
#include <IRremote.h>
RTC_Millis RTC;
unsigned long startMillis;
unsigned int loops = 0;
unsigned int iter = 0;
//int RECV_PIN = 9;
//IRrecv irrecv(RECV_PIN);
decode_results results;
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| R E L A Y P A R T |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| S I M P L E O N A N D O F F F E A T U R E |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
const int ledPin1 = 2; // pin number for relay 1
const int ledPin2 = 8; // pin number for relay 2
int ledState1 = LOW;
int ledState2 = LOW;
long previousMillis1 = 0;
long previousMillis2 = 0;
long interval1 = 30000; // interval at which to blink (milliseconds) for RELAY1
long interval2 = 50000; // interval at which to blink (milliseconds) for RELAY2
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| L E D D I M M I N G P A R T |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| F A D E S I N A N D O U T |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
int blueramptime = 60 ; // time for blue LEDs to dim on and off in minutes
int whiteramptime = 120 ; // time for white LEDs to dim on and off in minutes
int bluemin = 0 ; // minimmum dimming value of blue LEDs, range of 0-255
int bluemax = 255 ; // maximum dimming value of blue LEDs, range of 0-255
int whitemin = 0 ; // minimum dimming value of white LEDs, range of 0-255
int whitemax = 255 ; // maximum dimming value of white LEDs, range of 0-255
int photoperiod = 240 ; // amount of time array is on at full power in minutes
int ontime = 10 ; // time of day (hour, 24h clock) to begin photoperiod fade in
int blue = 3; // blue LEDs connected to digital pin 3 (pwm)
int white = 7; // white LEDs connected to digital pin 11 (pwm)
int fan = 10; // Fan lead connected to digital pin 10 (pwm)
int bluepercent[11] = { 0, 26, 52, 78, 103, 128, 154, 180, 205, 230, 255 }; // this line is needed if you are using meanwell ELN60-48P
int whitepercent[11] = { 0, 26, 52, 78, 103, 128, 154, 180, 205, 230, 255 }; // these are the values in 10% increments
// int pwm_one = 10; // extra pwm pin for future use
// int pwm_one = 9; // extra pwm pin for future use
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| R T C C L O C K D S 1 3 0 7 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
byte decToBcd(byte val) // Convert normal decimal numbers to binary coded decimal
{
return ( (val/10*16) + (val%10) );
}
byte bcdToDec(byte val) // Convert binary coded decimal to normal decimal numbers
{
return ( (val/16*10) + (val%16) );
}
// 1) Sets the date and time on the ds1307
// 2) Starts the clock
// 3) Sets hour mode to 24 hour clock
// Assumes you're passing in valid numbers
void setDateDs1307(byte second, // 0-59
byte minute, // 0-59
byte hour, // 1-23
byte dayOfWeek, // 1-7
byte dayOfMonth, // 1-28/29/30/31
byte month, // 1-12
byte year) // 0-99
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.send(decToBcd(second)); // 0 to bit 7 starts the clock
Wire.send(decToBcd(minute));
Wire.send(decToBcd(hour)); // If you want 12 hour am/pm you need to set
// bit 6 (also need to change readDateDs1307)
Wire.send(decToBcd(dayOfWeek));
Wire.send(decToBcd(dayOfMonth));
Wire.send(decToBcd(month));
Wire.send(decToBcd(year));
Wire.endTransmission();
}
// Gets the date and time from the ds1307
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
// Reset the register pointer
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
// A few of these need masks because certain bits are control bits
*second = bcdToDec(Wire.receive() & 0x7f);
*minute = bcdToDec(Wire.receive());
*hour = bcdToDec(Wire.receive() & 0x3f); // Need to change this if 12 hour am/pm
*dayOfWeek = bcdToDec(Wire.receive());
*dayOfMonth = bcdToDec(Wire.receive());
*month = bcdToDec(Wire.receive());
*year = bcdToDec(Wire.receive());
}
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| D E F I N E : U P N E X T |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
char* UpNext[3] ;
void Next()
{
GLCD.GotoXY(65, 0);
GLCD.Puts("Next:");
GLCD.GotoXY(65, 8);
GLCD.Puts(UpNext[0]);
GLCD.GotoXY(65, 16);
GLCD.Puts(UpNext[1]);
GLCD.GotoXY(65, 24);
GLCD.Puts(UpNext[2]);
GLCD.GotoXY(65, 32);
}
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| D E F I N E : F A N S O N |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
void FansOn()
{
analogWrite(fan, 255);
GLCD.GotoXY(64, 48);
GLCD.Puts("Fans:");
GLCD.GotoXY(64, 56);
GLCD.Puts("are on");
}
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| D E F I N E : F A N S O F F |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
void FansOff()
{
analogWrite(fan, 0);
GLCD.GotoXY(64, 48);
GLCD.Puts("Fans:");
GLCD.GotoXY(64, 56);
GLCD.Puts("are off");
}
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| D E F I N E : O N E S E C O N D |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
void onesecond() //function that runs once per second while program is running
{
DateTime now = RTC.now();
/* Commented out RTC
GLCD.PrintNumber(now.year());
GLCD.Puts("/");
GLCD.PrintNumber(now.month());
GLCD.Puts("/");
GLCD.PrintNumber(now.day());
GLCD.Puts(" ");
GLCD.PrintNumber(now.hour());
GLCD.Puts(":");
GLCD.PrintNumber(now.minute());
GLCD.Puts(":");
GLCD.PrintNumber(now.second());
*/
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
GLCD.GotoXY(0, 0);
//GLCD.PrintNumber(hour);
//GLCD.PrintNumber(minute);
//GLCD.PrintNumber(second);
if((now.hour())>0)
{
if((now.hour())<=12)
{
GLCD.PrintNumber(now.hour());
}
else
{
GLCD.PrintNumber((now.hour())-12);
}
}
else
{
GLCD.Puts("12");
}
GLCD.Puts(":");
if ((now.minute()) < 10) {
GLCD.Puts("0");
}
GLCD.PrintNumber(now.minute());
GLCD.Puts(":");
if ((now.second()) < 10) {
GLCD.Puts("0");
}
GLCD.PrintNumber(now.second());
if((now.hour())<12)
{
GLCD.Puts("am");
}
else
{
GLCD.Puts("pm");
}
GLCD.Puts(" ");
//GLCD.GotoXY(0, 24 );
//GLCD.PrintNumber (daybyminute);
delay(1000);
}
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| D E F I N E : R E L A Y 1 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
void relay1() //FUNCTION TO TURN ON AND OFF RELAY 1.
{
unsigned long currentMillis = millis();
if(currentMillis - previousMillis1 > interval1)
{
previousMillis1 = currentMillis;
if (ledState1 == LOW)
ledState1 = HIGH;
else
ledState1 = LOW;
digitalWrite(ledPin1, ledState1);
}
}
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| D E F I N E : R E L A Y 2 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
void relay2()
{
unsigned long currentMillis2 = millis();
if(currentMillis2 - previousMillis2 > interval2)
{
previousMillis2 = currentMillis2;
if (ledState2 == LOW)
ledState2 = HIGH;
else
ledState2 = LOW;
digitalWrite(ledPin2, ledState2);
}
}
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| S E T U P |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
void setup(){
// pinMode(ledPin1, OUTPUT); // set the digital pin as output:
// pinMode(ledPin2, OUTPUT); // set the digital pin as output:
RTC.begin(DateTime(__DATE__, __TIME__));
GLCD.Init(NON_INVERTED); // initialise the library, non inverted writes pixels onto a clear screen
GLCD.ClearScreen();
GLCD.SelectFont(System5x7); // switch to fixed width system font
GLCD.DrawBitmap(seahorse2, 8,0, BLACK); //draw the bitmap at the given x,y position
GLCD.DrawRoundRect(48,0,32,63, 5, BLACK); // rounded rectangle around text area
GLCD.GotoXY(56, 1);
GLCD.Puts("S W");
GLCD.GotoXY(56, 9);
GLCD.Puts("e h");
GLCD.GotoXY(56, 17);
GLCD.Puts("a i");
GLCD.GotoXY(56, 25);
GLCD.Puts("h s");
GLCD.GotoXY(56, 32);
GLCD.Puts("o p");
GLCD.GotoXY(56, 40);
GLCD.Puts("r e");
GLCD.GotoXY(56, 47);
GLCD.Puts("s r");
GLCD.GotoXY(56, 55);
GLCD.Puts("e s");
GLCD.DrawBitmap(seahorse, 88,0, BLACK); //draw the bitmap at the given x,y position
GLCD.SelectFont(System5x7); // switch to fixed width system font
countdown(1);
GLCD.ClearScreen();
introScreen(); // show some intro stuff
GLCD.ClearScreen();
BusinessScreen();
}
void introScreen(){
GLCD.SelectFont(Arial_14); // you can also make your own fonts, see playground for details
GLCD.GotoXY(20, 2);
GLCD.Puts("GLCD version ");
GLCD.PrintNumber(GLCD_VERSION);
GLCD.DrawRoundRect(16,0,99,18, 5, BLACK); // rounded rectangle around text area
GLCD.SelectFont(System5x7); // switch to fixed width system font
showCharacters();
countdown(1);
}
void showCharacters(){
byte line = 3; // start on the fourth line
for(byte c = 32; c <=127; c++){
if( (c-32) % 20 == 0)
GLCD.CursorTo(1,line++); // CursorTo is used for fixed width system font
GLCD.PutChar(c);
}
}
void countdown(int count){
while(count--){ // do countdown
GLCD.CursorTo(0,1); // first column, second row (offset is from 0)
GLCD.PutChar(count + '0');
delay(1000);
}
// Serial.begin(9600);
// irrecv.enableIRIn(); // Start the receiver
}
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| S E T U P - D I S P L A Y |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
void BusinessScreen(){
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
Wire.begin();
// Change these values to what you want to set your clock to.
// You probably only want to set your clock once and then remove
// the setDateDs1307 call.
// second = 56;
// minute = 57;
// hour = 23;
// dayOfWeek = 6; // Sunday is 0
// dayOfMonth = 26;
// month = 2;
// year = 11;
//setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
analogWrite(blue, bluemin);
analogWrite(white, whitemin);
// GLCD.begin(20, 8); // set up the LCD's number of rows and columns:
// lcd.print("12:00 80.6"); // Print a message to the LCD.
// lcd.print(char(223));
//byte line = 2; // start on the 3rd line
GLCD.GotoXY(0, 8 );
GLCD.Puts("Blue: ");
// GLCD.PrintNumber(33*blueramptime/85);
//GLCD.Puts("%");
// GLCD.GotoXY(1,1); // GotoXY is used for fixed width system font
GLCD.GotoXY(0, 16);
GLCD.Puts("White: ");
//GLCD.PrintNumber(33*whiteramptime/85);
// GLCD.Puts("%");
GLCD.DrawBitmap(seahorse2, 100,0, BLACK); //draw the bitmap at the given x,y position
//GLCD.DrawBitmap(MoonUp, 0,32, WHITE); //draw the bitmap at the given x,y position
//GLCD.DrawBitmap(SunSet, 64,32, WHITE); //draw the bitmap at the given x,y position
}
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| L O O P |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
void loop()
{
onesecond();
relay2();
relay1();
//if (irrecv.decode(&results)) {
// Serial.println(results.value, HEX);
// irrecv.resume(); // Receive the next value
// }
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| L O O P - D I M F U N C T I O N |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
DateTime now = RTC.now();
int daybyminute = ((now.hour() * 60) + now.minute()); //converts time of day to a single value in minutes
// int daybyminute = ((hour * 60) + minute); //converts time of day to a single value in minutes
int bluerampup;
if (daybyminute >= (ontime*60))
bluerampup = (((ontime*60) + blueramptime) - daybyminute);
else
bluerampup = blueramptime;
int whiterampup;
if (daybyminute >= (ontime*60 + blueramptime))
whiterampup = (((ontime*60) + blueramptime + whiteramptime) - daybyminute);
else
whiterampup = whiteramptime;
int whiterampdown;
if (((ontime * 60) + photoperiod + blueramptime + whiteramptime) <= daybyminute)
whiterampdown = (((ontime*60) + photoperiod + blueramptime + 2*whiteramptime) - daybyminute);
else
whiterampdown = whiteramptime;
int bluerampdown;
if (((ontime * 60) + photoperiod + blueramptime + 2*whiteramptime) <= daybyminute)
bluerampdown = (((ontime*60) + photoperiod + 2*blueramptime + 2*whiteramptime) - daybyminute);
else
bluerampdown = blueramptime;
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| L O O P - F A D E I N |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
if (daybyminute >= (ontime*60))
{
if (daybyminute <= ((ontime*60) + blueramptime + (whiteramptime/10*9))) //if time is in range of fade in, start fading in + (whiteramptime/10*9)
{
FansOn();
// fade blue LEDs in from min to max.
for (int i = 1; i <= 10; i++) // setting ib value for 10% increment. Start with 0%
{
char* UpNext[] = {"white", "ramp", "up"};
Next();
if((ontime + (blueramptime/60))<12)
{
GLCD.PrintNumber (ontime + (blueramptime/60));
GLCD.Puts(":00am");
}
else
{
GLCD.PrintNumber (ontime + (blueramptime/60) - 12);
GLCD.Puts(":00pm");
}
GLCD.GotoXY(0, 24 );
GLCD.Puts("Dawn ");
GLCD.DrawBitmap(Dawn, 0,32, WHITE); //draw the bitmap at the given x,y position
analogWrite(blue, bluepercent[i]);
GLCD.GotoXY(30, 8);
GLCD.Puts(" ");
GLCD.GotoXY(30, 8);
GLCD.PrintNumber(i*10);
GLCD.Puts("%");
GLCD.GotoXY(36, 16);
GLCD.Puts(" ");
GLCD.GotoXY(36, 16);
GLCD.PrintNumber(0);
GLCD.Puts("% ");
int countdown = ((bluerampup*60)/10); // calculates seconds to next step
while (countdown>0)
{
onesecond(); // updates clock once per second
countdown--;
relay2();
relay1();
}
}
// fade white LEDs in from min to max.
for (int i = 1; i <= 10; i++) // setting i value for 10% increment. Start with 0%
{
char* UpNext[] = {"all", "lights", "max"};
Next();
if((ontime + (blueramptime/60) + (whiteramptime/60))<12)
{
GLCD.PrintNumber (ontime + (blueramptime/60) + (whiteramptime/60));
GLCD.Puts(":00am");
}
else
{
GLCD.PrintNumber (ontime + (blueramptime/60) + (whiteramptime/60) - 12);
GLCD.Puts(":00pm");
}
GLCD.GotoXY(0, 24 );
GLCD.Puts("Sunrise ");
GLCD.DrawBitmap(SunRise, 0,32, WHITE); //draw the bitmap at the given x,y position
analogWrite(white, whitepercent[i]);
GLCD.GotoXY(36, 16);
GLCD.Puts(" ");
GLCD.GotoXY(36, 16);
GLCD.PrintNumber(i*10);
GLCD.Puts("%");
int countdown = ((whiterampup*60)/10); // calculates seconds to next step
while (countdown>0)
{
onesecond(); // updates clock once per second
countdown--;
relay2();
relay1();
}
}
}
}
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| L O O P - M A X V A L U E |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
if (daybyminute >= ((ontime * 60) + blueramptime + whiteramptime))
{
if ( daybyminute < ((ontime * 60) + blueramptime + whiteramptime + photoperiod)) // if time is in range of photoperiod, turn lights on to maximum fade value
{
char* UpNext[] = {"white", "ramp", "down"};
Next();
if((ontime + (blueramptime/60) + (whiteramptime/60) + (photoperiod/60))<12)
{
GLCD.PrintNumber (ontime + (blueramptime/60) + (whiteramptime/60)+ (photoperiod/60));
GLCD.Puts(":00am");
}
else
{
GLCD.PrintNumber (ontime + (blueramptime/60) + (whiteramptime/60)+ (photoperiod/60) - 12);
GLCD.Puts(":00pm");
}
FansOn();
GLCD.GotoXY(0, 24 );
GLCD.Puts("Daytime ");
GLCD.DrawBitmap(SunUp, 0,32, WHITE); //draw the bitmap at the given x,y position
analogWrite(blue, 255);
GLCD.GotoXY(30, 8);
GLCD.Puts(" ");
GLCD.GotoXY(30, 8);
GLCD.PrintNumber(100);
GLCD.Puts("%");
analogWrite(white, 255);
GLCD.GotoXY(36, 16);
GLCD.Puts(" ");
GLCD.GotoXY(36, 16);
GLCD.PrintNumber(100);
GLCD.Puts("%");
}
}
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| L O O P - F A D E O U T |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
if (((ontime * 60) + photoperiod + blueramptime + whiteramptime) <= daybyminute)
{
if (((ontime * 60) + photoperiod + whiteramptime + (2*blueramptime) + (whiteramptime/10*9)) >= daybyminute)
{
FansOn();
// fade white LEDs out from max to min in increments of 1 point:
for (int i = 10; i >= 0; i--) // // setting i value for 10% increment. Start with 10%
{
GLCD.GotoXY(64, 8);
char* UpNext[] = {"blue", "ramp", "down"};
Next();
if((ontime + (blueramptime/60) + (2*whiteramptime/60) + (photoperiod/60))<12)
{
GLCD.PrintNumber (ontime + (blueramptime/60) + (2*whiteramptime/60)+ (photoperiod/60));
GLCD.Puts(":00am");
}
else
{
GLCD.PrintNumber (ontime + (blueramptime/60) + (2*whiteramptime/60)+ (photoperiod/60) - 12);
GLCD.Puts(":00pm");
}
GLCD.GotoXY(0, 24 );
GLCD.Puts("SunSet ");
GLCD.DrawBitmap(SunSet, 0,32, WHITE); //draw the bitmap at the given x,y position
analogWrite(blue, 255);
GLCD.GotoXY(30, 8);
GLCD.Puts(" ");
GLCD.GotoXY(30, 8);
GLCD.PrintNumber(100);
GLCD.Puts("%");
analogWrite(white, whitepercent[i]);
GLCD.GotoXY(36, 16);
GLCD.Puts(" ");
GLCD.GotoXY(36, 16);
GLCD.PrintNumber(i*10);
GLCD.Puts("%");
int countdown = ((whiterampdown*60)/10); // calculates seconds to next step
while (countdown>0)
{
onesecond(); // updates clock once per second
countdown--;
relay2();
relay1();
}
}
// fade blue LEDs out from max to min in increments of 1 point:
for (int i = 10; i >= 0; i--) // setting i value for 10% increment. Start with 10%
{
char* UpNext[] = {"All", "Lights", "off"};
Next();
if((ontime + (2*blueramptime/60) + (2*whiteramptime/60) + (photoperiod/60))<12)
{
GLCD.PrintNumber (ontime + (2*blueramptime/60) + (2*whiteramptime/60)+ (photoperiod/60));
GLCD.Puts(":00am");
}
else
{
GLCD.PrintNumber (ontime + (2*blueramptime/60) + (2*whiteramptime/60)+ (photoperiod/60) - 12);
GLCD.Puts(":00pm");
}
GLCD.GotoXY(0, 24 );
GLCD.Puts("Dusk ");
GLCD.DrawBitmap(Dusk, 0,32, WHITE); //draw the bitmap at the given x,y position
analogWrite(blue, bluepercent[i]);
GLCD.GotoXY(30, 8);
GLCD.Puts(" ");
GLCD.GotoXY(30, 8);
GLCD.PrintNumber(i*10);
GLCD.Puts("%");
int countdown = ((bluerampdown*60)/10); // calculates seconds to next step
while (countdown>0)
{
onesecond(); // updates clock once per second
countdown--;
relay2();
relay1();
}
}
}
}
//*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Night Time |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
if (((ontime * 60) + photoperiod + (2 * blueramptime) + (2 * whiteramptime)) < daybyminute)
{
GLCD.GotoXY(64, 8);
char* UpNext[] = {"blue", "ramp", "up"};
Next();
if((ontime)<12)
{
GLCD.PrintNumber (ontime);
GLCD.Puts(":00am");
}
else
{
GLCD.PrintNumber (ontime - 12);
GLCD.Puts(":00pm");
}
FansOff();
GLCD.GotoXY(30, 8);
GLCD.Puts(" ");
GLCD.GotoXY(30, 8);
GLCD.PrintNumber(0);
GLCD.Puts("%");
GLCD.GotoXY(36, 16);
GLCD.Puts(" ");
GLCD.GotoXY(36, 16);
GLCD.PrintNumber(0);
GLCD.Puts("%");
GLCD.GotoXY(0, 24 );
GLCD.Puts("Night time");
GLCD.DrawBitmap(MoonUp, 0,32, WHITE); //draw the bitmap at the given x,y position
}
if (daybyminute < (ontime*60))
{
char* UpNext[] = {"blue", "ramp", "up"};
Next();
if((ontime)<12)
{
GLCD.PrintNumber (ontime);
GLCD.Puts(":00am");
}
else
{
GLCD.PrintNumber (ontime - 12);
GLCD.Puts(":00pm");
}
FansOff();
GLCD.GotoXY(30, 8);
GLCD.Puts(" ");
GLCD.GotoXY(30, 8);
GLCD.PrintNumber(0);
GLCD.Puts("%");
GLCD.GotoXY(36, 16);
GLCD.Puts(" ");
GLCD.GotoXY(36, 16);
GLCD.PrintNumber(0);
GLCD.Puts("%");
GLCD.GotoXY(0, 24 );
GLCD.Puts("Night time");
GLCD.DrawBitmap(MoonUp, 0,32, WHITE); //draw the bitmap at the given x,y position
}
}
// END LOOP
you better watch that metal box on that arduino you could fry it.....
I've got foam rubber feet on it so it won't touch.
Hmmmm try to get that fan working from a analog pin would save us a digital input. as soon as my girl leaves for work I will get my fans working on this or at least try
Hello!
I´m making this build and it is "kind" of working, I say "kind" because the leds dim are made with huge steps, not smooth. In the first step, 0/1 to 26 it ligth up like 0 to 40% or 50% of total power. When it turns on I can see leds with a very wheak ligth, on the next step... BUmmm, 40% of total power. Same thing on both blues and whites.
I´m using the 48P driven with 2n2222.
As I´m in test mode I have my ramp´s set to 10 minutes now.
Already tryed to change this :
int bluepercent[11] = { 0, 26, 52, 78, 103, 128, 154, 180, 205, 230, 255 }; // this line is needed if you are using meanwell ELN60-48P
int whitepercent[11] = { 0, 26, 52, 78, 103, 128, 154, 180, 205, 230, 255 }; // these are the values in 10% increments
to lower values like : 0, 2, 5, 10, .... no luck.
So, is this behaviour normal or do I have something wrong in my code?
many thanks,
Henrique
//int bluepercent[11] = { 0, 1, 2, 5, 8 ,12, 18, 27, 44, 80, 255 }; // this line is needed if you are using meanwell ELN60-48D
//int whitepercent[11] = { 0, 1, 2, 5, 8 ,12, 18, 27, 44, 80, 255 }; // these are the values in 10% increments
int bluepercent[11] = { 0, 26, 52, 78, 103, 128, 154, 180, 205, 230, 255 }; // this line is needed if you are using meanwell ELN60-48P
int whitepercent[11] = { 0, 26, 52, 78, 103, 128, 154, 180, 205, 230, 255 }; // these are the values in 10% increments
To all, there are 2 functions on this sketch...
FUNCTION 1
We are only talking about "one" function... which is the ramp down and up of two channel/s. One for white and one for blue...
FUNCTION 2
We just need (FUTURE) to add a low voltage relay and this can be used as a wavetimer. We have two channel/s already built in on this sketch. This is "RELAY1" and "RELAY2". Arduino PIN 2 & 8
First of all, welcome to RC, and to my thread.... I apologize for the delay, im done moving but everything right now are scattered everywhere and still in boxes... its very chaotic....
this is not normal.... please double check everthing specially the wiring... are you sure, you are using NPN? because you can easily have it mixed with PNP? do you have what i have? as in terms of hardware? what kind of hardware do you have, please list it here.... do you have a pic?
Im curious as to why it acts like that...
You should have something like this....
PHP://int bluepercent[11] = { 0, 1, 2, 5, 8 ,12, 18, 27, 44, 80, 255 }; // this line is needed if you are using meanwell ELN60-48D //int whitepercent[11] = { 0, 1, 2, 5, 8 ,12, 18, 27, 44, 80, 255 }; // these are the values in 10% increments int bluepercent[11] = { 0, 26, 52, 78, 103, 128, 154, 180, 205, 230, 255 }; // this line is needed if you are using meanwell ELN60-48P int whitepercent[11] = { 0, 26, 52, 78, 103, 128, 154, 180, 205, 230, 255 }; // these are the values in 10% increments
#include <Button.h>
//create a Button object at pin 12
/*
|| Wiring:
|| GND -----/ ------ pin 12
*/
Button button = Button(12,PULLUP);
void setup(){
pinMode(13,OUTPUT); //debug to led 13
}
void loop(){
if(button.isPressed()){
digitalWrite(13,HIGH);
}else{
digitalWrite(13,LOW);
}
}
Any thoughts?