Hi found a problem in a test of software i have written .sometimes the arduino freezes up. i thinks its a software related problem. this is just a guess but i think after a while (hours or days) the memory fills up and then freeze the program. but could some take a look at my code please, to se if that could be the problem.
How do i clear the memory if thats the case of my problems.
here is the code:
#include <AikoEvents.h>
#include <DmxSimple.h>
using namespace Aiko;
/*
Gustaf Gagges 3ch random dmx Fade
This example code is in the public domain.
*/
int brightness1 = 0; // how bright the channel is
int fadeAmount1 = 1; // how many points to fade the channel by
int brightness2 = 0; // how bright the channel is
int fadeAmount2 = 1; // how many points to fade the channel by
int brightness3 = 0; // how bright the channel is
int fadeAmount3 = 1; // how many points to fade the channel by
void setup() {
DmxSimple.usePin(3);
Serial.begin(9600);
randomSeed(analogRead(0));
Events.addHandler(eventhandl,1); // time for the random event
}
void loop() {
Events.loop();
}
void eventhandl()
{
if (brightness1 <=0){
Events.addHandler(channel1, random (1000,2000)); //max and min for the fade time on channel 1
}
if (brightness2 <=0){
Events.addHandler(channel2, random (400,1200));//max and min for the fade time on channel 2
}
if (brightness3 <=0){
Events.addHandler(channel3, random (1600,2400));//max and min for the fade time on channel 2
}
}
void channel1()
{
// set the brightness of dmx channel
DmxSimple.write(1, brightness1);
Serial.print("channel1:");
Serial.println(brightness1);
// change the brightness for next time through the loop:
brightness1 = brightness1 + fadeAmount1;
// reverse the direction of the fading at the ends of the fade:
if (brightness1 == 0 || brightness1 == 200) {
fadeAmount1 = -fadeAmount1 ;
}
}
void channel2()
{
// set the brightness of dmx channel
DmxSimple.write(2, brightness2);
Serial.print("channel2:");
Serial.println(brightness2);
// change the brightness for next time through the loop:
brightness2 = brightness2 + fadeAmount2;
// reverse the direction of the fading at the ends of the fade:
if (brightness2 == 0 || brightness2 == 200) {
fadeAmount2 = -fadeAmount2 ;
}
}
void channel3()
{
// set the brightness of dmx channel
DmxSimple.write(3, brightness3);
Serial.print("channel3:");
Serial.println(brightness3);
// change the brightness for next time through the loop:
brightness3 = brightness3 + fadeAmount3;
// reverse the direction of the fading at the ends of the fade:
if (brightness3 == 0 || brightness3 == 200) {
fadeAmount3 = -fadeAmount3 ;
}
}