I am starting with NXC. I have a code but I am confusing, so I have reduced my code to minimun.
I will show ..
Code: Select all
#define SPIN_SPEED 50
// NXT Port aliases
#define WHEELS OUT_BC
#define LEFT_WHEEL OUT_B
#define RIGHT_WHEEL OUT_C
#define CW 1 // clockwise
#define ACW -1 // anticlockwise
void Spin(short dir)
{
// Gira hacia el lado de "dir"
// Usar CW o ACW
NumOut(0, LCD_LINE4, dir);
NumOut(0, LCD_LINE5, sign(dir));
/*
OnFwdReg(LEFT_WHEEL, -sign(dir)*SPIN_SPEED, OUT_REGMODE_IDLE );
OnFwdReg(RIGHT_WHEEL, sign(dir)*SPIN_SPEED, OUT_REGMODE_IDLE );
*/
OnFwdReg(LEFT_WHEEL, dir*10, OUT_REGMODE_IDLE );
OnFwdReg(RIGHT_WHEEL, -dir*10, OUT_REGMODE_IDLE );
}
task main()
{
Spin(CW);
Wait(3000);
}
Code: Select all
task main()
{
Spin(ACW);
Wait(3000);
}
another test ... If I change main task to ...
Code: Select all
task main()
{
Spin(CW);
Wait(3000);
Spin(ACW);
Wait(3000);
}
Code: Select all
Spin(ACW);
Wait(3000);
Spin(CW);
Wait(3000);
So why programn dont work when I try to Spin ACW (AnticlockWise) only ????
thanks in advance and sorry for my english!