Page 1 of 1

IO module port 2 stuck on even when disconnected

Posted: Wed Aug 29, 2012 7:48 pm
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

Re: IO module port 2 stuck on even when disconnected

Posted: Wed Aug 29, 2012 8:25 pm
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.