Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //import lejos.nxt.*;
- import lejos.util.Delay;
- import lejos.nxt.LightSensor;
- import lejos.nxt.SensorPort;
- import lejos.nxt.Motor;
- import lejos.nxt.LCD;
- public class PainelSolar {
- public static void main (String[] args) {
- LCD.drawString("Painel Solar!", 0, 0);
- LightSensor Sensor_luz1 = new LightSensor(SensorPort.S1,false);
- int[] valores_1 = new int[8];
- int[] valores_2 = new int[8];
- int[] valores_3 = new int[8];
- int[] valores_4 = new int[8];
- int[] MotorAPosicao = new int[8];
- String[] valores2_1 = new String[];
- String[] valores2_2 = new String[];
- String[] valores2_3 = new String[];
- String[] valores2_4 = new String[];
- for(int x = 0; x < 8; x++) {
- //motoAPosicao[x] = Motor.A.getTachoCount();
- valores_1[x] = Sensor_luz1.getLightValue();
- Delay.msDelay(500);
- Motor.B.rotate(30);
- valores_2[x] = Sensor_luz1.getLightValue();
- Delay.msDelay(500);
- Motor.B.rotate(30);
- valores_3[x] = Sensor_luz1.getLightValue();
- Delay.msDelay(500);
- Motor.B.rotate(30);
- valores_4[x] = Sensor_luz1.getLightValue();
- Delay.msDelay(500);
- Motor.B.rotate(-90);
- Delay.msDelay(500);
- valores2_1[x] = "P1: " + x + " = " + valores_1[x];
- valores2_2[x] = "P2: " + x + " = " + valores_2[x];
- valores2_3[x] = "P3: " + x + " = " + valores_3[x];
- valores2_4[x] = "P4: " + x + " = " + valores_4[x];
- //LCD.drawString("Intensidade " + Sensor_luz1.getLightValue(), 0, 5);
- //LCD.drawString("Rotacao " + Motor.A.getTachoCount(), 0, 6);
- Motor.A.rotate(845);
- }
- //Motor.A.rotate(6740);
- //LCD.drawString(LCDD[0], 0, 1);
- int maximo = 0;
- int posicao = 0;
- int fator = 0;
- for(int i=0;i < 8;i++){
- if(valores_1[i] > maximo){
- maximo = valores_1[i];
- posicao = MotorAPosicao[i];
- fator = i;
- }
- }
- LCD.drawString("Intensidade: " + maximo, 0, 2);
- LCD.drawString("Rotacao: " + posicao, 0, 3);
- LCD.drawString("Fator: " + fator,0,4);
- Motor.A.setSpeed(1000);
- Motor.A.rotate((-845*fator));
- while(true) {
- if (Button.ESCAPE.isDown()) {
- LCD.drawString("Desligando", 0, 6);
- Delay.msDelay(2000);
- break;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment