0% found this document useful (0 votes)
12 views

Program Flood Sensor

This code initializes an LCD module and displays different warning messages on it depending on the state of buttons connected to port B of a microcontroller. It sets port B as input, port D as output, initializes the LCD, then enters a loop that checks the button states using a switch statement and displays the corresponding message by changing the port D output and using LCD functions.

Uploaded by

Okto Prasetiyo I
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Program Flood Sensor

This code initializes an LCD module and displays different warning messages on it depending on the state of buttons connected to port B of a microcontroller. It sets port B as input, port D as output, initializes the LCD, then enters a loop that checks the button states using a switch statement and displays the corresponding message by changing the port D output and using LCD functions.

Uploaded by

Okto Prasetiyo I
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <mega8535.h> // Alphanumeric LCD Module functions #asm .equ __lcd_port=0x15 ;PORTC #endasm #include <lcd.h> #include <stdio.

h> void main(void) { // Declare your local variables here PORTB = 0xFF ; DDRB = 0x00 ; PORTD = 0xFF ; DDRD = 0xFF; // LCD module initialization lcd_init(16); while (1) { // Place your code here switch (PINB) { case 0xBF : PORTD = 0xFE ; lcd_gotoxy(0,0); lcd_putsf("AMAN break; case 0xAF : PORTD = 0xFB ; lcd_gotoxy(0,0); lcd_putsf("SIAGA break; case 0xAB : PORTD = 0xEF; lcd_gotoxy(0,0); lcd_putsf("WASPADA break; case 0xAA : PORTD = 0xAF; lcd_gotoxy(0,0); lcd_putsf("OVERFLOW break; default : PORTD = 0xFF; lcd_gotoxy(0,0); lcd_putsf(" "); } }; }

");

");

");

");

You might also like