Created
November 24, 2014 16:53
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <avr/io.h> | |
#include<string.h> | |
#include<stdlib.h> | |
#include "timeout.h" | |
#include "5110/5110.h" | |
#include "5110/5110.cpp" | |
#include "introscreen.h" | |
#include "first.h" | |
#include "second.h" | |
#include "third.h" | |
#include "fourth.h" | |
#include "fifth.h" | |
#include "sixth.h" | |
#include "seventh.h" | |
#include "eight.h" | |
#include "nine.h" | |
#include "ten.h" | |
#include "correct.h" | |
#include "go.h" | |
#include "intro.h" | |
LCD_5110 lcd; | |
char words1[][13]={"ACRES","ADULT","ADVICE","ARRANGEMENT","ATTEMPT","AUGUST","AUTUMN","BORDER","BREEZE","BRICK","CALM","CANAL","CASEY","CAST","CHOSE","CLAWS","COACH","CONSTANTLY","CONTRAST","COOKIES","CUSTOMS","DAMAGE","DANNY","DEEPLY","DEPTH","DISCUSSION","DOLL","DONKEY","EGYPT","ELLEN","ESSENTIAL","EXCHANGE","EXIST","EXPLANATION","FACING"}; | |
int pos=0,ran=0,i,count=0,f=0,length; | |
char a[]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}; | |
char z[10]="< >"; | |
int main(void) | |
{ DDRC=0x00; | |
PORTC=0xFF; | |
DDRB=0xFF; | |
PORTB=0x01; | |
lcd.lcd_init(&PORTD, PD4, &PORTD, PD3, &PORTD, PD5, &PORTD, PD6, &PORTD, PD7); | |
lcd.printPictureOnLCD(intro); | |
_delay_ms(2000); | |
lcd.lcd_clear(); | |
xy: int pos=0,ran=0,i,count=0,f=0,c=0,r; | |
r=rand() / (RAND_MAX / 35 + 1); | |
char buff[13]; | |
strcpy(buff,words1[r]); | |
length=strlen(buff); | |
char disp[13]; | |
for(i=0;i<length;i++) | |
disp[i]='_'; | |
disp[i]='\0'; | |
while (1) { | |
lcd.lcd_goto_xy(4,0); | |
lcd.lcd_string_format("HANGMAN", 0); | |
//_delay_ms(200); | |
lcd.lcd_goto_xy(2,2); | |
lcd.lcd_string_format(disp, 0); | |
//_delay_ms(200); | |
lcd.lcd_goto_xy(4,4); | |
z[2]=a[pos]; | |
lcd.lcd_string_format(z, 0); | |
_delay_ms(200); | |
if(bit_is_clear(PINC, 3)) | |
{ | |
pos++; | |
if(pos==26) | |
pos=0; | |
} | |
if(bit_is_clear(PINC, 0)) | |
{ | |
pos--; | |
if(pos==-1) | |
pos=25; | |
} | |
if(bit_is_clear(PINC, 4)) | |
{ | |
for(i=0;i<strlen(buff);i++) | |
{ | |
if(buff[i]==z[2]) | |
{ | |
disp[i]=z[2]; | |
PORTB=0x02; | |
_delay_ms(200); | |
PORTB=0x00; | |
f=1; | |
if(strcmp(buff,disp)==0) | |
{ | |
lcd.printPictureOnLCD(correct); | |
PORTB=0x02; | |
_delay_ms(200); | |
PORTB=0x00; | |
_delay_ms(1800); | |
lcd.lcd_clear(); | |
goto xy; | |
} | |
} | |
} | |
if(f==0) | |
{ | |
switch(count) | |
{ | |
case 1: lcd.printPictureOnLCD(first); | |
PORTB=0x02; | |
_delay_ms(600); | |
PORTB=0x00; | |
_delay_ms(1400); | |
lcd.lcd_clear(); | |
break; | |
case 2: lcd.printPictureOnLCD(second); | |
PORTB=0x02; | |
_delay_ms(600); | |
PORTB=0x00; | |
_delay_ms(1400); | |
lcd.lcd_clear(); | |
break; | |
case 3: lcd.printPictureOnLCD(third); | |
PORTB=0x02; | |
_delay_ms(600); | |
PORTB=0x00; | |
_delay_ms(1400); | |
lcd.lcd_clear(); | |
break; | |
case 4: lcd.printPictureOnLCD(fourth); | |
PORTB=0x02; | |
_delay_ms(600); | |
PORTB=0x00; | |
_delay_ms(1400); | |
lcd.lcd_clear(); | |
break; | |
case 5: lcd.printPictureOnLCD(fifth); | |
PORTB=0x02; | |
_delay_ms(600); | |
PORTB=0x00; | |
_delay_ms(1400); | |
lcd.lcd_clear(); | |
break; | |
case 6: lcd.printPictureOnLCD(sixth); | |
PORTB=0x02; | |
_delay_ms(600); | |
PORTB=0x00; | |
_delay_ms(1400); | |
lcd.lcd_clear(); | |
break; | |
case 7: lcd.printPictureOnLCD(seventh); | |
PORTB=0x02; | |
_delay_ms(600); | |
PORTB=0x00; | |
_delay_ms(1400); | |
lcd.lcd_clear(); | |
break; | |
case 8: lcd.printPictureOnLCD(eight); | |
PORTB=0x02; | |
_delay_ms(600); | |
PORTB=0x00; | |
_delay_ms(1400); | |
lcd.lcd_clear(); | |
break; | |
case 9: lcd.printPictureOnLCD(nine); | |
PORTB=0x02; | |
_delay_ms(600); | |
PORTB=0x00; | |
_delay_ms(1400); | |
lcd.lcd_clear(); | |
break; | |
case 10: lcd.printPictureOnLCD(ten); | |
PORTB=0x02; | |
_delay_ms(600); | |
PORTB=0x00; | |
_delay_ms(1400); | |
lcd.lcd_clear(); | |
case 11: | |
lcd.lcd_goto_xy(4,4); | |
lcd.lcd_string_format(words1[r], 0); | |
_delay_ms(2000); | |
lcd.printPictureOnLCD(go); | |
PORTB=0x02; | |
_delay_ms(600); | |
PORTB=0x00; | |
_delay_ms(1400); | |
lcd.lcd_clear(); | |
goto xy; | |
break; | |
} | |
count++; | |
} | |
f=0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment