IO Expansion Coding

Do you have a question on how to do something.
Ask in here.
Post Reply
JoelIreland
Posts: 58
Joined: Sat Jan 26, 2013 1:27 am

IO Expansion Coding

Post by JoelIreland »

I there,
I can figure most things out but can't see much on the IO expansion relay.
I have one and want to do 2 things.
I want to have a button ( on press ) start feed mode or another result, and on press again it stops it.
Also i want other outputs to be status LEDs so how do i know what input / output etc it controls and what to listen for for button press?

Thanks
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: IO Expansion Coding

Post by rimai »

:(
That's my bad...
We never had nobody doing output in the past, so we never improved the firmware on the expansion module.
http://forum.reefangel.com/viewtopic.php?f=3&t=3045
So, if you want to pickup the slack and improve the firmware, we can move forward and get this wrapped up.
Want to try?
Roberto.
JoelIreland
Posts: 58
Joined: Sat Jan 26, 2013 1:27 am

Re: IO Expansion Coding

Post by JoelIreland »

Ill see what i can do.
So as far as detecting a button press, what would be my best option?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: IO Expansion Coding

Post by rimai »

You could do something like this:

Code: Select all

  if (ReefAngel.IO.GetChannel(0) && ReefAngel.DisplayedMenu==FEEDING_MODE)
    ButtonPress++;
  else
    ReefAngel.FeedingModeStart();
Roberto.
JoelIreland
Posts: 58
Joined: Sat Jan 26, 2013 1:27 am

Re: IO Expansion Coding

Post by JoelIreland »

So one end of button goes into channel 0 the other into one of the ground input?
Thanks.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: IO Expansion Coding

Post by rimai »

Yeap :)
Roberto.
JoelIreland
Posts: 58
Joined: Sat Jan 26, 2013 1:27 am

Re: IO Expansion Coding

Post by JoelIreland »

this is what i have ( head and loop )
<!-- HEAD -->
#include <Salinity.h>
#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 <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>

#include <WaterLevel.h>
#include <ReefAngel.h>


<!-- LOOP -->
// First channel on left and 1st ground on left. It a push button when it on i want moon lights ( for test ) to turn on.
Moon lights are also on timer but this should over ride?
if(ReefAngel.IO.GetChannel(0)){

ReefAngel.Relay.On(MOON_LIGHTS);
}
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: IO Expansion Coding

Post by rimai »

That's fine, but this override will only work if it is after your moonlight function.
Roberto.
Post Reply