Roberto and I wrote this code to monitor a float valve in my display tank, when tripped would sound the buzzer, turn off the pump, then send an alert to the portal which would alert me via text, email etc.
Code: Select all
//turn off port 8 - main pump when switch is tripped and sound buzzer
ReefAngel.Relay.Set(Port8,ReefAngel.IO.GetChannel(0));
ReefAngel.PWM.SetDaylight(100-(ReefAngel.IO.GetChannel(0)*100));
//tell the portal we have a overflow problem
ReefAngel.CustomVar[0]=ReefAngel.IO.GetChannel(0);
ReefAngel.CustomVar[7]=1;
Code: Select all
// Initialize Buzzer variables
byte buzzer=0;
byte iochannel0flag=0;
byte iochannel1flag=0;
byte iochannel2flag=0;
byte iochannel3flag=0;
byte iochannel4flag=0;
byte iochannel5flag=0;
void loop()
{
iochannel0flag = ReefAngel.IO.GetChannel( 0 );
iochannel1flag = ReefAngel.IO.GetChannel( 1 );
iochannel2flag = ReefAngel.IO.GetChannel( 2 );
iochannel3flag = ReefAngel.IO.GetChannel( 3 );
iochannel4flag = ReefAngel.IO.GetChannel( 4 );
iochannel5flag = ReefAngel.IO.GetChannel( 5 );
buzzer = iochannel0flag + iochannel1flag + iochannel2flag + iochannel3flag + iochannel4flag + iochannel5flag;
if ( buzzer >= 1 ) buzzer = 100;
ReefAngel.PWM.SetActinic( buzzer );