Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to code 12 dc motor using pic16f877a in c language with l293

Status
Not open for further replies.

indio_19gen

Newbie level 3
Newbie level 3
Joined
Dec 24, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,307
Good day! Can anyone help me to solve this problems. I have already the code in c language and I would like to use sensor but i don't know how to code it. When sensor is activated means is ON the motor will stop then if sensor is OFF the motor is activated. And also, i want to use LED to indicates the motor directions. I have attached my simulation here. Can you please help me about this. Thanks

this is the link of simulation:
https://obrazki.elektroda.pl/6434967200_1356351832.jpg

here's the code that i have.

Code:
#include<16F877A.h>
#fuses HS, NOPUT, NOLVP
#use delay(clock=20Hz)


 void main()
  {
   while(true)
    {
//-------------------------------for motor operation
     if(!input(PIN_D0))//---------microswitch 
      {
//-------------------------------switch for reversing     
       output_high(PIN_B2);//----clockwise mode
       
        if(!input(PIN_D1))
        {
          output_high(PIN_B0);
          output_low(PIN_B1);
        }
       else if(!input(PIN_D2))//-----counter clockwise mode
        {
          output_high(PIN_B1);
          output_low(PIN_B0);
        }
      }
   else if(input(PIN_D0))
      {
       output_low(PIN_B2);
      }
}
}
 
Last edited by a moderator:

What sensor are you using?

Code:
#include<16F877A.h>
#fuses HS, NOPUT, NOLVP
#use delay(clock=20Hz)


void main()
{
	while(true)
	{
		//-------------------------------for motor operation
		if(!input(PIN_D0))//---------microswitch 
		{
			//-------------------------------switch for reversing 
			output_high(PIN_B2);//----clockwise mode

			if(!input(PIN_D1))
			{
				output_high(PIN_B0);
				output_low(PIN_B1);
				//Add led code here
				output_low(PIN_B4);
				output_high(PIN_B3);

			}
			else if(!input(PIN_D2))//-----counter clockwise mode
			{
				output_high(PIN_B1);
				output_low(PIN_B0);
				//Add led code here
				output_low(PIN_B3);
				output_high(PIN_B4);

			}
		}
		else if(input(PIN_D0))
		{
			output_low(PIN_B2);
		}
	}
}
 
Last edited:
Thanks bro,its work fine. Another one is for the sensor on how to add the code. As you noticed in my simulation that i have attached here. I USED switch placed in PIN_d3 this is for my sensor. I used IR Proximity Sensor Kit. Can you please help me again. THANK YOU!
 

I am using switch as i mentioned in my proteus simulation placed in PIN_d3, because my ir proximity sensor kit has three wires, input, output, and for ground. Can you please interface the code for the sensor as switch only just to stop the motor when its detected object and if there's no object the motor is still actives. THANKS FOR YOUR HELP AGAIN.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top