Membuat
suatu sistem operasi dengan tampilan LCD
Dengan
kondisi :
Jika push
button Start ditekan maka L1=On L2=Off
Jika push
button Pb.1 ditekan maka M1=On M2=Off
Jika push
button Pb.2 ditekan maka M1=Off M2=On
Jika push
button Stop ditekan maka L1=Off L2=On
OUTPUT PROGRAM :
Sebelum pengoperasian mesin berjalan
Start button ditekan maka Led 1 = On
Push button 1 ditekan maka Motor 1 dan Led 1 = On sedangkan Motor 2 = Off
Push button 2 ditekan maka Motor 1 = Off sedangkan Motor 2 dan Led 1 = On
Stop button ditekan maka Led 2 = On sedangkan Motor 1, Motor 2, serta LED 1 = Off
PROGRAM :
/*************************************
This program
was produced by the
CodeWizardAVR
V2.03.4 Standard
Automatic
Program Generator
© Copyright
1998-2008 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date : 20/11/2012
Author :
Company :
Comments:
Chip type : ATmega128
Program
type : Application
Clock
frequency : 8,000000 MHz
Memory
model : Small
External RAM
size : 0
Data Stack
size : 1024
**************************************/
#include
<mega128.h>
#define on 1
#define off 0
#define
start PINF.0
#define pb1
PINF.1
#define pb2
PINF.2
#define stop
PINF.3
#define led1
PORTB.0
#define
motor1 PORTB.1
#define
motor2 PORTB.2
#define led2
PORTB.3
//
Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x12 ;PORTD
#endasm
#include
<lcd.h>
// Declare
your global variables here
void
main(void)
{
PORTB=0x00;
DDRB=0xFF;
PORTD=0x00;
DDRD=0x00;
PORTF=0x00;
DDRF=0x00;
// LCD
module initialization
lcd_init(20);
lcd_gotoxy(1,0);
lcd_putsf("Sistem
Operasi Mati");
lcd_gotoxy(2,1);
lcd_putsf("START
untuk mulai");
while (1)
{
if(start==on)
{
lcd_init(20);
lcd_gotoxy(4,0);
lcd_putsf("LED START ON");
lcd_gotoxy(0,1);
lcd_putsf("Tekan Pb1 utk
motor1");
led1=on;
led2=motor1=motor2=off;
}
if(pb1==on)
{
lcd_init(20);
lcd_gotoxy(6,0);
lcd_putsf("MOTOR 1 ON");
lcd_gotoxy(0,1);
lcd_putsf("Tekan Pb2 utk
motor2");
led1=on;motor1=on;
led2=motor2=off;
}
if(pb2==on)
{
lcd_init(20);
lcd_gotoxy(6,0);
lcd_putsf("MOTOR 2 ON");
lcd_gotoxy(1,1);
lcd_putsf("STOP untuk
berhenti");
led1=motor2=on;
led2=motor1=off;
}
if(stop==on)
{
lcd_init(20);
lcd_gotoxy(5,0);
lcd_putsf("LED STOP ON");
lcd_gotoxy(2,1);
lcd_putsf("Sistem berhenti");
led2=on;
led1=motor1=motor2=off;
}
} ;
}
Tidak ada komentar:
Posting Komentar