Advertisement
Guest User

erik je kral

a guest
Jun 14th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <avr/io.h>
  2. #define F_CPU 1000000UL
  3. #include <stdlib.h>
  4. #include <util/delay.h>
  5. #include "4bit-ifc.c"
  6. #include <time.h>
  7.  
  8.  
  9. int main(void)
  10. {
  11. DDRD=0xFF;
  12. DDRC=0x00;
  13. lcd_init();
  14. lcd_clear();
  15. srand(time(NULL));
  16.  
  17. while (1)
  18. {
  19.  
  20.  
  21. int p = rand()%32;
  22. if (bit_is_clear (PINC,0)){
  23. if (p>=0 && p<=16)
  24. {
  25. int r=rand()%16;
  26. lcd_cmd(0x80+r);
  27. lcd_write((unsigned char *) "+");
  28. _delay_ms(500);
  29. lcd_clear();
  30. }
  31. if (p>=17 && p<=32){
  32. int d=rand()%16;
  33. lcd_cmd(0xc0+d);
  34. lcd_write((unsigned char *) "+");
  35. _delay_ms(500);
  36. lcd_clear();
  37. }
  38.  
  39. }
  40. if (bit_is_clear (PINC,1)){
  41. if (p>=0 && p<=16)
  42. {
  43. int r=rand()%16;
  44. lcd_cmd(0x80+r);
  45. lcd_write((unsigned char *) "*");
  46. _delay_ms(500);
  47. lcd_clear();
  48. }
  49. if (p>=17 && p<=32){
  50. int d=rand()%16;
  51. lcd_cmd(0xc0+d);
  52. lcd_write((unsigned char *) "*");
  53. _delay_ms(500);
  54. lcd_clear();
  55. }
  56.  
  57. }
  58.  
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement