[Logo] TCC discussion forum
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Top Downloads] Top Downloads   [Groups] Back to home page 
[Register] Register /  [Login] Login 


This forum is read only and new users cannot register, please ask all new questions either using GitHub discussions, or in Arduino forum tagging @davetcc.

Pin numbering in IOabstraction RSS feed
Forum Index » IoAbstraction & TaskManagerIO
Author Message
pryanic


Joined: Mar 28, 2022
Messages: 2
Offline
Hello, everyone!
I can't understand pin numbering using ioabstraction lib.
For example:
#include <IoAbstraction.h>
#include <IoAbstractionWire.h>

IoAbstractionRef ioExpander1;
IoAbstractionRef ioExpander2;

void setup() {
  ioExpander1 = ioFrom8574(0x27);
  ioExpander2 = ioFrom8574(0x28);
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:
}

I set io to input using pinDirection(). If I want to read value from pin there is no problem. I can use ioDeviceDigitalRead with unit ref and pin number. I want to addSwitch() function witch only have "pin" parameter. And now I can't understand...? For example I want to addswitch to pin 3 ioExpander1 and to pin 5 ioExpander2. What pin numbers I should print in addSwitch() function?


davetcc


Joined: Jan 19, 2019
Messages: 686
Offline
For switches, you provide the IoAbstraction that it is going to use in the initialise call.

I would suggest that you use a MultiIoAbstraction that lets you group together many IO devices into a single abstraction (I think it allows up to 8 separate ones by default). See

https://www.thecoderscorner.com/ref-docs/ioabstraction/html/class_multi_io_abstraction.html

and

https://www.thecoderscorner.com/products/arduino-libraries/io-abstraction/arduino-pins-and-io-expanders-same-time/

Then you would pass that abstraction to the switches initialise call instead of whatever you're passing now.
pryanic


Joined: Mar 28, 2022
Messages: 2
Offline
I'm stupid. With ioDeviceSync all OK
Yes, thanks. I think similar. But one more issue whitch I could understang.
I have very "stuped" code just for some trainig:

#include <IoAbstraction.h>
#include <IoAbstractionWire.h>
#include<TaskManagerIO.h>
#include <Wire.h>

MultiIoAbstractionRef multiIo = multiIoExpander(100);
void setup() {
Wire.begin();
Serial.begin(115200);
Serial.println("Multi IoExpander example");
multiIoAddExpander(multiIo, ioFrom8574(0x20), 10);
Serial.println("added an expander at pin 100 to 109");
// multiIoAddExpander(multiIo, ioFrom8574(0x21), 10);
//Serial.println("added an expander at pin 110 to 119");
//ioDevicePinMode(multiIo, 100, INPUT);
ioDevicePinMode(multiIo, 100, OUTPUT);
ioDevicePinMode(multiIo, 101, OUTPUT);
ioDevicePinMode(multiIo, 102, OUTPUT);
ioDevicePinMode(multiIo, 103, OUTPUT);
ioDevicePinMode(multiIo, 104, OUTPUT);
ioDevicePinMode(multiIo, 105, OUTPUT);
ioDevicePinMode(multiIo, 106, OUTPUT);
ioDevicePinMode(multiIo, 107, OUTPUT);
ioDevicePinMode(multiIo, LED_BUILTIN, OUTPUT);

ioDeviceDigitalWrite(multiIo, 100, LOW);
ioDeviceDigitalWrite(multiIo, 101, LOW);
ioDeviceDigitalWrite(multiIo, 102, HIGH);
ioDeviceDigitalWrite(multiIo, 103, HIGH);
ioDeviceDigitalWrite(multiIo, 104, HIGH);
ioDeviceDigitalWrite(multiIo, 105, HIGH);
ioDeviceDigitalWrite(multiIo, 106, HIGH);
ioDeviceDigitalWrite(multiIo, 107, HIGH);
ioDeviceDigitalWrite(multiIo, LED_BUILTIN, HIGH);
}

void loop() {
taskManager.runLoop();
}


But nothing happens on PCF outputs, builtin led is OK. I tryed this too but no result: https://www.thecoderscorner.com/products/arduino-libraries/io-abstraction/i2c8574-example-ioabstraction-library/
expander outputs always High. I2C scanner show right adress of 8574 boad.
 
Forum Index » IoAbstraction & TaskManagerIO
Go to:   
Mobile view
Powered by JForum 2.7.0 © 2020 JForum Team • Maintained by Andowson Chang and Ulf Dittmer

This site uses cookies to analyse traffic, serve ads by Google AdSense (non-personalized in EEA/UK), and to record consent. We also embed Twitter, Youtube and Disqus content on some pages, these companies have their own privacy policies.

Our privacy policy applies to all pages on our site

Should you need further guidance on how to proceed: External link for information about cookie management.