IO module port 2 stuck on even when disconnected

Basic / Standard Reef Angel hardware
Post Reply
00Warpig00
Posts: 289
Joined: Wed May 16, 2012 9:52 pm

IO module port 2 stuck on even when disconnected

Post by 00Warpig00 »

Came home to my IO module showing me an on status (dot) on port 2 So I unhooked the switch. I already have 1 switch that is flaky so figured another flaky switch. Port still stayed on with switch disconnected. Rebooted RA+ port still on. I had to unplug/replug the data cable from the IO Mod to clear it. Any Ideas?

Nick
180G FOWLR
20GH QT#1
29G QT#2

Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: IO module port 2 stuck on even when disconnected

Post by rimai »

Let's add watchdog to your module.

Code: Select all

#include <Wire.h>
#include <avr/wdt.h>

byte IOports[] ={
  3,5,6,9,10,11};

byte IOOut=0;
void setup()
{
  wdt_enable(WDTO_1S);
  Wire.begin(9);
  Wire.onRequest(requestEvent);
  for (int a=0;a<6;a++)
  {
    pinMode(IOports[a],INPUT);
    digitalWrite(IOports[a],HIGH); //pull up resistor
  }
}

void loop()
{
  wdt_reset();
}

void requestEvent() {
  IOOut=0;
  for (int a=0;a<6;a++)
  {
    IOOut+=digitalRead(IOports[a])<<a; //pull up resistor
  }
  Wire.write(IOOut);
}

Upload this code to your I/O module.
Open the case and plug the cable with the black wire on the GND marking.
Make sure you pick "Reef Angel Controller w/ optibbot" board before you try uploading.
Roberto.
Post Reply