colordetector
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
colordetector [2024/01/22 06:51] – angelegt torsten.roehl | colordetector [2024/01/22 06:51] (aktuell) – torsten.roehl | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
====== ColorDetector | ====== ColorDetector | ||
+ | |||
+ | <Code Java linenums: | ||
+ | import lejos.nxt.*; | ||
+ | import lejos.nxt.addon.ColorSensor; | ||
+ | |||
+ | /** | ||
+ | * For testing the HiTechnic color sensor (see lejos.nxt.addon.ColorSensor). | ||
+ | * @author BB | ||
+ | */ | ||
+ | public class ColorDetector { | ||
+ | |||
+ | final static int INTERVAL = 200; // milliseconds | ||
+ | |||
+ | public static void main(String [] args) throws Exception { | ||
+ | ColorSensor cmps = new ColorSensor(SensorPort.S1); | ||
+ | String color = " | ||
+ | String r = " | ||
+ | String g = " | ||
+ | String b = " | ||
+ | |||
+ | while(!Button.ESCAPE.isPressed()) { | ||
+ | LCD.clear(); | ||
+ | LCD.drawString(cmps.getProductID(), | ||
+ | LCD.drawString(cmps.getSensorType(), | ||
+ | LCD.drawString(cmps.getVersion(), | ||
+ | LCD.drawString(color, | ||
+ | LCD.drawInt((int)cmps.getColorNumber(), | ||
+ | LCD.drawString(r, | ||
+ | LCD.drawInt((int)cmps.getRedComponent(), | ||
+ | LCD.drawString(g, | ||
+ | LCD.drawInt((int)cmps.getGreenComponent(), | ||
+ | LCD.drawString(b, | ||
+ | LCD.drawInt((int)cmps.getBlueComponent(), | ||
+ | LCD.refresh(); | ||
+ | Thread.sleep(INTERVAL); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | </ |
colordetector.txt · Zuletzt geändert: 2024/01/22 06:51 von torsten.roehl