kokwah520
Newbie level 5
#include <pic.h>
#use delay (clock = 20000000)
#define L293D_A RB0
#define L293D_B RB1
#define L293D_C RB2
#define L293D_D RB3
#define L293D_E RB4
#define L293D_F RB5
__CONFIG(0x3f3a);
void rotate_L1(void);
void rotate_R1(void);
void rotate_L2(void);
void rotate_R2(void);
void breaksA(void);
void breaksB(void);
void delay(void);
void main()
{
TRISA= 0x0f;
TRISB = 0xf0;
PORTB = 0;
RB4 = 1;
RB5 = 1;
for(;
{
if (RA0 == 1)
{
rotate_L1();
}
else if (RA1 == 1)
{
rotate_R1();
}
else if (RA2 ==1)
{
rotate_L2();
}
else if (RA3 == 1)
{
rotate_R2();
}
else if (RA0 == 1 & RA1== 1)
{
breaksA();
}
else if (RA2 == 1 & RA3 == 1)
{
breaksB();
}
}
}
void rotate_L1()
{
L293D_A=1;
L293D_B=0;
L293D_E=1;
}
void rotate_R1()
{
L293D_A=0;
L293D_B=1;
L293D_E=1;
}
void rotate_L2()
{
L293D_C=1;
L293D_D=0;
L293D_F=1;
}
void rotate_R2()
{
L293D_C=0;
L293D_D=1;
L293D_F=1;
}
void breaksA()
{
L293D_A=0;
L293D_B=0;
L293D_E=0;
}
void breaksB()
{
L293D_C=0;
L293D_D=0;
L293D_F=0;
}
this is my coding of my project but my project is not working, hardware part i have check and is okay, my lecturer say that is software problem, can anyone tell me what is the problem? for the delay, i cant use #include <delay.h> so i use "#use delay (clock = 20000000), it is build successful but it show warning on use delay..
the statement i use void, is this okay? will affect anything?
the program is about to compare the signal of port A, RA0 with RA1 and RA2 with RA3
if RA0 is high (logic "1") then go to subroutine rotate L1
if RA1 is high (logic "1") then go to subroutine rotate R1
if RA2 is high (logic "1") then go to subroutine rotate L2
if RA3 is high (logic "1") then go to subroutine rotate R2
if RA0 and RA1 is high (logic "1") then go to subroutine breaksA
if RA2 and RA3 is high (logic "1") then go to subroutine breaksA
subroutine is to send the signal to the servo motor to make the servo motor turn clockwise or anticlockwise..
void rotate_R2()
{
L293D_C=0;
L293D_D=1;
L293D_F=1;
}
C and D is send the signal to motor driver L293D and F is to control the enable pin of the motor driver.
L293_A/C is the input pin
L293_B/D is the output pin
L294_E/F is the enable pin
can anyone tell me what is the problem of my program?
#use delay (clock = 20000000)
#define L293D_A RB0
#define L293D_B RB1
#define L293D_C RB2
#define L293D_D RB3
#define L293D_E RB4
#define L293D_F RB5
__CONFIG(0x3f3a);
void rotate_L1(void);
void rotate_R1(void);
void rotate_L2(void);
void rotate_R2(void);
void breaksA(void);
void breaksB(void);
void delay(void);
void main()
{
TRISA= 0x0f;
TRISB = 0xf0;
PORTB = 0;
RB4 = 1;
RB5 = 1;
for(;
if (RA0 == 1)
{
rotate_L1();
}
else if (RA1 == 1)
{
rotate_R1();
}
else if (RA2 ==1)
{
rotate_L2();
}
else if (RA3 == 1)
{
rotate_R2();
}
else if (RA0 == 1 & RA1== 1)
{
breaksA();
}
else if (RA2 == 1 & RA3 == 1)
{
breaksB();
}
}
}
void rotate_L1()
{
L293D_A=1;
L293D_B=0;
L293D_E=1;
}
void rotate_R1()
{
L293D_A=0;
L293D_B=1;
L293D_E=1;
}
void rotate_L2()
{
L293D_C=1;
L293D_D=0;
L293D_F=1;
}
void rotate_R2()
{
L293D_C=0;
L293D_D=1;
L293D_F=1;
}
void breaksA()
{
L293D_A=0;
L293D_B=0;
L293D_E=0;
}
void breaksB()
{
L293D_C=0;
L293D_D=0;
L293D_F=0;
}
this is my coding of my project but my project is not working, hardware part i have check and is okay, my lecturer say that is software problem, can anyone tell me what is the problem? for the delay, i cant use #include <delay.h> so i use "#use delay (clock = 20000000), it is build successful but it show warning on use delay..
the statement i use void, is this okay? will affect anything?
the program is about to compare the signal of port A, RA0 with RA1 and RA2 with RA3
if RA0 is high (logic "1") then go to subroutine rotate L1
if RA1 is high (logic "1") then go to subroutine rotate R1
if RA2 is high (logic "1") then go to subroutine rotate L2
if RA3 is high (logic "1") then go to subroutine rotate R2
if RA0 and RA1 is high (logic "1") then go to subroutine breaksA
if RA2 and RA3 is high (logic "1") then go to subroutine breaksA
subroutine is to send the signal to the servo motor to make the servo motor turn clockwise or anticlockwise..
void rotate_R2()
{
L293D_C=0;
L293D_D=1;
L293D_F=1;
}
C and D is send the signal to motor driver L293D and F is to control the enable pin of the motor driver.
L293_A/C is the input pin
L293_B/D is the output pin
L294_E/F is the enable pin
can anyone tell me what is the problem of my program?
Your post is not related to "software links " category.
Moved to microcontrollrs section, post in the proper category, next time you'll get an infraction [alexan_e]