Anda di halaman 1dari 8

Nama

: Ilham Romadhona

NIM

: 02858
TUGAS ELEKTRONIKA

Mapping

S0

S1

S2

S3

--> Belok Kanan cepat

--> belok kanan lambat

--> belok kiri lambat

--> belok kiri cepat

-->belok kanan lambat

-->lurus lambat

-->belok kiri lambat

-->lurus cepat

-->belok kanan lambat

-->belok kiri lambat

-->belok kanan lambat

-->belok kiri lambat

-->lurus lambat

-->lurus lambat

-->stop

-->lurus lambat

GAMBAR

PROGRAM
#include <mega8535.h>
#include <alcd.h>
void main(void)
{
PORTA=0x00;
DDRA=0xFF;
PORTB=0x00;
DDRB=0x00;
PORTC=0x00;
DDRC=0xFF;
PORTD=0x00;
DDRD=0xFF;

lcd_init(16);

while (1)
{
if (PINB.0==1&&PINB.1==0&&PINB.2==0&&PINB.3==0)
{
PORTC=0b00000101;
OCR1A=255;
lcd_gotoxy(0,0);
lcd_putsf("Belok Kanan Cepat
}

");

if (PINB.0==0&&PINB.1==1&&PINB.2==0&&PINB.3==0)
{
PORTC=0b00000101;
OCR1A=100;
lcd_gotoxy(0,0);
lcd_putsf("Maju Pelan

");

}
if (PINB.0==0&&PINB.1==0&&PINB.2==1&&PINB.3==0)
{
PORTC=0b00101000;
OCR1B=100;
lcd_gotoxy(0,0);
lcd_putsf("Maju Pelan

");

}
if (PINB.0==0&&PINB.1==0&&PINB.2==0&&PINB.3==1)
{
PORTC=0b00101000;
OCR1B=255;
lcd_gotoxy(0,0);
lcd_putsf("Belok Kiri Cepat

");

}
if (PINB.0==1&&PINB.1==1&&PINB.2==0&&PINB.3==0)
{
PORTC=0b00000101;
OCR1A=100;

lcd_gotoxy(0,0);
lcd_putsf("Belok Kanan Pelan

");

}
if (PINB.0==0&&PINB.1==1&&PINB.2==1&&PINB.3==0)
{
PORTC=0b00101101;
OCR1A=100;
OCR1B=100;
lcd_gotoxy(0,0);
lcd_putsf("Maju Pelan

");

}
if (PINB.0==0&&PINB.1==0&&PINB.2==1&&PINB.3==1)
{
PORTC=0b00101000;
OCR1A=100;
lcd_gotoxy(0,0);
lcd_putsf("Belok Kiri Pelan

");

}
if (PINB.0==1&&PINB.1==0&&PINB.2==0&&PINB.3==1)
{
PORTC=0b00101101;
OCR1A=255;
lcd_gotoxy(0,0);
lcd_putsf("Maju Cepat
}

");

if (PINB.0==1&&PINB.1==0&&PINB.2==1&&PINB.3==0)
{
PORTC=0b00101101;
OCR1A=255;
OCR1B=100;
lcd_gotoxy(0,0);
lcd_putsf("Belok Kanan Pelan

");

}
if (PINB.0==0&&PINB.1==1&&PINB.2==0&&PINB.3==1)
{
PORTC=0b00101101;
OCR1B=255;
OCR1A=80;
lcd_gotoxy(0,0);
lcd_putsf("Belok Kiri Pelan

");

}
if (PINB.0==1&&PINB.1==1&&PINB.2==1&&PINB.3==0)
{
PORTC=0b00101101;
OCR1A=100;
OCR1B=70;
lcd_gotoxy(0,0);
lcd_putsf("Belok Kanan Pelan

");

}
if (PINB.0==0&&PINB.1==1&&PINB.2==1&&PINB.3==1)

{
PORTC=0b00101101;
OCR1A=80;
OCR1B=180;
lcd_gotoxy(0,0);
lcd_putsf("Belok Kiri Pelan

");

}
if (PINB.0==1&&PINB.1==0&&PINB.2==1&&PINB.3==1)
{
PORTC=0b00101101;
OCR1A=190;
OCR1B=180;
lcd_gotoxy(0,0);
lcd_putsf("Maju Pelan

");

}
if (PINB.0==1&&PINB.1==1&&PINB.2==1&&PINB.3==1)
{
PORTC=0b00101101;
OCR1A=200;
OCR1B=200;
lcd_gotoxy(0,0);
lcd_putsf("Maju Pelan

");

}
if (PINB.0==0&&PINB.1==0&&PINB.2==0&&PINB.3==0)
{

PORTC=0b00000000;
lcd_gotoxy(0,0);
lcd_putsf("BERHENTI
}
}
}

");