Coding for I/O Expansion Unit
Posted: Sat Feb 02, 2013 8:27 pm
One of the things I like most to do is use the wizard to generate some code then compare it to what I doing, looking for improvements, ideas, etc.
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.
I am now going to be adding more float valves to my new tanks and need to replicate this to monitor more floats, different relay ports and pumps, etc. I found this piece of code on the wizard
Can I use this to do what I want, monitor several floats, effect several ports based on individual valves and expand on the original code? Thanks in advance.
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 );