Whistle-On Whistle-Off

This experiment turns on a LED when a whistle is detected. The LED turns off when the whistle is detected for the second time.  

                    ;Expt11b.asm
;Project: Whistle-On  Whistle-Off

List P = 16F84
#include <p16F84.inc>
__CONFIG 1Bh    ;_CP_OFF & _PWRTE_ON & _WDT_OFF & _RC_OSC

SetUp
Delay

Delay1

DelayA

Look

Look1

Look2

Main

Main1

Main2

Main3

ORG 00
BSF 03,5
CLRF 06
MOVLW 02
MOVWF 05
BCF 03,5
CLRF 1F
CLRF 05
CLRF 06
GOTO Main
NOP
DECFSZ 1A,1
GOTO Delay
RETURN

MOVLW 40h
MOVWF 1B
DECFSZ 1A,1
GOTO DelayA
DECFSZ 1B,1
GOTO DelayA
RETURN

BCF 1F,0
MOVLW 040h
MOVWF 0E
CLRF 0Ch
CALL Delay
BTFSC 05,1
GOTO look2
INCF 0Ch,1
DECFSZ 0E,1
GOTO Look1
MOVLW 18h
SUBWF 0Ch,0
BTFSS 03,0
RETURN
BSF 1F,0
RETURN

CALL Look
BTFSS 1F,0
GOTO Main
MOVLW 04
MOVWF 06
CALL Delay1
CALL Look
BTFSC 1F,0
GOTO Main1
CALL Delay1
CALL Look
BTFSS 1F,0
GOTO Main2
MOVLW 00
MOVWF 06
CALL Delay1
CALL Look
BTFSC 1F,0
GOTO Main3
GOTO Main

END

;Start of memory for program.
;Go to Bank 1
;Make all port B output
;Load W with 0000 0010
;Make RA1 input
;Go to Bank 0 – the program memory area.
;Clear flag file
;Clear the display
;Clear the display
; Create 1mS delay

;Clear the “whistle” flag
;Number of loops
;Loops file
;Holds the LOW count

;LOW detected

;Test Carry flag. If set C=more than 10h

;Whistle detected

;No whistle
;Whistle – turn on display

;whistle

;No whistle
;Whistle – turn off display

;whistle
;no whistle

EXPERIMENT 12
Light Detection

Light Detection
This experiment detects the presence of light. A photo-darlington transistor is connected to the circuit via a plug and socket and exposed to light. The change in resistance of the photo-darlington transistor creates a voltage change across it and this is amplified by the circuit and delivered to an input of the microcontroller. The program turns on the 8 LEDs when the photo-darlington transistor detects change in illumination.
The photo-darlington transistor is connected to the circuit via a capacitor and only CHANGES in illumination are detected.
If the illumination is decreased, a point will be obtained where the circuit is sensitive to the changes in supply rail voltage. At this point the circuit will start to oscillate or MOTOR-BOAT.
The circuit must be re-designed to prevent this from occurring.
If the photo-darlington transistor is placed in a room with incandescent lighting, the 50 or 60Hz from the light will be detected. These pulses must be dealt with by the program to obtain a reliable HIGH/LOW pulse. 

 

For more detail: Whistle-On  Whistle-Off

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter