
import lejos.nxt.*;

public class HelloWorld
{
	public static void main (String[] args) throws Exception
	{
		Motor aMotor = Motor.A;
		Motor cMotor = Motor.C;
		double szog = 90;
		double tavolsag = 0.5;
		double kerek_atmero = 0.043;
		double kerektav = 0.12;
		double elore_szamitas=0;
		double fordulas_szamitas=0;
		int fsz=0;
		
		elore_szamitas=(2/kerek_atmero)*(180/Math.PI)*tavolsag;
		fsz = (int)Math.rint(elore_szamitas);
		aMotor.rotate(fsz, true);
		cMotor.rotate(fsz, false);
		
		fordulas_szamitas=(kerektav/kerek_atmero)*szog;
		fsz=(int)Math.rint(fordulas_szamitas);
		aMotor.rotate(-fsz,true);
		cMotor.rotate(fsz,false);
		
		Thread.sleep(500);
		aMotor.stop();
		cMotor.stop();
	}
}

























/* VÁLOGATÓ PROGRAMRÉSZLET */
/*
import lejos.nxt.*;
import java.io.*;
import javax.bluetooth.RemoteDevice;
import lejos.nxt.LCD;
import lejos.nxt.comm.BTConnection;
import lejos.nxt.comm.Bluetooth;


public class HelloWorld
{
	public static void main (String[] args) throws Exception
	{
		ColorSensor cs = new ColorSensor(SensorPort.S1);
		Motor aMotor = Motor.A;
		Motor bMotor = Motor.B;
		aMotor.setSpeed(320);
		bMotor.setSpeed(320);
		int szin1 = 0;
		int szin2 = 0;
		boolean voltSzin1 = false;
		boolean voltSzin2 = false;
		boolean kezdo_irany_jobb = false;
		boolean kezdo_irany_bal = false;
		String name = "NXT";
		int darab = 6;

		
		while (! Button.ESCAPE.isPressed())
		{
			LCD.clear();
			LCD.drawString("szin:", 2, 4);
			LCD.drawInt(cs.readValue(), 3, 5);
			LCD.drawString("db:",0,6);
			LCD.drawInt(darab, 6, 6);
			LCD.refresh();
			
			if( darab == 0 )
				
				break;
			
			if(!voltSzin1)
			{
				szin1 = cs.readValue();
				voltSzin1 = true;
			}
			if(!(Math.abs(cs.readValue() - szin1) <= 2) && !voltSzin2)
			{
				szin2 = cs.readValue();
				voltSzin2 = true;
				
			}
			
			else if( Math.abs(cs.readValue() - szin1) <= 2)
			{
				Thread.sleep(750);
				bMotor.rotate(50);
				Thread.sleep(750);
				aMotor.rotate(-70);
				Thread.sleep(750);
				aMotor.rotate(70);
				Thread.sleep(750);
				bMotor.rotate(-50);
				Thread.sleep(750);
				darab = darab-1;
				kezdo_irany_bal = true;
				
			}
			else if(Math.abs(cs.readValue() - szin2) <= 2)
			{
				Thread.sleep(750);
				bMotor.rotate(-50);
				Thread.sleep(750);
				aMotor.rotate(-70);
				Thread.sleep(750);
				aMotor.rotate(70);
				Thread.sleep(750);
				bMotor.rotate(50);
				Thread.sleep(750);
				darab = darab-1;
				kezdo_irany_jobb = true;
			}

			
		}
		
		LCD.clear();
		LCD.drawString("Connecting...", 0, 0);
		LCD.refresh();
		
		try
		{
			RemoteDevice receiver = Bluetooth.getKnownDevice(name);
			if (receiver == null)
				throw new IOException("no such device");
			BTConnection connection = Bluetooth.connect(receiver);
			if (connection == null)
				throw new IOException("Connect fail");

			LCD.drawString("connected.", 1, 0);
			DataOutputStream output = connection.openDataOutputStream();
			if ( kezdo_irany_bal == true )
			{
				output.writeInt(22);
				output.flush();
			}
			//output.writeInt(22);
			//output.flush();
			else if( kezdo_irany_jobb == true )
			{
				//kezdo_irany_bal = false;
				output.writeInt(42);
				output.flush();
			}
			LCD.drawString("Sent data", 2, 0);

			output.close();
			connection.close();
			LCD.drawString("Bye ...", 5, 0);
		}
		catch(Exception ioe)
		{
			LCD.clear();
			LCD.drawString("ERROR", 0, 0);
			LCD.drawString(ioe.getMessage(), 2, 0);
			LCD.refresh();
		}
		
		
	}
}
		
		/*while (! Button.ESCAPE.isPressed())
		{
			figyelo = figyelo+1;
			if( ( figyelo % 2 ) == 0 )
			{
				Thread.sleep(1000);
				bMotor.rotate(50);
				Thread.sleep(1000);
				aMotor.rotate(-60);
				Thread.sleep(1000);
				aMotor.rotate(60);
				Thread.sleep(1000);
				bMotor.rotate(-50);
				Thread.sleep(1000);
			}
			else
			{
				bMotor.rotate(-50);
				Thread.sleep(1000);
				aMotor.rotate(-60);
				Thread.sleep(1000);
				aMotor.rotate(60);
				Thread.sleep(1000);
				bMotor.rotate(50);
				Thread.sleep(1000);
				
			}
		}*/
	/*}
}*/


