正反转可控的直流电机程序#include #include #define uint unsigned int#define uchar unsigned charsbit K1 = P30;sbit K2 = P31;sbit K3 = P32;sbit LED1 = P00;sbit LED2 = P01;sbit LED3 = P02;sbit MA = P10;sbit MB = P11;void main(void)LED1 = 1;LED2 = 1;LED3 = 0;while(1)if(K1 = 0) /控制正转, LED1 亮while(K1 = 0); /检测按键是否按下LED1 = 0;LED2 = 1;LED3 = 1;MA = 0; MB = 1; if(K2 = 0) /控制反转 ,LED2 亮while(K2 = 0);LED1 = 1;LED2 = 0;LED3 = 1;MA = 1;MB = 0;if(K3 = 0) /控制停止,LED3 亮while(K3 = 0); LED1 = 1;LED2 = 1;LED3 = 0;MA = 0;MB = 0;