Home alarm system using Proteus, 74HC165, 74HC595 and Arduino uno.

Thread Starter

Simon Poizon Katimba

Joined Nov 6, 2016
3
I created a home alrm with 16 inputs as switches and 16 outputs as LEDs. I think i compiled and wired it right but still when i click one of the switches, the corresponding LED doesnt go on. Please help me troubleshoot this problem. It is for my project. I have attched the project files, pictures and code.

// 74HC595 74HC165
// Pin 1 - LED 1 Pin 1 - Load
// Pin 2 - LED 2 Pin 2 - Clock
// Pin 3 - LED 3 Pin 3 - Input 4
// Pin 4 - LED 4 Pin 4 - Input 5
// Pin 5 - LED 5 Pin 5 - Input 6
// Pin 6 - LED 6 Pin 6 - Input 7
// Pin 7 - LED 7 Pin 7 - Data
// Pin 8 - Negative (Ground) Pin 8 - Negative (Ground)
// Pin 9 - (Not Used) Serial out Pin 9 - (Not Used)
// Pin 10 - MR Master Reset (+) Pin 10 - (Not Used)
// Pin 11 - SHCP CLOCK Pin 11 - Input 0
// Pin 12 - STCP LATCH Pin 12 - Input 1
// Pin 13 - OE Output Enable (-) Pin 13 - Input 2
// Pin 14 - DS DATA Pin 14 - Input 3
// Pin 15 - LED 0 Pin 15 - Clock Enable (CE)
// Pin 16 - Voltage IN (+) Pin 16 - Vcc Voltage IN (+)


//74HC595 PIN OUT

// Pin 1 - LED 1
// Pin 2 - LED 2
// Pin 3 - LED 3
// Pin 4 - LED 4
// Pin 5 - LED 5
// Pin 6 - LED 6
// Pin 7 - LED 7
// Pin 8 - Negative (Ground)
// Pin 9 - (Not Used) Serial out
// Pin 10 - MR Master Reset (+)
// Pin 11 - SHCP CLOCK
// Pin 12 - STCP LATCH
// Pin 13 - OE Output Enable (-)
// Pin 14 - DS DATA
// Pin 15 - LED 0
// Pin 16 - Voltage IN (+)


//Pin connected to latch pin (ST_CP) of 74HC595 PIN 12
int latchPin = 10;
//Pin connected to clock pin (SH_CP) of 74HC595 PIN 11
int clockPin = 11; ///Pin connected to Data in (DS) of 74HC595 PIN 14
int dataPin = 12;

int load = 7; // Connects to Load pin 1 74HC165
int clockEnablePin = 4; // Connects to Clock Enable pin 15 74HC165
int dataIn = 5; // Connects to the Data pin 7 74HC165
int clockIn = 6; // Connects to the Clock pin 2 74HC165

byte incoming, incoming2;

void setup() {
Serial.begin(9600); //Pin connected to latch pin (ST_CP) of 74HC595 PIN 12
pinMode(latchPin, OUTPUT); //Pin connected to clock pin (SH_CP) of 74HC595 PIN 11
pinMode(dataPin, OUTPUT); ///Pin connected to Data in (DS) of 74HC595 PIN 14
pinMode(clockPin, OUTPUT);
pinMode(load, OUTPUT);
pinMode(clockEnablePin, OUTPUT);
pinMode(clockIn, OUTPUT);
pinMode(dataIn, INPUT);
pinMode(2, OUTPUT);
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(load,LOW);
delayMicroseconds(5);
digitalWrite(load,HIGH);
delayMicroseconds(5);

digitalWrite(clockIn,HIGH);
digitalWrite(clockEnablePin,LOW);
byte incoming = shiftIn(dataIn, clockIn, LSBFIRST);
byte incoming2 = shiftIn(dataIn, clockIn, LSBFIRST);
digitalWrite(clockEnablePin,HIGH);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, incoming ); //1-8 digitalWrite(latchPin, HIGH);

// Shift out to 74HC595
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, incoming2 );
shiftOut(dataPin, clockPin, LSBFIRST, incoming ); //1-8
digitalWrite(latchPin, HIGH);
delay(50);


Serial.print("Pin States 1-8:\r\n");
Serial.println(incoming, BIN);
Serial.print("Pin States 9-16:\r\n");
Serial.println(incoming2, BIN);
Serial.print("\r\n");
Serial.print("\r\n");
delay(200);

if (incoming == B10000001) // if switch 8 is high
{
digitalWrite(13, HIGH);
}
if (incoming == B10000000)
{
digitalWrite(13,LOW);
}

if (incoming2 == B10000001) // if switch 8 is high
{
digitalWrite(2, HIGH);
}
if (incoming2 == B10000000)
{
digitalWrite(2,LOW);
}}
 

Attachments

Last edited:

dannyf

Joined Sep 13, 2015
2,197
if (incoming == B10000001) // if switch 8 is high
if you want to test individual pins' state, you can do something like this:

Code:
  if (incoming & SW_8) ...
when SW_8 is a mask associated with the pin that switch 8 is connected to.
 
Top