Beispiel #1
0
void keydo(uint8 keyc)
{
	static bit t=0;
	if(keyc<=0x39&&keyc>=0x30)
	{
		if(t==0)
			motor_set((keyc-'0')*360,0);
		else  motor_set((keyc-'0')*360,1);
	}
	if(keyc==0x1b)
	{
		motorstop();
	}
	if(keyc==0x25)
	{
		t=1;
	}
	if(keyc==0x27)
	{
		t=0;
	}
	if(keyc==0x26)
	{
		motor_set(90,0);
	}
	if(keyc==0x28)
	{
		motor_set(90,1);
	}
	if(keyc==0x0D)
	{
		motor_set(99999999,t);
	}
}
Beispiel #2
0
void motorcitos_init() {
	/* 
	 * set mapped L283D motor1 and motor 2 enable pins on Arduino to output
	 * (to turn on/off motor1 and motor2 via L293D)
	 */
	pinMode(enablePin1, OUTPUT);
	pinMode(enablePin2, OUTPUT);
  
	/* set mapped motor poles to Arduino pins (via L293D) */
	pinMode(motor1pole1, OUTPUT);
	pinMode(motor1pole2, OUTPUT);
	pinMode(motor2pole1, OUTPUT);
	pinMode(motor2pole2, OUTPUT);
	motorspeed(0, 0);
	motorstop(2);
	motorstop(1);
}  
Beispiel #3
0
void motormove()
{
	 static uint8 i=0;
	 if(step==0){motorstop();return ;}
	 if(step>0)
	 {
	 step--;
	 P1&=0XF0;
	 P1|=motorcode[i];
	 i++;
	 i&=0x07;
	 }
	 else if(step<0)
	 {
	 if(i==0)i=8;
	 step++;
	 P1&=0XF0;
	 P1|=motorcode[i-1];
	 i--;
	 }
}