Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4907

Other projects • Re: Custom Key pad

$
0
0
All RN's go back to pin 4 and pin 9 (Q7) of U9 goes to pin 12, would that mean pin 12 is the data pin instead of pin 4?

Code:

// Code for shift-register based keypad// Arduino Pro Micro connected to keypad PCB// via JP1 (14-pin IDC header). Keypad is// constructed from nine '165 shift registers// in series, therefore 72 bits to shift out.// Connect Arduino VCC to JP1 pin 14 (VCC)// Connect Arduino GND to JP1 pin  1 (GND)// Connect Arduino 4   to JP1 pin  4 (DATA)// Connect Arduino 2   to JP1 pin  6 (CLK)// Connect Arduino 3   to JP1 pin  8 (~PL)// GPIOs connected to keypad PCB int dataPIN = 4;int latchPIN = 3;  // Active lowint clockPIN = 2;  // Shift data on rising edgevoid setup() {  // put your setup code here, to run once:  // Setup serial port  Serial.begin(115200);  // Set up pin objects  // Pull-up not needed on data pin because it is driven externally  pinMode(dataPIN, INPUT);  // Include initial pin states here  pinMode(latchPIN, OUTPUT);  digitalWrite(latchPIN, HIGH);  pinMode(clockPIN, OUTPUT);  digitalWrite(clockPIN, LOW);}void loop() {  // put your main code here, to run repeatedly:  // Shift out registers from the PCB and show the value  delay(10);  digitalWrite(latchPIN, LOW); // Latch pins into register  delay(1);  digitalWrite(latchPIN, HIGH);  delay(1);  // For testing look at the first 8 bits  for (int i=0; i<8; i++) {    // Bits are shifted out MSb (bit 7) first    Serial.print("D");    Serial.print(7-i);    Serial.print(" ");    Serial.println(digitalRead(dataPIN));    digitalWrite(clockPIN, HIGH); // Clock out next bit    delay(1);    digitalWrite(clockPIN, LOW);    delay(1);  }  Serial.println();  delay(1000);}

Statistics: Posted by tom2 — Fri Jul 12, 2024 4:30 pm



Viewing all articles
Browse latest Browse all 4907

Trending Articles