Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Arduino source code for KC868-A256]-02 INPUT_256
#1
Code:
/*
* KC868-256 INPUT CODE
  74HC165 Shift register input example
*/
const byte latchPin = 33;       
const byte clockPin = 32;       
const byte dataPin = 15;       


const int numBits = 8;   

void setup() {
  Serial.begin(115200);
  pinMode(dataPin, INPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(latchPin, OUTPUT);
}

void loop() {

  digitalWrite(latchPin, LOW);
  digitalWrite(latchPin, HIGH);
  for(int j =0;j<=255;j+=8)
  {
    for (int i = numBits; i >0; i--) {
    int bit = digitalRead(dataPin);
    if (bit == LOW) {
      Serial.printf("Input %d is DOWN\n",i+j);
    }
    digitalWrite(clockPin, HIGH);
    digitalWrite(clockPin, LOW);
  }
  }
}


Attached Files
.zip   KC868-256_input_256.zip (Size: 796 bytes / Downloads: 279)
Reply


Messages In This Thread
[Arduino source code for KC868-A256]-02 INPUT_256 - by KinCony Support - 03-22-2023, 01:02 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)