Bug ? in Digital out on i/o board ??

Hi,

When I initialize all digital ports as input AND I power up externally I only read HIGH on all 8 digital inputs. When I power up via usb and afterwards add external power this does not happen.

If I use one digital i/o as output all works as expected.

Code with unexpected behaviour:

#include <Wire.h>
#include <EEPROM.h>
#include <UC1701.h>
#include <Indio.h>

static UC1701 lcd;

void setup() {
  // put your setup code here, to run once:
  Indio.digitalMode(1,INPUT); // Set CH1 as an input
  Indio.digitalMode(2,INPUT); // Set CH2 as an input
  Indio.digitalMode(3,INPUT); // Set CH3 as an input
  Indio.digitalMode(4,INPUT); // Set CH4 as an input
  Indio.digitalMode(5,INPUT); // Set CH5 as an input
  Indio.digitalMode(6,INPUT); // Set CH6 as an input
  Indio.digitalMode(7,INPUT); // Set CH7 as an input
  Indio.digitalMode(8,INPUT); // Set CH8 as an input

  for (int y = 0; y <= 7; y++) {
    for (int x = 0; x <= 128; x++) {
      lcd.setCursor(x, y);
      lcd.print(" ");
    }
  }
}

void loop() {
 // lcd.clear(); //clear the screen
  lcd.setCursor(0, 2);
  lcd.print("Digital1: ");
 Indio.digitalWrite(8,LOW);
  lcd.print(Indio.digitalRead(1),BIN);
  lcd.print(Indio.digitalRead(2),BIN);
  lcd.print(Indio.digitalRead(3),BIN);
  lcd.print(Indio.digitalRead(4),BIN);
  lcd.print(Indio.digitalRead(5),BIN);
  lcd.print(Indio.digitalRead(6),BIN);
  lcd.print(Indio.digitalRead(7),BIN);
  lcd.print(Indio.digitalRead(8),BIN);
}

 

Code modified with one OUTPUT works fine:

#include <Wire.h>
#include <EEPROM.h>
#include <UC1701.h>
#include <Indio.h>

static UC1701 lcd;

void setup() {
  // put your setup code here, to run once:
  Indio.digitalMode(1,INPUT); // Set CH1 as an input
  Indio.digitalMode(2,INPUT); // Set CH2 as an input
  Indio.digitalMode(3,INPUT); // Set CH3 as an input
  Indio.digitalMode(4,INPUT); // Set CH4 as an input
  Indio.digitalMode(5,INPUT); // Set CH5 as an input
  Indio.digitalMode(6,INPUT); // Set CH6 as an input
  Indio.digitalMode(7,INPUT); // Set CH7 as an input
 // Set CH8 as an input
  Indio.digitalMode(8,OUTPUT);
  Indio.digitalWrite(8,LOW); // To work around a bug showing all digital input's as 1, only when externally powered

  lcd.begin();  //sets the resolution of the LCD screen

  for (int y = 0; y <= 7; y++) {
    for (int x = 0; x <= 128; x++) {
      lcd.setCursor(x, y);
      lcd.print(" ");
    }
  }
}

void loop() {
 // lcd.clear(); //clear the screen
  lcd.setCursor(0, 2);
  lcd.print("Digital1: ");
 Indio.digitalWrite(8,LOW);
  lcd.print(Indio.digitalRead(1),BIN);
  lcd.print(Indio.digitalRead(2),BIN);
  lcd.print(Indio.digitalRead(3),BIN);
  lcd.print(Indio.digitalRead(4),BIN);
  lcd.print(Indio.digitalRead(5),BIN);
  lcd.print(Indio.digitalRead(6),BIN);
  lcd.print(Indio.digitalRead(7),BIN);
}

 

peter
peter
7
| 2 1 2
Asked on 10/7/15, 1:51 PM
0
vote
2466 Views

Hi Peter,

Could you please first set all 8 channels to outputs and to LOW in the setup routine before setting your chosen channels to inputs? That should solve the issue. I will add this small routine as standard to a library update soon.

Cheers,

Loic

Loic De Buck
Loic De Buck
1263
| 3 1 3
Answered on 10/8/15, 9:13 AM
0
vote

Thanx, this works..

peter
on 10/8/15, 9:20 AM

Your answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

Ask a Question

Keep Informed

About This Forum

This community is for professionals and enthusiasts of our products and services.

Read Guidelines

Question tools

14 follower(s)

Stats

Asked: 10/7/15, 1:51 PM
Seen: 2466 times
Last updated: 10/8/15, 9:13 AM