Sensor Alarm w/ Threshold Control & Seven Segment Display
This sensor alarm allows the user to set the alarm threshold via potentiometer and displays the threshold value or the sensor value on a seven segment display.
This project allows you to interface with just about any sensor that provides analog output, set a threshold value, activly observe the sensor's values (or the threshold value), and sound an alarm (and light an LED) when the sensor value exceeds the threshold you set. The threshold is set by moving the slide switch to the left and adjusting the potentiometer. Once the value is set, slide the switch to the right and observe the sensor values on the seven segment display.
I am using MQ series sensors to detect gas and sound an alarm (an active piezo and a LED) if the gas sensor exceeds the threshold amount set with the potentiometer. There's no reason why this project wouldn't work for any kind of sensor, as long as the sensor has ground, power, and analog out. The project displays numerals and characters on a series of 3 single character seven segment displays set up in a circuit with S8550 PNP transistors for multiplexed switching. A shift register, 74HC595, is used to shuttle a value to all of the SS displays, and the transistor for the character position for which the value is intended is switched on. When the next number comes through the shift register, it's transistor is turned on, and so on. Values are mapped so as to light the correct segments on the display. See sensorDetector.h for the mapping. The setup includes 8 330ohm resistors to prevent you from overloading a segment of the display with 5v emitting from the shift register, 3 common cathode single character seven segment displays, 3 S8550 pnp transistors (other pnp transistors might also work) for switching on the seven segment leds, a 74HC595 shift register, 4 resistors for the transistor switching, a sensor, and a potentiometer for setting the alarm threshold. For this project we're using active-lo PNP (emitter follower) transistors as "sinking" drivers connected to ground.
The program will include functions for sending debuging output to a serial display via the ATMega 328's RXD and TXD lines. You will need a USB serial adapter to see the output. You will also need an AVR programmer if you're going to change the code, as well as Atmel Stuidio or similar setup. The Arduino IDE is not necessary for this project, but there's no reason why this wouldn't work with an arduino.
The ATMega328p-pu runs at 8mHz, use AVRDude, Atmel Studio or similar to set the fuse values.
I am C programming language novice, any feedback is welcome.
Here is the parts list:
1 Atmel ATMega328p-pu or 168p-pu
1 74HC595 shift register
3 common cathode single digit seven segment displays
1 analog sensor (e.g. MQ series gas sensors)
1 active piezo buzzer
1 slide switch
1 tactile push button
3 S8550 pnp transistors
1 BC547 npn transistor
1 10k potentiometer
10 330ohm resistors
1 10k resistor
1 4.7k ohm resistor
1 terminal block
2 10uF electrolic capacitors
2 100nF ceramic capacitors
1 L7805 5v regulator
2 LEDs (I have 1 yellow, one red)
hookup wire; black, red, green yellow
1 800point breadboard
NOTE: This project shows a MQ-7 CO gas detector in use because this is the only working gas detector that I have. The MQ-7 sensor requires an alternating 1.4v and 5v, which needs to be achieved via pulse width modulation (PWM). That feature is not present in this project, and I intend to substitute a methane sensor (MQ-4) for the MQ-7 when it arrives from China.