// egy szám küldése bluetooth-on nxt-nek

/*import java.io.*;
import javax.bluetooth.RemoteDevice;
import lejos.nxt.LCD;
import lejos.nxt.comm.BTConnection;
import lejos.nxt.comm.Bluetooth;


public class HelloWorld
{
	public static void main(String[] args) throws Exception
	{
		// Change this to the name of your receiver
		String name = "NXT";
		
		LCD.clear();
		LCD.drawString("Connecting...", 0, 0);
		LCD.refresh();
		try
		{
			RemoteDevice receiver = Bluetooth.getKnownDevice(name);
			if (receiver == null)
				throw new IOException("no such device");
			BTConnection connection = Bluetooth.connect(receiver);
			if (connection == null)
				throw new IOException("Connect fail");

			LCD.drawString("connected.", 1, 0);
			DataOutputStream output = connection.openDataOutputStream();

			output.writeInt(22);
			output.flush();
			LCD.drawString("Sent data", 2, 0);

			output.close();
			connection.close();
			LCD.drawString("Bye ...", 5, 0);
		}
		catch(Exception ioe)
		{
			LCD.clear();
			LCD.drawString("ERROR", 0, 0);
			LCD.drawString(ioe.getMessage(), 2, 0);
			LCD.refresh();
		}
		Thread.sleep(4000);
	}
}


*/


































/*

import java.io.*;
import lejos.nxt.LCD;
import lejos.nxt.comm.BTConnection;
import lejos.nxt.comm.Bluetooth;
import lejos.nxt.*;

public class HelloWorld
{
	public static void main(String[] args) throws Exception
	{
		UltrasonicSensor us = new UltrasonicSensor(SensorPort.S1); //látószenzor
		ColorSensor cs_jobb = new ColorSensor(SensorPort.S3);
		ColorSensor cs_bal = new ColorSensor(SensorPort.S2);
		
		int szin = ColorSensor.BLACK;
		final int forward = 1;
		final int stop = 3;
		final int flt = 4;
		final int power = 80;
		final int power_kor = 80;
		int temp_szin = ColorSensor.BLACK ;
		int tavolsag;
		int figyelo=1;
		Motor cMotor = Motor.C; 
		Motor aMotor = Motor.A;
		Motor bMotor = Motor.B;
		aMotor.setSpeed(340);
		cMotor.setSpeed(300);
		bMotor.setSpeed(70);
		
// Kalibrálni kell a jobb majd a bal szenzort 
		
		cs_jobb.calibrate();
		cs_bal.calibrate();
		
		LCD.clear();
		LCD.drawString("Receiver wait...", 0, 0);
		LCD.refresh();
		int szam = 0;

		try
		{
			BTConnection connection = Bluetooth.waitForConnection();
			if (connection == null)
				throw new IOException("Connect fail");

			LCD.drawString("Connected.", 1, 0);
			DataInputStream input = connection.openDataInputStream();
			szam = input.readInt();					
			input.close();
			connection.close();
		}
		catch(Exception ioe)
		{
			LCD.clear();
			LCD.drawString("ERROR", 0, 0);
			LCD.drawString(ioe.getMessage(), 2, 0);
			LCD.refresh();
		}
		if(szam == 42)//ha zöld golyók felé kell fordulni.
		{
			Thread.sleep(1000);
			aMotor.rotate(200);
			Thread.sleep(1000);
			
		//while(!Button.ESCAPE.isPressed())
		//{
			//LCD.clear();
			//if(cs_jobb.white())
			//	LCD.drawString("feher  ", 2, 3);
			//else if(cs_jobb.black())
			//	LCD.drawString("fekete   ", 2, 3);
			//else if(cs_jobb.yellow())
			//	LCD.drawString("sarga    ",2,3);
			//else
			//	LCD.drawString("semmi  ", 2, 3);
		//LCD.refresh();
		//}
		//Show light percent until LEFT is pressed
		//LCD.drawString("Press LEFT", 0, 1);
		//LCD.drawString("to start", 0, 2);
		//while (! Button.LEFT.isPressed())
		//{
			//LCD.drawInt(cs_jobb.readValue(), 3, 3);
			//LCD.drawInt(cs_bal.readValue(), 3, 4);
		//}
		while (! Button.ESCAPE.isPressed())
		{
			LCD.clear();
			LCD.drawString("cm1:", 0, 0);
			LCD.drawInt(us.getDistance(), 5, 0);
			LCD.refresh();
			tavolsag = us.getDistance();
			if(tavolsag <= 20)
			{
				aMotor.stop();
				bMotor.stop();
				cMotor.stop();
				LCD.drawString("stop", 3, 4);
				continue;
			}			
			if((cs_jobb.getColor() == szin) && (cs_bal.getColor() == szin)  )
			{
				//aMotor.stop();
				//cMotor.stop();
				//if( szin==ColorSensor.BLACK )
				//	temp_szin=ColorSensor.YELLOW;
				//else temp_szin = ColorSensor.BLACK;
				figyelo = figyelo+1;
				if( ( figyelo % 2 ) == 0 )
				{
					aMotor.stop();
					cMotor.stop();
					Thread.sleep(1500);
					bMotor.rotate(-810);
					Thread.sleep(1500);
					aMotor.setSpeed(100);
					cMotor.setSpeed(100);
				   	aMotor.rotate(400, true);
				   	cMotor.rotate(400, false);
				   	Thread.sleep(1500);
				   	bMotor.rotate(210);
				   	Thread.sleep(1500);
				   	aMotor.rotate(-400, true);
				   	cMotor.rotate(-400, false);
				   	Thread.sleep(1500);
				   	bMotor.rotate(600);
				   	Thread.sleep(1500);
				   	aMotor.setSpeed(120);
				   	cMotor.setSpeed(120);
				   	aMotor.rotate(-480, true);
				   	cMotor.rotate(480, false);
				}
				else
				{
					aMotor.stop();
					cMotor.stop();
					Thread.sleep(1500);
					bMotor.rotate(-610);
					aMotor.setSpeed(100);
					cMotor.setSpeed(100);
				   	aMotor.rotate(350, true);
				   	cMotor.rotate(350, false);
				   	Thread.sleep(1500);
				   	bMotor.rotate(-200);
				   	Thread.sleep(1500);
				   	aMotor.rotate(-350, true);
				   	cMotor.rotate(-350, false);
				   	Thread.sleep(1500);
				   	bMotor.rotate(810);
				   	Thread.sleep(1500);
				   	aMotor.setSpeed(120);
				   	cMotor.setSpeed(120);
				   	aMotor.rotate(-480, true);
				   	cMotor.rotate(480, false);	
				}	
			}
			else if (cs_jobb.getColor() == szin)
			{
				//MotorPort.C.controlMotor(0,stop);
				//MotorPort.A.controlMotor(power_kor, forward);
				//aMotor.setSpeed(200);
				cMotor.setSpeed(0);
				aMotor.setSpeed(470);
				//cMotor.stop();
				//aMotor.forward();
			}
			else if(cs_bal.getColor() == szin)
			{		
				//MotorPort.A.controlMotor(0,stop);
				//MotorPort.C.controlMotor(power_kor, forward);
				//aMotor.stop();
				//cMotor.isForward();
				aMotor.setSpeed(0);
				cMotor.setSpeed(450);
			}			
			else
			{
				aMotor.setSpeed(340);
				cMotor.setSpeed(300);
				aMotor.forward();
				cMotor.forward();
				//MotorPort.A.controlMotor(power, forward);
				//MotorPort.C.controlMotor(power, forward);
			}
		}
		// Program befejezésekor lassulva áll le a motor 
		MotorPort.A.controlMotor(0,flt);
		MotorPort.C.controlMotor(0,flt);
		LCD.clear();
		LCD.drawString("Program stopped", 0, 0);
		Thread.sleep(1000);
		}
		
		
		
		
		else if(szam == 22)//ha sárga golyók felé kell fordulni.
		{
			Thread.sleep(1000);
			cMotor.rotate(200);
			Thread.sleep(1000);
			
		//while(!Button.ESCAPE.isPressed())
		//{
			//LCD.clear();
			//if(cs_jobb.white())
			//	LCD.drawString("feher  ", 2, 3);
			//else if(cs_jobb.black())
			//	LCD.drawString("fekete   ", 2, 3);
			//else if(cs_jobb.yellow())
			//	LCD.drawString("sarga    ",2,3);
			//else
			//	LCD.drawString("semmi  ", 2, 3);
		//LCD.refresh();
		//}
		//Show light percent until LEFT is pressed
		//LCD.drawString("Press LEFT", 0, 1);
		//LCD.drawString("to start", 0, 2);
		//while (! Button.LEFT.isPressed())
		//{
			//LCD.drawInt(cs_jobb.readValue(), 3, 3);
			//LCD.drawInt(cs_bal.readValue(), 3, 4);
		//}
		while (! Button.ESCAPE.isPressed())
		{
			LCD.clear();
			LCD.drawString("cm1:", 0, 0);
			LCD.drawInt(us.getDistance(), 5, 0);
			LCD.refresh();
			tavolsag = us.getDistance();
			if(tavolsag <= 20)
			{
				aMotor.stop();
				bMotor.stop();
				cMotor.stop();
				LCD.drawString("stop", 3, 4);
				continue;
			}			
			if((cs_jobb.getColor() == szin) && (cs_bal.getColor() == szin)  )
			{
				//aMotor.stop();
				//cMotor.stop();
				//if( szin==ColorSensor.BLACK )
				//	temp_szin=ColorSensor.YELLOW;
				//else temp_szin = ColorSensor.BLACK;
				figyelo = figyelo+1;
				if( ( figyelo % 2 ) == 0 )
				{
					aMotor.stop();
					cMotor.stop();
					Thread.sleep(1500);
					bMotor.rotate(-810);
					Thread.sleep(1500);
					aMotor.setSpeed(100);
					cMotor.setSpeed(100);
				   	aMotor.rotate(400, true);
				   	cMotor.rotate(400, false);
				   	Thread.sleep(1500);
				   	bMotor.rotate(210);
				   	Thread.sleep(1500);
				   	aMotor.rotate(-400, true);
				   	cMotor.rotate(-400, false);
				   	Thread.sleep(1500);
				   	bMotor.rotate(600);
				   	Thread.sleep(1500);
				   	aMotor.setSpeed(120);
				   	cMotor.setSpeed(120);
				   	aMotor.rotate(-480, true);
				   	cMotor.rotate(480, false);
				}
				else
				{
					aMotor.stop();
					cMotor.stop();
					Thread.sleep(1500);
					bMotor.rotate(-610);
					aMotor.setSpeed(100);
					cMotor.setSpeed(100);
				   	aMotor.rotate(350, true);
				   	cMotor.rotate(350, false);
				   	Thread.sleep(1500);
				   	bMotor.rotate(-200);
				   	Thread.sleep(1500);
				   	aMotor.rotate(-350, true);
				   	cMotor.rotate(-350, false);
				   	Thread.sleep(1500);
				   	bMotor.rotate(810);
				   	Thread.sleep(1500);
				   	aMotor.setSpeed(120);
				   	cMotor.setSpeed(120);
				   	aMotor.rotate(-480, true);
				   	cMotor.rotate(480, false);	
				}	
			}
			else if (cs_jobb.getColor() == szin)
			{
				//MotorPort.C.controlMotor(0,stop);
				//MotorPort.A.controlMotor(power_kor, forward);
				//aMotor.setSpeed(200);
				cMotor.setSpeed(0);
				aMotor.setSpeed(470);
				//cMotor.stop();
				//aMotor.forward();
			}
			else if(cs_bal.getColor() == szin)
			{		
				//MotorPort.A.controlMotor(0,stop);
				//MotorPort.C.controlMotor(power_kor, forward);
				//aMotor.stop();
				//cMotor.isForward();
				aMotor.setSpeed(0);
				cMotor.setSpeed(450);
			}			
			else
			{
				aMotor.setSpeed(340);
				cMotor.setSpeed(300);
				aMotor.forward();
				cMotor.forward();
				//MotorPort.A.controlMotor(power, forward);
				//MotorPort.C.controlMotor(power, forward);
			}
		}
		// Program befejezésekor lassulva áll le a motor 
		MotorPort.A.controlMotor(0,flt);
		MotorPort.C.controlMotor(0,flt);
		LCD.clear();
		LCD.drawString("Program stopped", 0, 0);
		Thread.sleep(1000);
		}
		
		
	}
}
*/
























/*import lejos.nxt.*;
public class HelloWorld {

   public static void main(String [] args)  throws Exception {

           SoundSensor ss = new SoundSensor(SensorPort.S2,false);


           LCD.drawString("Sound level (%) ", 0, 0);

           while (! Button.ESCAPE.isPressed())
           {

                   LCD.drawInt(ss.readValue(),3,5);
                   LCD.refresh();

                   Thread.sleep(300);
           }
           LCD.clear();
           LCD.drawString("Program stopped", 0, 0);
           LCD.refresh();
   }
}*/


/*import lejos.nxt.*;
import lejos.nxt.Sound;
import lejos.nxt.SoundSensor;

public class HelloWorld
{
	public static void main (String[] args) throws Exception
	{
		
		SoundSensor ss = new SoundSensor(SensorPort.S4);
		
		while (! Button.ESCAPE.isPressed())
		{
			
			Thread.sleep(2000);
			Sound.twoBeeps();
			Thread.sleep(2000);
			Sound.beep();
			Thread.sleep(2000);
			Sound.buzz();
			Thread.sleep(2000);
			ss.setDBA(true);
			
			
			
			
		}
		
	}
}

































/* VONALKÖVETÉSI PROGRAM RÉSZLET */

/*import lejos.nxt.*;

public class HelloWorld
{
	public static void main (String[] aArg) throws Exception
	{
		UltrasonicSensor us = new UltrasonicSensor(SensorPort.S1); //látószenzor
		ColorSensor cs_jobb = new ColorSensor(SensorPort.S3);
		ColorSensor cs_bal = new ColorSensor(SensorPort.S2);
		
		int szin = ColorSensor.BLACK;
		final int forward = 1;
		final int stop = 3;
		final int flt = 4;
		final int power = 80;
		final int power_kor = 80;
		int temp_szin = ColorSensor.BLACK ;
		int tavolsag;
		int figyelo=1;
		Motor cMotor = Motor.C; 
		Motor aMotor = Motor.A;
		Motor bMotor = Motor.B;
		aMotor.setSpeed(340);
		cMotor.setSpeed(300);
		bMotor.setSpeed(70);

		cs_jobb.calibrate();
		cs_bal.calibrate();
		while(!Button.ESCAPE.isPressed())
		{
			LCD.clear();
			if(cs_jobb.white())
				LCD.drawString("feher  ", 2, 3);
			else if(cs_jobb.black())
				LCD.drawString("fekete   ", 2, 3);*/
			/*else if(cs_jobb.yellow())
				LCD.drawString("sarga    ",2,3);*/
		/*	else
				LCD.drawString("semmi  ", 2, 3);
		LCD.refresh();
		}
	
		// Show light percent until LEFT is pressed
		LCD.drawString("Press LEFT", 0, 1);
		LCD.drawString("to start", 0, 2);
		while (! Button.LEFT.isPressed())
		{
			LCD.drawInt(cs_jobb.readValue(), 3, 3);
			LCD.drawInt(cs_bal.readValue(), 3, 4);
		}
		while (! Button.ESCAPE.isPressed())
		{
			LCD.clear();
			LCD.drawString("cm1:", 0, 0);
			LCD.drawInt(us.getDistance(), 5, 0);
			LCD.refresh();
			tavolsag = us.getDistance();
			if(tavolsag <= 20)
			{
				aMotor.stop();
				bMotor.stop();
				cMotor.stop();
				LCD.drawString("stop", 3, 4);continue;
			}			
			if((cs_jobb.getColor() == szin) && (cs_bal.getColor() == szin)  )
			{
				/*aMotor.stop();
				cMotor.stop();
				if( szin==ColorSensor.BLACK )
					temp_szin=ColorSensor.YELLOW;
				else temp_szin = ColorSensor.BLACK;*/
				
			/*	figyelo= figyelo+1;
				if( ( figyelo % 2 ) == 0 )
				{
					aMotor.stop();
					cMotor.stop();
					Thread.sleep(1500);
					bMotor.rotate(-810);
					Thread.sleep(1500);
					aMotor.setSpeed(100);
					cMotor.setSpeed(100);
				   	aMotor.rotate(400, true);
				   	cMotor.rotate(400, false);
				   	Thread.sleep(1500);
				   	bMotor.rotate(210);
				   	Thread.sleep(1500);
				   	aMotor.rotate(-400, true);
				   	cMotor.rotate(-400, false);
				   	Thread.sleep(1500);
				   	bMotor.rotate(600);
				   	Thread.sleep(1500);
				   	aMotor.setSpeed(120);
				   	cMotor.setSpeed(120);
				   	aMotor.rotate(-480, true);
				   	cMotor.rotate(480, false);
				}
				else
				{
					aMotor.stop();
					cMotor.stop();
					Thread.sleep(1500);
					bMotor.rotate(-610);
					aMotor.setSpeed(100);
					cMotor.setSpeed(100);
				   	aMotor.rotate(350, true);
				   	cMotor.rotate(350, false);
				   	Thread.sleep(1500);
				   	bMotor.rotate(-200);
				   	Thread.sleep(1500);
				   	aMotor.rotate(-350, true);
				   	cMotor.rotate(-350, false);
				   	Thread.sleep(1500);
				   	bMotor.rotate(810);
				   	Thread.sleep(1500);
				   	aMotor.setSpeed(120);
				   	cMotor.setSpeed(120);
				   	aMotor.rotate(-480, true);
				   	cMotor.rotate(480, false);	
				}	
			}
			else if (cs_jobb.getColor() == szin)
			{
				//MotorPort.C.controlMotor(0,stop);
				//MotorPort.A.controlMotor(power_kor, forward);
				//aMotor.setSpeed(200);
				cMotor.setSpeed(0);
				aMotor.setSpeed(470);
				//cMotor.stop();
				//aMotor.forward();
			}
			else if(cs_bal.getColor() == szin)
			{		
				//MotorPort.A.controlMotor(0,stop);
				//MotorPort.C.controlMotor(power_kor, forward);
				//aMotor.stop();
				//cMotor.isForward();
				aMotor.setSpeed(0);
				cMotor.setSpeed(450);
			}			
			else
			{
				aMotor.setSpeed(340);
				cMotor.setSpeed(300);
				aMotor.forward();
				cMotor.forward();
				//MotorPort.A.controlMotor(power, forward);
				//MotorPort.C.controlMotor(power, forward);
			}
		}
		// Program befejezésekor lassulva áll le a motor 
		MotorPort.A.controlMotor(0,flt);
		MotorPort.C.controlMotor(0,flt);
		LCD.clear();
		LCD.drawString("Program stopped", 0, 0);
		Thread.sleep(1000);
	}
}

*/














/*import lejos.nxt.*;

public class HelloWorld
{
	public static void main(String[] args) throws InterruptedException
	{
		//LightSensor c = new LightSensor(SensorPort.S3);
		ColorSensor cs = new ColorSensor(SensorPort.S3);
		cs.calibrate();
		while(!Button.ESCAPE.isPressed()){
			//LCD.clear();
			//LCD.drawString("     ", 2, 3);
			if(cs.white())
				LCD.drawString("feher  ", 2, 3);
			else if(cs.black())
				LCD.drawString("zöld   ", 2, 3);
			else if(cs.blue())
				LCD.drawString("kék    ",2,3);
			else
				LCD.drawString("semmi  ", 2, 3);
		//LCD.refresh();
		}
	}
}*/
/*{

	public static void main(String [] args) throws Exception
    {
        String ports[] = {"Port 1", "Port 2", "Port 3", "Port 4"};
        TextMenu portMenu = new TextMenu(ports, 0, "Sensor port");
        String modes[] = {"Full", "Red", "Green", "Blue", "None"};
        TextMenu modeMenu = new TextMenu(modes, 0, "Color mode");
        int rawVals[] = new int[4];
        int vals[] = new int[4];

        //int portNo = portMenu.select();
        //if (portNo < 0) return;
        ColorLightSensor cs = new ColorLightSensor(SensorPort.PORTS[2], 13);
        //cs.setFloodlight(color)
        //cs.setFloodlight(true);
        
        for(;!Button.ESCAPE.isPressed();)
        {
            
            //int mode = modeMenu.select();
            //if (mode < 0) return;
            
            LCD.clear();
            while (!Button.ESCAPE.isPressed())
            {
                LCD.drawString("Mode: " + modes[1], 0, 0);
                LCD.drawString("Color   Raw  Cal", 0, 1);
               // if (mode == 0)
               // {
                    cs.readValues(vals);
                    cs.readRawValues(rawVals);
                   
                    Colors.Color color = cs.readColor();
                    int colorVal = cs.readValue();
                    for(int i = 0; i < vals.length; i++)
                    {
                        LCD.drawString(modes[i+1], 0, i + 2);
                        LCD.drawInt(rawVals[i], 5, 6, i + 2);
                        LCD.drawInt(vals[i], 5, 11, i + 2);
                    }
                    LCD.drawString("Color:          ", 0, 6);
                    LCD.drawString(color.name(), 7, 6);
                    LCD.drawString("Value: ", 0, 7);
                    LCD.drawInt(colorVal, 5, 7, 7);
               // }
               /* else
                {
                    LCD.drawString(modes[mode], 0, 3);
                    int raw = cs.readRawValue();
                    int val = cs.readValue();
                    LCD.drawInt(raw, 5, 6, 3);
                    LCD.drawInt(val, 5, 11, 3);
                }
            }
            LCD.clear();
        }
	}
}*/


















/*import lejos.nxt.*;
import lejos.nxt.addon.*;

public class HelloWorld
{
	public static int maxCs = 810;
	public static int aktCs = 0;	
	public static void main (String[] aArg) throws Exception
		{
	
	*/	
		
/* TARGONCA ÍRÁNYVÁLTÁSAI */ 
/*	   	  Motor aMotor = Motor.A;
	   	  Motor cMotor = Motor.C;
	  
	   	  aMotor.setSpeed(300);
	   	  cMotor.setSpeed(300);
	  
	   	  aMotor.rotate(720, true);
	   	  cMotor.rotate(720, false);

	   	  aMotor.rotate(3836, false);
	   	  cMotor.rotate(-480, false);
	  
	   	  aMotor.rotate(360, true);
	   	  cMotor.rotate(360, false);
	  
	   	  aMotor.rotate(720);
	   	  cMotor.rotate(720);
	  
	   	  aMotor.rotate(720, true);
	   	  cMotor.rotate(720, false);*/
  
/* TARGONCA CSÖRLŐ MOZGÁSA */		
/*		Motor bMotor = Motor.B;
		TouchSensor ts = new TouchSensor(SensorPort.S3);
		bMotor.setSpeed(300);
		while(!ts.isPressed())
		{
		  bMotor.backward();
		}
		bMotor.stop();
		aktCs = 0;
	  
		Button.LEFT.addButtonListener(new LeftButtonEvent(bMotor));
		Button.RIGHT.addButtonListener(new RightButtonEvent(bMotor));
		Button.ESCAPE.waitForPressAndRelease();*/
/* KIJELZŐ */
/*		TouchSensor ts2 = new TouchSensor(SensorPort.S2);
		UltrasonicSensor us = new UltrasonicSensor(SensorPort.S1);
		
		while(!Button.ESCAPE.isPressed())
		{
			LCD.drawString("          ", 0, 3);
			LCD.drawString("cm:", 0, 3);
			LCD.drawInt(us.getDistance(), 4, 3);
			LCD.drawString("                     ", 0, 5);
			if(ts2.isPressed())
				LCD.drawString("touch: benyomva", 0, 5);
			else
				LCD.drawString("touch: nincs benyomva", 0, 5);
			Thread.sleep(100);
		}*/
/* AKADÁLY KIKERÜLÉSE */		
		//UltrasonicSensor us = new UltrasonicSensor(SensorPort.S1 );
		//TouchSensor ts = new TouchSensor(SensorPort.S2);
		//TouchSensor ts2 = new TouchSensor(SensorPort.S3);
		/*ColorSensor ls = new ColorSensor(SensorPort.S4);
		ColorLightSensor s = new ColorLightSensor(SensorPort.S3, ColorLightSensor.MODE_PCTFULLSCALE);
		
		s.readColor();*/
		//Motor aMotor = Motor.A;
		//Motor cMotor = Motor.C;
		//Motor bMotor = Motor.B;
		//bMotor.setSpeed(80);
		
		//while( !Button.ENTER.isPressed() )
		//{		
