DrDiettrich:
The inputs don't have pullup resistors. Add a resistor to every switch.
I had that from the beginning, apologies for the lack of clarity
Grumpy_Mike:
No, leave that unconnected otherwise what salidude said.
Will do, thank you
saildude:
you need to read the sticky post at the start of the forum on how to use the forum - it explains how to post you code using code tags -you also need a wiring diagram - it can be hand sketched and a picture or scan of it
then someone can look at your code and wiring and help you - you want to make it easy for people to help - i.e. don't make them guess or need to go search for things
welcome to the forum - those chips are used by the truck load and a small single wire can stop everything - so should be someone that can glance at the code and wiring and get you going in the right direction
Apologies for the lack of these, attached is a diagram of 8 switches and 1 register
and here is the code
//Code for using a Arduino Micro as a keyboard using
//Geteron switches and the HC165 Shift Registers
int latchPin = 4;
int clockPin = 5;
int dataPin = 3;
byte switchVar1 = 72; //01001000
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB
}
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
}
void loop() {
//Pulse the latch pin:
//set it to 1 to collect parallel data
digitalWrite(latchPin,1);
//set it to 1 to collect parallel data, wait
delayMicroseconds(20);
//set it to 0 to transmit data serially
digitalWrite(latchPin,0);
//while the shift register is in serial mode
//collect each shift register into a byte
//the register attached to the chip comes in first
switchVar1 = shiftIn(dataPin, clockPin, LSBFIRST);
//Print out the results.
//leading 0's at the top of the byte
//(7, 6, 5, etc) will be dropped before
//the first pin that has a high input
//reading
Serial.println(switchVar1, BIN);
//white space
Serial.println("-------------------");
//delay so all these print satements can keep up.
delay(500);
}
hope this can help you help me!
