Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Wire.h"
- #include "TCA9555.h"
- TCA9555 TCA1(0x20);
- TCA9555 TCA2(0x21);
- unsigned long cur_time, old_time;
- int ledState = LOW;
- byte pin_tca1[] = {0, 1, 2, 3, 4, 5, 6, 7, 13, 12, 11, 10};
- byte pin_tca2[] = {7, 6, 5, 4, 3, 2, 1, 0, 10, 11, 12, 13};
- byte pin_led = 16;
- byte dt_tca1[20];
- byte dt_tca2[20];
- void setup() {
- // put your setup code here, to run once:
- delay(10);
- Serial.begin(115200);
- Serial.println();
- delay(100);
- pinMode(pin_led, OUTPUT);
- Wire.begin();
- TCA1.begin();
- TCA2.begin();
- for (int i = 0; i < sizeof(pin_tca1); i++) {
- Serial.print(i); Serial.print(",");
- TCA1.pinMode(pin_tca1[i], INPUT_PULLUP);
- TCA2.pinMode(pin_tca2[i], INPUT_PULLUP);
- }
- Serial.println();
- }
- void loop() {
- // put your main code here, to run repeatedly:
- cur_time = millis();
- if (cur_time - old_time >= 100) {
- ledState = !ledState;
- digitalWrite(pin_led, ledState);
- Serial.print("TCA1: ");
- for (int i = 0; i < sizeof(pin_tca1); i++) {
- dt_tca1[i] = TCA1.digitalRead(pin_tca1[i]);
- Serial.print(dt_tca1[i]);
- Serial.print(",");
- delay(5);
- }
- Serial.println();
- Serial.print("TCA2: ");
- for (int i = 0; i < sizeof(pin_tca2); i++) {
- dt_tca2[i] = TCA2.digitalRead(pin_tca2[i]);
- Serial.print(dt_tca2[i]);
- Serial.print(",");
- delay(5);
- }
- Serial.println();
- old_time = millis();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement