DC Motor Control With Joystick and PIC16F877A

Introduction: DC Motor Control With Joystick and PIC16F877A

This is one project that i'm doing, now I'm going to show how to do it only for one motor, but i'm using and DEMUX to in the future use 4 motor.

The project is simple, it uses the pic to control the DEMUX and the DEMUX control the H-BRIDGE that control the motor forward or backward.

Step 1: Part List

The itens that you will need is in the picture below.
Board not in picture, but you will need right?

Step 2: Schematic

The H-Bridge schematic, sorry about the mess.
The print version is in PDF file

My motor works with 15V, but with the TIP31 I can put much more than that.

Step 3: Schematic

This is the schematic for the connections with the PIC16F877A.

The JP1 is VCC and GND, the JP2 is where you connect the motor, inverter is necessary for this, because the DEMUX work in logical level low, but if you have one thats work in high you can remove inverters ports.

The Pot is the ANALOG input, where I will connect my Joystick.

The PWM is the port RC2/CCP1 and goes to DEMUX.

The DEMUX is very simple, look in the link below for the datasheet.

Step 4: The Code

After everything is connected, make sure the supply for PIC is 5V, for my case, supply for the H-Bridge is 15V and the ground of both must have the same GND.

Now my code is very simple. It recive the Voltage from the Joystick that works igual a potentiometer, and calculate PWM duty and the direction of the rotation of the motor.

Donwload the PDF or the TXT file.

Step 5: Conclusion

This is the video demostrantion of the project working, its hard to see but belive me, if every thing is correct the motor will rotate to both directions.





    • Creative Misuse Contest

      Creative Misuse Contest
    • Water Contest

      Water Contest
    • Fix It! Contest

      Fix It! Contest

    11 Discussions


    2 years ago

    Where is the potentiometer's place in schematic and on breadboard?

    Also i can see 4 push buttons u didnt say any thing aboutem

    Ok the pot controls the speed but how to control the direction

    Problem happen when i try to build:

    undeclared identifer 'pwm_init' in expression

    anyone can help me? email me at mrbracepaul@gmail.com

    Hello Mr.Nabeyama
    you projects look very interesting and I would like to built for motorizing an telescope focuser, but I have questions ffor you . The questions are:
    Please could you send me a copy of the .Hex file for download the PIC 16F877A and electronics schematics ?
    How you replace the potenciometer with the joystick, because joystick has many positions a many cables ?

    best regards

    hello sir..can you show the schematic circuit diagram completed of your circuit to control the motor? because i don't get it how you connect the joystick to pic/circuit...did you used joystick ps2?because total wire from joystick is 8..

    I am new to the electronic project
    I am planning to do the same for my project based on that
    I have a few clarifications
    Here in dig 2 : Q1 stand for???
    and the work of potentiometer???
    here i dint understand the connection for joystick (where to be connected)
    In parts listing its said that joystick is replaced by potentiometer which mean either of these are to be used
    can u please clarify me the above

    1 reply

    Hello, need help.. can i use this project to control 8 DC motor? what should i change?

    sir can you post a clearer picture of the schematic? i cant view it. Please. Im planning to do the same project. Thanks.