/* * mmtest3.c * * Test three: run the motor continually, slowing it down over time * * Motor Mind module is conected to PORTA * FM pin on MM is connected to RA1 pin 18 * LED on RB4 via 1K resistor * * Mark Crosbie 10/31/98 mark@mastincrosbie.com */ #define MOTOR 0x5 #define MMPIN 1 #define LED 4 void main(void) { char i; set_bit(STATUS, RP0); /* select the register bank 1 */ clear_bit(TRISA, MMPIN); /* Port A.1 is output */ clear_bit(TRISB, LED); /* Port RB.4 is output */ clear_bit(STATUS, RP0); /* set the initial speed */ i = 250; while(1) { /* start the motor running */ mm_start(MOTOR, MMPIN, i); delay_s(2); /* reduce the PWM frequency. This will hit 0 and then roll over to 231 on the next iteration */ i = i - 25; /* flash the LED */ set_bit(PORTB, LED); delay_s(1); clear_bit(PORTB, LED); delay_s(1); } }