- You are using the most current development libraries. If you are unsure or don't have the most updated, you can simply follow the instructions in this thread to update/convert: http://forum.reefangel.com/viewtopic.php?f=8&t=2
- You already have everything connected and tested. If not, please read through the manual: http://www.reefangel.com/files/Reef%20A ... 20v1.0.pdf
- You have modified the file ReefAngel_Features.h to include the PWM Expansion code into the libraries. If not, the file is located at "Documents\Arduino\libraries\ReefAngel_Features". Open it in notepad and make sure that you have "#define PWMExpansionRelay" and that it does not have "//" in front of it.
The first thing we are going to to is declare some variables and labels we are going to be used within our code. This piece of code goes above setup() function.
Code: Select all
//**********************************************************************************//Start of PWM Expansion Code Header
// This is just how we are going to reference the PWM expansion ports within the code.
// You can change the labels if you would like, just as long as they are changed all throughout the code too.
#define LEDPWM0 0
#define LEDPWM1 1
#define LEDPWM2 2
#define LEDPWM3 3
#define LEDPWM4 4
#define LEDPWM5 5
// Initial values to all 6 channels at startup. They will always be 0.
byte PWMChannel[]={
0,0,0,0,0,0};
//End of PWM Expansion Code Header
//**********************************************************************************
Code: Select all
//**********************************************************************************//Start of PWM Expansion Code for Slope
PWMChannel[LEDPWM0]=PWMSlope(15,0,21,30,15,45,90,PWMChannel[LEDPWM0]);
PWMChannel[LEDPWM1]=PWMSlope(15,0,21,30,15,45,90,PWMChannel[LEDPWM1]);
PWMChannel[LEDPWM2]=PWMSlope(15,0,21,30,15,45,90,PWMChannel[LEDPWM2]);
PWMChannel[LEDPWM3]=PWMSlope(15,0,21,30,15,45,90,PWMChannel[LEDPWM3]);
PWMChannel[LEDPWM4]=PWMSlope(15,0,21,30,15,45,90,PWMChannel[LEDPWM4]);
PWMChannel[LEDPWM5]=PWMSlope(15,0,21,30,15,45,90,PWMChannel[LEDPWM5]);
// In the example above, we are starting the slope at 3:00pm with 15% and going up to 45% within 90 minutes, which would be 4:30pm.
// Then it would stay at 45% from 4:30 to 90 minutes prior to 9:30pm, which would be 8:00pm.
// Then from 8:00pm, it would start sloping down from 45% all the way back to 15% within 90 minutes, which would be 9:30pm.
for (int a=0;a<6;a++)
{
ReefAngel.PWMExpansion(a,int(2.55*PWMChannel[a]));
}
//End of PWM Expansion Code for Slope
//**********************************************************************************
The attached PDE file has the complete code you can use for your reference.