| ??? 03/05/09 17:58 Read: times |
#163105 - Reply Responding to: ???'s previous message |
I know C programming, but I just don't know how to write this particular project. For example, I don't know how to write the program so that the AT89S52 can control whether the L298 bridge can move or stop the motor.
I can only write the code as follows
#include "AT89S52.h"
#define TRUE 1
#define FALSE 0
#define MOTOR_LEFT1 P1_2
#define MOTOR_LEFT2 P1_3
#define MOTOR_ENABLE P1_4
void motor_move(void);
void motor_stop(void);
void delay(void);
void main(){
while(1){
motor_move();
delay();
motor_stop();
delay();
}
}
void motor_move(){
MOTOR_LEFT1=1;
MOTOR_LEFT2=0;
MOTOR_ENABLE=1;
}
void motor_stop(){
MOTOR_LEFT1=0;
MOTOR_LEFT2=0;
MOTOR_ENABLE=0;
}
void delay(){
unsigned char i,j,k;
for(i=0;i<0x20;i++)
for(j=0;j<255;j++)
for(k=0;k<255;k++);
}
But I don't know why after I put this program into MCU, the motor can't run!!! |
| Topic | Author | Date |
| About my project | 01/01/70 00:00 | |
| a very basic mistake | 01/01/70 00:00 | |
| RE: I have no idea about the program. | 01/01/70 00:00 | |
| Programming µControllers | 01/01/70 00:00 | |
| Language is an implementation issue | 01/01/70 00:00 | |
| This is not a chicken and egg question | 01/01/70 00:00 | |
| Reply | 01/01/70 00:00 | |
| another basic mistake | 01/01/70 00:00 | |
SHARP GP2D12(Distance Measuring Sensor) | 01/01/70 00:00 |



