Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- #define F_CPU 1000000UL
- #include <stdlib.h>
- #include <util/delay.h>
- #include "4bit-ifc.c"
- #include <time.h>
- int main(void)
- {
- DDRD=0xFF;
- DDRC=0x00;
- lcd_init();
- lcd_clear();
- srand(time(NULL));
- while (1)
- {
- int p = rand()%32;
- if (bit_is_clear (PINC,0)){
- if (p>=0 && p<=16)
- {
- int r=rand()%16;
- lcd_cmd(0x80+r);
- lcd_write((unsigned char *) "+");
- _delay_ms(500);
- lcd_clear();
- }
- if (p>=17 && p<=32){
- int d=rand()%16;
- lcd_cmd(0xc0+d);
- lcd_write((unsigned char *) "+");
- _delay_ms(500);
- lcd_clear();
- }
- }
- if (bit_is_clear (PINC,1)){
- if (p>=0 && p<=16)
- {
- int r=rand()%16;
- lcd_cmd(0x80+r);
- lcd_write((unsigned char *) "*");
- _delay_ms(500);
- lcd_clear();
- }
- if (p>=17 && p<=32){
- int d=rand()%16;
- lcd_cmd(0xc0+d);
- lcd_write((unsigned char *) "*");
- _delay_ms(500);
- lcd_clear();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement