I am having trouble rotating the motors 80 degrees.. I am making a blackjack playing nxt robot and am having trouble with my card reading class. This class uses the Lego RGB colour sensor to read two coloured strips on the playing cards. Here is my code for the early stages of my ReadCard class :
import lejos.nxt.*;
import lejos.robotics.Color;
public class ReadCard {
public int CardRead(){
int counter = 0;
String colorNames[] = {"Red", "Green", "Blue", "Yellow",
"Megenta", "Orange", "White", "Black", "Pink",
"Grey", "Light Grey", "Dark Grey", "Cyan"};
while (!Button.ESCAPE.isPressed() && counter == 0)
{
ColorSensor colours = new ColorSensor(SensorPort.S1);
ColorSensor.Color colourVal = colours.getColor();
Motor.A.setSpeed(540);
Motor.B.setSpeed(540);
Motor.C.setSpeed(540);
Motor.A.forward();
Motor.B.forward();
Motor.C.forward();
if (colourVal.getColor()<7){
counter = 1;
Motor.A.rotate(80);
Motor.B.rotate(80);
Motor.C.rotate(80);
}
}
return card;
}
}
The aim of this is to turn the motors to draw in the card and when the sensor senses the beginning of the card, I want all 3 the motors to rotate 80 degrees to position the card in the correct position for the first coloured strip to be read. Everything works until the 'rotate motor' code runs. All that happens is one motor turns slowly for a few seconds then shuts off. If I remove the B and C line and just have Motor.A.rotate(80), it works and motor A rotates 80 degrees. I cant seem to get all 3 motors to rotate 80 degrees.
Any Suggestions?
Many Thanks