/* AKADÁLY ELKERÜLÉSE */
			
			/*LCD.clear();
			
			LCD.drawString("szin:", 2, 2);
			LCD.drawInt((int)ls.getColorNumber(), 3, 3);
			LCD.drawInt(ls.getColorIndexNumber(), 4, 4);
			LCD.refresh();*/
			
			
					
			
			
			/*LCD.clear();
			LCD.drawString("cm:", 0, 0);
			LCD.drawInt(us.getDistance(), 4, 0);
			LCD.refresh();
			int tavolsag;
			tavolsag = us.getDistance();
			if (tavolsag <277 && tavolsag >27)
			{
				LCD.refresh();
				aMotor.setSpeed(384);
				cMotor.setSpeed(350);
				aMotor.forward();
				cMotor.forward();
				LCD.refresh();
				LCD.drawString("itt egy", 2, 2);
			}
			if ( tavolsag <33 && tavolsag >13 )
			{
				LCD.refresh();
				aMotor.setSpeed(120);
				cMotor.setSpeed(100);
				LCD.refresh();
				LCD.drawString("itt ketto", 3, 3);
			}
			if( tavolsag < 23 )
			{
				LCD.refresh();
				aMotor.stop();
				cMotor.stop();
				aMotor.setSpeed(110);
				cMotor.setSpeed(100);
				aMotor.rotate(-240,true);
				cMotor.rotate(-240,false);
				aMotor.setSpeed(300);
				aMotor.rotate(480);
				LCD.refresh();
				LCD.drawString("itt harom", 3, 3);
			
			}*/
				/*LCD.refresh();
				LCD.clear();
				LCD.drawString("cm2:", 0, 3);
				LCD.drawInt(us.getDistance(), 5, 3);
				LCD.refresh();
				aMotor.stop();
				bMotor.stop();
				cMotor.stop();
				aMotor.setSpeed(150);
				bMotor.setSpeed(200);
				cMotor.setSpeed(150);
				bMotor.rotate(-200);
				while( !Button.ESCAPE.isPressed() )
				{
					LCD.drawString("cumi", 5, 3);
					/*LCD.refresh();
					LCD.clear();
					LCD.drawString("cm2:", 0, 3);
					LCD.drawInt(us.getDistance(), 5, 3);
					LCD.refresh();
					if(us.getDistance()>33 && us.getDistance()<277)
					{
						aMotor.rotate(1920, true);
						cMotor.rotate(-1920,false);
					}
					if(us.getDistance()<30)
					{
						aMotor.stop();
						cMotor.stop();
						aMotor.setSpeed(200);
						cMotor.setSpeed(200);
						aMotor.rotate(us.getDistance(),true);
						cMotor.rotate(us.getDistance(),false);
						LCD.refresh();
						aMotor.rotate(400,true);
						cMotor.rotate(400,false);
						aMotor.rotate(-400, true);
						cMotor.rotate(-400, false);
						break;
					}
				}
				bMotor.rotate(200);
				break;*/
/*ha megnyomtuk a S2-t akkor megáll a targonca és leengedi az elemlőt*/
			/*if( ts.isPressed() )
			{
				aMotor.rotate(1960, true);
				bMotor.setSpeed(900);
				bMotor.rotate(-888,true);
			}*/
			/*if ( ts2.isPressed() )
			{
				LCD.drawString("benyomodott", 0, 5);
				aMotor.setSpeed(200);
				cMotor.setSpeed(200);
				aMotor.rotate(240,true);
				cMotor.rotate(240,false);
			}*/
		//}
	/*		aktCs = 0;
			//Button.LEFT.addButtonListener(new LeftButtonEvent(bMotor));
			//Button.RIGHT.addButtonListener(new RightButtonEvent(bMotor));
			Button.ESCAPE.waitForPressAndRelease();
			Thread.sleep(200);
	
		}	
}
*/






