Guest User

Untitled

a guest
Dec 15th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.17 KB | None | 0 0
  1. //import lejos.nxt.*;  
  2.  
  3. import lejos.util.Delay;
  4. import lejos.nxt.LightSensor;
  5. import lejos.nxt.SensorPort;
  6. import lejos.nxt.Motor;
  7. import lejos.nxt.LCD;
  8.  
  9. public class PainelSolar {
  10.     public static void main (String[] args) {
  11.    
  12.         LCD.drawString("Painel Solar!", 0, 0);
  13.         LightSensor Sensor_luz1 = new LightSensor(SensorPort.S1,false);
  14.  
  15.         int[] valores_1 = new int[8];
  16.         int[] valores_2 = new int[8];
  17.         int[] valores_3 = new int[8];
  18.         int[] valores_4 = new int[8];
  19.         int[] MotorAPosicao = new int[8];
  20.         String[] valores2_1 = new String[];
  21.         String[] valores2_2 = new String[];
  22.         String[] valores2_3 = new String[];
  23.         String[] valores2_4 = new String[];
  24.    
  25.         for(int x = 0; x < 8; x++) {
  26.             //motoAPosicao[x] = Motor.A.getTachoCount();
  27.             valores_1[x] = Sensor_luz1.getLightValue();
  28.             Delay.msDelay(500);
  29.             Motor.B.rotate(30);
  30.            
  31.             valores_2[x] = Sensor_luz1.getLightValue();
  32.             Delay.msDelay(500);
  33.             Motor.B.rotate(30);
  34.            
  35.             valores_3[x] = Sensor_luz1.getLightValue();
  36.             Delay.msDelay(500);
  37.             Motor.B.rotate(30);
  38.            
  39.             valores_4[x] = Sensor_luz1.getLightValue();
  40.             Delay.msDelay(500);
  41.            
  42.             Motor.B.rotate(-90);           
  43.             Delay.msDelay(500);
  44.            
  45.             valores2_1[x] = "P1: " + x + " = " + valores_1[x];
  46.             valores2_2[x] = "P2: " + x + " = " + valores_2[x];
  47.             valores2_3[x] = "P3: " + x + " = " + valores_3[x];
  48.             valores2_4[x] = "P4: " + x + " = " + valores_4[x];
  49.  
  50.             //LCD.drawString("Intensidade " + Sensor_luz1.getLightValue(), 0, 5);
  51.             //LCD.drawString("Rotacao " + Motor.A.getTachoCount(), 0, 6);
  52.             Motor.A.rotate(845);
  53.         }
  54.         //Motor.A.rotate(6740);
  55.  
  56.         //LCD.drawString(LCDD[0], 0, 1);
  57.        
  58.         int maximo = 0;
  59.         int posicao = 0;
  60.         int fator = 0;
  61.         for(int i=0;i < 8;i++){
  62.             if(valores_1[i] > maximo){
  63.                 maximo = valores_1[i];
  64.                 posicao = MotorAPosicao[i];
  65.                 fator = i;
  66.             }
  67.         }
  68.        
  69.        
  70.         LCD.drawString("Intensidade: " + maximo, 0, 2);
  71.         LCD.drawString("Rotacao: " + posicao, 0, 3);
  72.         LCD.drawString("Fator: " + fator,0,4);
  73.        
  74.         Motor.A.setSpeed(1000);
  75.         Motor.A.rotate((-845*fator));
  76.        
  77.         while(true) {
  78.             if (Button.ESCAPE.isDown()) {
  79.                 LCD.drawString("Desligando", 0, 6);
  80.                 Delay.msDelay(2000);
  81.             break;
  82.             }
  83.         }      
  84.     }
  85. }
Add Comment
Please, Sign In to add comment