NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

ORG 0000H
SJMP MAIN ; Jump to main program

ORG 0030H
ADC_DATA EQU 30H ; Define ADC_DATA memory location

MAIN:
CALL INIT_SERIAL ; Initialize serial communication
CALL LCD_INITIALISE ; Initialize LCD

SETB P0.0 ; RELAY ON
CLR P0.1 ; BUZZER ON
CALL LCD_LOADING ; Display loading message

MOV P2, #0FFH ; Set P2 as input for ADC
CALL LCD_DISPLAY_INIT ; Display "GAS:000PPM R:OFF"

CLR P0.1 ; BUZZER OFF
CALL DELAY_500MS ; Initial delay

LOOP:
CALL ADC_READ ; Read ADC value
MOV A, ADC_DATA ; Move ADC data to A
CALL LCD_UPDATE ; Update LCD display

MOV B, #80
CJNE A, B, CHECK_SAFE
SJMP ALERT

CHECK_SAFE:
JC SAFE ; If A < 80, jump to SAFE state
SJMP ALERT ; Otherwise, go to ALERT

SAFE:
CALL SAFE_STATE ; If gas is normal, keep relay ON
SJMP LOOP ; Repeat process

;------------------------------------------------
; ADC READ FUNCTION
;------------------------------------------------
ADC_READ:
CLR P0.6 ; WR = 0 (Start conversion)
SETB P0.6 ; WR = 1 (End conversion)

WAIT_INTR:
JNB P0.5, WAIT_INTR ; Wait until INTR = 0 (conversion complete)

CLR P0.7 ; RD = 0 (Read ADC Data)
MOV ADC_DATA, P2 ; Store ADC Data
SETB P0.7 ; RD = 1 (Stop read)
RET

;------------------------------------------------
; LCD DISPLAY UPDATE
;------------------------------------------------
LCD_UPDATE:
CALL LCD_CMD ; Ensure cursor is set
MOV A, ADC_DATA
CALL LCD_WRITE_DIGITS ; Convert and write to LCD
RET

;------------------------------------------------
; ALERT FUNCTION
;------------------------------------------------
ALERT:
CLR P0.0 ; RELAY OFF
CLR P0.1 ; BUZZER ON
CALL LCD_ALERT_MSG ; Display "G:HIGH V:CLOSE"
CALL SEND_SMS ; Send SMS Alert
SJMP LOOP
RET

;------------------------------------------------
; SAFE STATE FUNCTION
;------------------------------------------------
SAFE_STATE:
SETB P0.0 ; RELAY ON
SETB P0.1 ; BUZZER OFF
CALL LCD_SAFE_MSG ; Display "G:NORMAL V:OPEN"
RET

;------------------------------------------------
; SEND SMS FUNCTION (Basic GSM Module Commands)
;------------------------------------------------
SEND_SMS:
MOV DPTR, #MSG
CALL SEND_STRING ; Send the SMS message string
RET

SEND_STRING:
CLR A
SEND_LOOP:
MOVC A, @A+DPTR ; Load character from memory
JZ END_STRING ; If NULL terminator, exit
CALL SEND_CHAR ; Send character via serial
INC DPTR
SJMP SEND_LOOP

END_STRING:
RET

MSG:
DB "VOLVE CLOSED AND POWER DISCONNECTED DUE TO GAS LEAKAGE!", 0

;------------------------------------------------
; LCD FUNCTION PROTOTYPES
;------------------------------------------------
LCD_INITIALISE:
; LCD Initialization Code
RET

LCD_LOADING:
; Display "LOADING...."
RET

LCD_DISPLAY_INIT:
; Display "GAS:000PPM R:OFF"
RET

LCD_CMD:
; LCD Command Function (Set cursor position)
RET

LCD_WRITE_DIGITS:
; Convert ADC Data to ASCII and display on LCD
RET

LCD_ALERT_MSG:
; Display "G:HIGH V:CLOSE"
RET

LCD_SAFE_MSG:
; Display "G:NORMAL V:OPEN"
RET

;------------------------------------------------
; DELAY FUNCTION (500ms)
;------------------------------------------------
DELAY_500MS:
MOV R0, #200
DELAY1:
MOV R1, #255
DELAY2:
DJNZ R1, DELAY2
DJNZ R0, DELAY1
RET

END
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.