Professional Documents
Culture Documents
Project
Version
Date
: 11/23/2011
Author
: NeVaDa
Company
Comments
Chip type
: ATmega8
Program type
: Application
: 8.000000 MHz
Memory model
: Small
:0
: 256
*****************************************************/
#include <mega8.h>
#include <stdlib.h>
// Alphanumeric LCD Module functions
#include <alcd.h>
// SPI functions
#include <spi.h>
#include <delay.h>
// Declare your global variables here
unsigned char spi(unsigned char data);
void main(void)
{
// Declare your local variables here
unsigned char byte4, byte5, byte6, byte7, byte8, byte9;
unsigned char ID, SS;
unsigned char *tampung;
unsigned char *tampung6;
unsigned char *tampung7;
unsigned char *tampung8;
unsigned char *tampung9;
while (1)
{
// Place your code here
lcd_clear();
PORTB.2 = 0;
spi(0x01);
ID = spi(0x42);
SS = spi(0);
byte4 = spi(0);
byte5 = spi(0);
byte6 = spi(0);
byte7 = spi(0);
byte8 = spi(0);
byte9 = spi(0);
PORTB.2 = 1;
lcd_clear();
itoa(ID, tampung);
lcd_gotoxy(0,0);
lcd_puts(tampung);
if (ID == 65)
{
lcd_gotoxy(5,0);
lcd_puts("analog off");
delay_ms(500);
}
lcd_clear();
if (byte4 == 0b01111111)
{
lcd_clear();
lcd_gotoxy(0,1);
lcd_puts("left");
delay_ms(700);
}
lcd_puts("up");
delay_ms(700);
}
lcd_clear();
lcd_gotoxy(0,1);
lcd_puts("L2");
delay_ms(700);
}
lcd_clear();
lcd_gotoxy(0,1);
lcd_puts(tampung8);
lcd_gotoxy(0,5);
lcd_puts(" analog ON");
delay_ms(700);}
lcd_clear();
}
}