Modul Panduan Belajar Mikrokontroler ATMEL dan AVR (lesmikrokontroler2005.blogspot.com) HP : 081388796849 WA : 0895800277858
Senin, 31 Maret 2014
Robot Line Follower dengan LCD maret
Skema rangkaian simulasi buat Robot Line Follower
Listing Prongramnya
#include <mega16.h>
#include <delay.h>
#include <alcd.h>
void main(void)
{
DDRB=0xff;
PORTB=0x00;
lcd_init(16);
lcd_gotoxy(0,0);
lcd_putsf("ROBOT LINE");
delay_ms(400);
lcd_gotoxy(0,1);
lcd_putsf("FOLLOWER");
delay_ms(400);
while (1)
{
// robot keadaan maju
PORTB.0=1;
PORTB.1=0;
PORTB.2=1;
PORTB.3=0;
delay_ms(900);
// robot berhenti
PORTB.0=1;
PORTB.1=1;
PORTB.2=1;
PORTB.3=1;
delay_ms(400);
// robot keadaan mundur
PORTB.0=0;
PORTB.1=1;
PORTB.2=0;
PORTB.3=1;
delay_ms(900);
//robot berhenti
PORTB.0=1;
PORTB.1=1;
PORTB.2=1;
PORTB.3=1;
delay_ms(400);
// robot berbelok kekanan
PORTB.0=1;
PORTB.1=0;
PORTB.2=1;
PORTB.3=1;
delay_ms(900);
// robot berhenti
PORTB.0=1;
PORTB.1=1;
PORTB.2=1;
PORTB.3=1;
delay_ms(400);
// robot berbelok kekiri
PORTB.0=1;
PORTB.1=1;
PORTB.2=1;
PORTB.3=0;
delay_ms(900);
// robot berhenti
PORTB.0=1;
PORTB.1=1;
PORTB.2=1;
PORTB.3=1;
delay_ms(400);
};
}
Listing Prongramnya
#include <mega16.h>
#include <delay.h>
#include <alcd.h>
void main(void)
{
DDRB=0xff;
PORTB=0x00;
lcd_init(16);
lcd_gotoxy(0,0);
lcd_putsf("ROBOT LINE");
delay_ms(400);
lcd_gotoxy(0,1);
lcd_putsf("FOLLOWER");
delay_ms(400);
while (1)
{
// robot keadaan maju
PORTB.0=1;
PORTB.1=0;
PORTB.2=1;
PORTB.3=0;
delay_ms(900);
// robot berhenti
PORTB.0=1;
PORTB.1=1;
PORTB.2=1;
PORTB.3=1;
delay_ms(400);
// robot keadaan mundur
PORTB.0=0;
PORTB.1=1;
PORTB.2=0;
PORTB.3=1;
delay_ms(900);
//robot berhenti
PORTB.0=1;
PORTB.1=1;
PORTB.2=1;
PORTB.3=1;
delay_ms(400);
// robot berbelok kekanan
PORTB.0=1;
PORTB.1=0;
PORTB.2=1;
PORTB.3=1;
delay_ms(900);
// robot berhenti
PORTB.0=1;
PORTB.1=1;
PORTB.2=1;
PORTB.3=1;
delay_ms(400);
// robot berbelok kekiri
PORTB.0=1;
PORTB.1=1;
PORTB.2=1;
PORTB.3=0;
delay_ms(900);
// robot berhenti
PORTB.0=1;
PORTB.1=1;
PORTB.2=1;
PORTB.3=1;
delay_ms(400);
};
}
Langganan:
Postingan (Atom)