Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package finch;
- import java.awt.Color;
- import edu.cmu.ri.createlab.terk.robot.finch.Finch;
- /**
- * Created by: Chris Grillo
- * Date: 11/26/2014
- * A starter file to use the Finch
- */
- public class Lightburns
- {
- Finch Matthew = new Finch();
- private static int normal = 110;
- public static int dark = 80;
- public static int bright = 175;
- public static void main(final String[] args)
- {
- int SensorsAverage;
- int level=3; // Level can be 0, 1, 2 for dark, okay, bright
- while(true)
- {
- SensorsAverage = checkSensors();
- level = didChange(level,SensorsAverage);
- }
- // Always end your program with finch.quit()
- Matthew.quit();
- System.exit(0);
- }
- public static int checkSensors()
- {
- int SensorsAverage;
- int []lights = Matthew.getLightSensors();
- int red=0, green=0;
- int mod = 0;
- lights=Matthew.getLightSensors();
- SensorsAverage = (lights[0] + lights[1]) / 2;
- red = (int)Math.abs((normal-SensorsAverage)*2.5);
- if(red>255)
- {
- red =255;
- }
- green = 255 - red;
- Matthew.setLED(red,green,0);
- return SensorsAverage;
- }
- public static int didChange(int level, int SensorsAverage){
- if(SensorsAverage <= dark && level != 0) // You never included and equal sign. Could be a problem
- {
- System.out.println("Its to dark and your mother is a whore");
- level = 0;
- return level;
- }
- else if(SensorsAverage >= bright && level != 2)
- {
- System.out.print("bright as shit nigga");
- level = 2;
- return level;
- }
- else if(level != 1)
- {
- System.out.print("alright, alright, alright");
- level = 1;
- return level;
- }
- else
- {
- return level;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement