Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. // Global Variables
  2.  
  3. const unsigned char MSG0[20] = "HW04Q3.c ";
  4.  
  5. // Subroutine Declarations
  6. #include <pic18.h>
  7.  
  8. // Subroutines
  9. #include "lcd_portd.c"
  10.  
  11. // Main Routine
  12.  
  13. void main(void)
  14. {
  15. unsigned int i, j;
  16. unsigned int ROLL;
  17.  
  18. TRISA = 0;
  19. TRISB = 255;
  20. TRISC = 0;
  21. TRISD = 0;
  22. TRISE = 0;
  23. ADCON1 = 0x0F;
  24.  
  25. LCD_Init(); // initialize the LCD
  26.  
  27. LCD_Move(0,0); for (i=0; i<20; i++) LCD_Write(MSG0[i]);
  28.  
  29. ROLL = 0;
  30.  
  31. while(1){
  32.  
  33. while(!RB0) {
  34. ROLL++;
  35. ROLL = (ROLL % 21);
  36. if(RB0)
  37. break;
  38. }
  39.  
  40.  
  41.  
  42. LCD_Move(1,0); // Move to row #1, column #1
  43. LCD_Out(ROLL, 2, 0); // 1 decimal place, 5 digits
  44.  
  45. if(ROLL == 20){
  46. for(i = 0; i<10;i++){
  47. PORTC = 255;
  48. Wait_ms(50);
  49. PORTC = 0;
  50. Wait_ms(50);
  51. }
  52. }
  53. while(1){
  54. if(RB1){
  55. ROLL = 0;
  56. LCD_Move(1,0); // Move to row #1, column #1
  57. LCD_Out(ROLL, 2, 0); // 1 decimal place, 5 digits
  58. break;
  59. }
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement