PWM Expansion difficulties
Posted: Tue May 22, 2012 3:31 pm
So I've been trying for the past day and half to figure out how to set my LED lights on a dimming schedule. So far all I've been able to do is turn them on and off. I've changed to code during my experiments to have the LED's run at only 30% so that I can visually tell if the code is working....but so far they keep running at full power...my brain is fried from reading posts on the forum and trying to figure this out...any help would be awesome!
Not looking for anything fancy right now...just want a sunrise/sunset effect...
Not looking for anything fancy right now...just want a sunrise/sunset effect...
Code: Select all
// Autogenerated file by RAGen (v1.2.2.171), (05/22/2012 14:47)
// RA_052212_1447.ino
//
// This version designed for v0.9.0 or later
//The following features are enabled for this File:
#define DisplayImages
#define DateTimeSetup
#define VersionMenu
#define DirectTempSensor
#define DisplayLEDPWM
#define SIMPLE_MENU
#define PWMEXPANSION
#define RFEXPANSION
#define IOEXPANSION
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <RF.h>
#include <IO.h>
#include <ReefAngel.h>
////// Place global variable code below here
// LEDPWM Channel defines for easy code reading
#define LEDPWM0 0
#define LEDPWM1 1
#define LEDPWM2 2
#define LEDPWM3 3
// Initial values to all 6 channels at startup. They will always be 0.
byte PWMChannel[]={
0,0,0,0,0,0};
////// Place global variable code above here
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
// Ports that are always on
ReefAngel.Relay.On(Port2);
ReefAngel.Relay.On(Port5);
ReefAngel.Relay.On(Port6);
ReefAngel.Relay.On(Port7);
ReefAngel.Relay.On(Port8);
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
////// Place your custom code below here
//Start of PWM Expansion Code for Slope
PWMChannel[LEDPWM0]=PWMSlope(11,00,17,00,20,80,60,PWMChannel[LEDPWM0]);
PWMChannel[LEDPWM1]=PWMSlope(10,00,18,00,20,80,60,PWMChannel[LEDPWM1]);
PWMChannel[LEDPWM2]=PWMSlope(9,30,18,30,20,80,30,PWMChannel[LEDPWM2]);
PWMChannel[LEDPWM3]=PWMSlope(10,30,17,30,20,80,30,PWMChannel[LEDPWM3]);
// The lines above are what calculates the slope.
// You can change the schedule by changing the parameter inside the parenthesis of the PWMSlope() function
// The are as follow:
// 1st parameter: hour to start slope
// 2nd parameter: minute to start slope
// 3rd parameter: hour to end slope
// 4th parameter: minute to end slope
// 5th parameter: % of the PWM signal to start slope
// 6th parameter: % of the PWM signal to end slope
// 7th parameter: duration of slope in minutes
// 8th parameter: always the same as the variable before the PWMSlope() call
////// Place your custom code above here
// This should always be the last line
ReefAngel.ShowInterface();
}