Im fairly new to this and have some basic understandings. What im wanting to do is place buttons on the 0-7 on the 74HC165 and have the arduino process it and send the data down a patch cable to 74HC595. I have it all wired up and semi working. Im using a example code and its using the "tick" command which im not understanding and its remember the last value and the LED stays on at the 595. It is possible to keep 4 of those like that with debounce and make the other 4 just momentary.
Its not clear where your problems lie - could you provide some details like how its
wired up, the example code you are working with, clues as to what you have
working and what you have not?
This is the code im using. I have the inputs all pulled to ground. Problem is say when i trigger #2, #2 stays on until i trigger it again, but needs a debounce added. Im trying to get 1-4 to act that way with the debounce added, but i would want 5-8 to turn off as soon as i release the button on the 165.
#include <C165.h>
#include <C595.h>
C165 WButtons = C165(13,8,10,1);
C595 WLEDs = C595(11,10,9,1);
unsigned int WLEDsTemp = 0;
unsigned int WButtonsTemp = 0;
void setup()
{
//
}
void loop()
{
WButtonsTemp = WButtons.tick();
if (WButtonsTemp)
{
WLEDsTemp ^= WButtonsTemp;
WLEDs.tick(WLEDsTemp);
WButtons.reset();
}
}
[code tags are there for code,
// like this
#include <C165.h>
#include <C595.h>
So next question is what are those libraries - where do we find them, which version do you
have.... It always helps to provide all the information needed to reproduce a problem,
so that we can reproduce the actual problem (and not a different one!)
Here is the code
#include <C165.h>
#include <C595.h>
C165 WButtons = C165(13,8,10,1);
C595 WLEDs = C595(11,10,9,1);
unsigned int WLEDsTemp = 0;
unsigned int WButtonsTemp = 0;
void setup()
{
//
}
void loop()
{
WButtonsTemp = WButtons.tick();
if (WButtonsTemp)
{
WLEDsTemp ^= WButtonsTemp;
WLEDs.tick(WLEDsTemp);
WButtons.reset();
}
}
Here is C165.h
/*
Created by WilliamK @ Wusik Dot Com (c) 2010
http://arduino.wusik.com
8 to 16 Inputs with only 3 pins on the Arduino using the following chip: 74HC165N
http://www.sparkfun.com/products/9519
Typical Usage:
Setup:
C165 inputs = C165(25,27,26,2);
// C165( Connects to Parallel load pin the 165,
// Connects to the Q7 (data) pin the 165,
// Connects to the Clock pin the 165,
// Number of C165 Chips - 1 or 2);
Loop:
unsigned int tempinputs = inputs.tick();
if (tempinputs) // Returns > 0 if something changed //
{
// Check each bit now //
if (bitRead(tempinputs,1)) Serial.println("1 Changed !");
if (bitRead(tempinputs,7)) Serial.println("7 Changed !");
// Call Reset so it restarts //
inputs.reset();
}
*/
#ifndef C165_h
#define C165_h
#include <inttypes.h>
#include "HardwareSerial.h"
class C165
{
public:
C165(uint8_t _loadPin, uint8_t _dataPin, uint8_t _clockPin, uint8_t _chips);
unsigned int tick(void);
void reset(void);
private:
uint8_t loadPin;
uint8_t dataPin;
uint8_t clockPin;
uint8_t chips;
unsigned int values;
unsigned int prevvalues;
unsigned int prevhigh;
};
#endif
Here is C595
/*
Created by WilliamK @ Wusik Dot Com (c) 2010
http://arduino.wusik.com
8 to 16 Outputs with only 3 pins on the Arduino using the following chip: 74HC595
http://www.sparkfun.com/products/733
Typical Usage:
Variables:
C595 outputs = C595(22,24,23,2);
unsigned int outvalue = 0;
// C595(Latch Pin, Clock Pin, Data Pin, Number of Chips - 1 or 2) //
Loop:
outvalue = 61680; // 1111000011110000
outputs.tick(outvalue);
// Or you can also use bitRead/bitWrite //
bitWrite(outvalue,0,1);
bitWrite(outvalue,1,1);
bitWrite(outvalue,2,0);
bitWrite(outvalue,3,1);
// ... //
bitWrite(outvalue,15,1);
*/
#ifndef C595_h
#define C595_h
#include <inttypes.h>
#include "HardwareSerial.h"
// ======================================================================================= //
class C595
{
public:
C595(uint8_t _latchPin, uint8_t _clockPin, uint8_t _dataPin, uint8_t _chips);
void tick(unsigned int output);
private:
uint8_t latchPin;
uint8_t clockPin;
uint8_t dataPin;
uint8_t chips;
};
#endif
I am using Arduino 1.0.5 on win 7 x64.
So i found a view of what im trying to accomplish but cant fine a code. here is the youtube link just skip in to ~6:50
74HC595: http://www.gammon.com.au/forum/?id=11518
74HC165: Gammon Forum : Electronics : Microprocessors : Using a 74HC165 input shift register
I have all that but i cant just seem to get the shiftIN to just do a simple shiftOUT
but i cant just seem to get the shiftIN to just do a simple shiftOUT
I don't see any example of you trying this.
Rob
i wrote a example but its not working right, i need output to be low when input is low
Have you looked at the Arduino shiftIn and shiftOut commands?