- #include
- #define uchar unsigned char
- #define uint unsigned int
- void delayms (uint aa)
- {
- uint bb;
- while(aa--)
- {
- for(bb=0;bb<100;bb++)
- {
- }
- }
- }
- void motor_ccw(void)
- {
- P1DIR|=0xff;
- uchar j;
- for(j=0;j<8;j++)
- {
- P1OUT=0x08;
- delayms(10);
- P1OUT=0x0c;
- delayms(10);
- P1OUT=0x04;
- delayms(10);
- P1OUT=0x06;
- delayms(10);
- P1OUT=0x02;
- delayms(10);
- P1OUT=0x03;
- delayms(10);
- P1OUT=0x01;
- delayms(10);
- P1OUT=0x09;
- delayms(10);
- }
- }
- void main(void)
- {
- WDTCTL=WDTPW+WDTHOLD;
- uint r;
- uint M=64;
- while(1)
- {
- for(r=0;r
- {
- motor_ccw();
- }
- }
- }
刚拿到的电机,找了个最简单的程序,电机里面转外面不转,以上是我的代码,