Hi all,
I'm building a piggyback board that extends input and out put pins on arduino uno. Got my 74HC565s working nicely. code might be a bit clunky but i like it that way - i can see whats going on.
I'm trying to get some code to work that I found in this forum, i've modified it a bit but its not giing me an expected output in the serial monitor.
I've pulled the inputs to the 165 to ground and have buttons that send +5v to the inputs of the 165.
when any of the buttons are pressed the serial monitor changes from 00000000 to 11111111. i'd have expected the serial monitor to put 1's depending n which input to the 165 went high.
any thoughts???
Many thanks
Neal
(P.S. fantastic forum!)
//pins
int inclearPin = 11; // enablepin 74HC165pin 15
int indataPin = 9; //74HC165 pin 7
int inclockPin = 10; //74HC165 pin 2
int inloadPin = 12; // toggling this tells the 165 to read the value into its memory for reading 74HC165pin1
int temp = 0;
void setup() {
//start serial
Serial.begin(9600);
//165
pinMode(inclearPin, OUTPUT);
digitalWrite(inclearPin, 0); // enable input, you could also tie this pin to GND
pinMode(indataPin, INPUT);
pinMode(inclockPin, OUTPUT);
pinMode(inloadPin, OUTPUT);
}
void loop() {
digitalWrite(inloadPin, 0); // read into register (tells the 165 to take a snapshot of its input pins)
digitalWrite(inloadPin, 1); // done reading into register, ready for us to read
for(int i=0; i<=7; i++){ // read each of the 165's 8 inputs (or its snapshot of it rather)
// tell the 165 to send the inputs pin state
digitalWrite(inclockPin, 0);
// read the current output
temp = digitalRead(indataPin); // read the state
// tell the 165 we are done reading
digitalWrite(inclockPin, 1);
Serial.print (temp);
}
Serial.println ("");
Serial.println ("--------");
delay(200);
}