Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A24 arduino demo source code-02-digital input
#1
Code:
#include "Arduino.h"
#include "PCF8575.h"
#define delaytime    200
PCF8575 pcf8575_IN1(0x24,16,5);
PCF8575 pcf8575_IN2(0x25,16,5);
void setup()
{
  Serial.begin(115200);
  delay(100);
/**************************************************************/ 
pcf8575_IN1.begin();
pcf8575_IN2.begin();
  for (int a=0;a<=15;a++)
    {
      pcf8575_IN1.pinMode(a,INPUT);
     
    }
     for (int a=0;a<=7;a++)
    {
     pcf8575_IN2.pinMode(a,INPUT);
    }
/*************************************/
}
void loop()
{
  delay(delaytime);
  for(int a=0;a<=15;a++){
     if (pcf8575_IN1.digitalRead(a)==0) Serial.printf(("KEY %d PRESSED\n"),a+1);
  }
  for(int a=0;a<=7;a++){
     if (pcf8575_IN2.digitalRead(a)==0) Serial.printf(("KEY %d PRESSED\n"),a+17);
  }
 
}

   
Reply


Messages In This Thread
A24 arduino demo source code-02-digital input - by KinCony Support - 12-07-2023, 02:00 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)