16 Eylül 2017 Cumartesi

Control a DC Motor


Proteus: We will use RC0 and RC1 output to control the motor. L293D will drive the motor. 
RC0=1, RC1=0 will turn CW
RC0=0, RC1=1 will turn CCW
RC0=0, RC1=0 will stop



MCC:  just set RC0, RC1 as output. 1MHZ, INTOSC, disable MCLR

XC8: inside the main while(1) loop you can change RC0, RC1 pins as you want. turn CW, turn CCW and stop for example.

    while (1)
    {
        // Add your application code
        IO_RC0_SetHigh();
        __delay_ms(2000);
        IO_RC0_SetLow();
        IO_RC1_SetHigh();
        __delay_ms(2000);
        IO_RC0_SetLow();
        IO_RC1_SetLow();
        __delay_ms(2000);
       
    }

download the example

Hiç yorum yok:

Yorum Gönder