// Stepper1.C // Drive a stepper motor at 100ms/step // Global Variables const unsigned char MSG[16] = "Stepper1.C "; unsigned char TABLE[4] = {1, 2, 4, 8}; // Subroutine Declarations #include #include "LCD_PortD.C" // High-priority service // Main Routine void main(void) { int i, STEP; TRISA = 0; TRISB = 0; TRISC = 0; TRISD = 0; TRISE = 0; ADCON1 = 0x0F; STEP = 0; // Initialize the LCD display LCD_Init(); LCD_Move(0,0); for (i=0; i<16; i++) LCD_Write(MSG[i]); Wait_ms(100); while(1) { STEP = STEP + 1; PORTC = TABLE[STEP % 4]; LCD_Move(1,0); LCD_Out(STEP,0, 5); Wait_ms(100); } }