1、#include #define out_put P2sbit SA = P10;sbit SB = P11;sbit SC = P12;sbit DIR = P13;void Forward();void Backward();void main(void)while(1)if(!DIR)Forward();elseBackward();void Forward(void)if(SA&(!SB)&SC)/101out_put = 0x09;else if(SA&(!SB)&(!SC) /100out_put = 0x0A;else if(SA&SB&(!SC) /110out_put = 0
2、x22;else if(!SA)&SB&(!SC) /010out_put = 0x24;else if(!SA)&SB&SC)/011out_put = 0x14;else if(!SA)&(!SB)&(SC) /001out_put = 0x11;void Backward(void)if(SA&(!SB)&SC)/101out_put = 0x24;else if(!SA)&(!SB)&(SC)/001out_put = 0x22;else if(!SA)&(SB)&(SC) /011out_put = 0x0A;else if(!SA)&(SB)&(!SC) /010out_put = 0x09;else if(SA)&(SB)&(!SC) /110out_put = 0x11;else if(SA)&(!SB)&(!SC) /100out_put = 0x14;