Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Global Variables
- const unsigned char MSG0[20] = "HW04Q3.c ";
- // Subroutine Declarations
- #include <pic18.h>
- // Subroutines
- #include "lcd_portd.c"
- // Main Routine
- void main(void)
- {
- unsigned int i, j;
- unsigned int ROLL;
- TRISA = 0;
- TRISB = 255;
- TRISC = 0;
- TRISD = 0;
- TRISE = 0;
- ADCON1 = 0x0F;
- LCD_Init(); // initialize the LCD
- LCD_Move(0,0); for (i=0; i<20; i++) LCD_Write(MSG0[i]);
- ROLL = 0;
- while(1){
- while(!RB0) {
- ROLL++;
- ROLL = (ROLL % 21);
- if(RB0)
- break;
- }
- LCD_Move(1,0); // Move to row #1, column #1
- LCD_Out(ROLL, 2, 0); // 1 decimal place, 5 digits
- if(ROLL == 20){
- for(i = 0; i<10;i++){
- PORTC = 255;
- Wait_ms(50);
- PORTC = 0;
- Wait_ms(50);
- }
- }
- while(1){
- if(RB1){
- ROLL = 0;
- LCD_Move(1,0); // Move to row #1, column #1
- LCD_Out(ROLL, 2, 0); // 1 decimal place, 5 digits
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement