Home→Forums→MonoBrick EV3 Firmware→Using the NXT Color Sensor with EV3
- This topic has 4 replies, 3 voices, and was last updated 11 years ago by
Auctor137.
-
AuthorPosts
-
December 3, 2014 at 15:43 #5026

Auctor137ParticipantHey there,
the last two hours I’ve tried to get the NXT Color Sensor to read some colors, but it didn’t work so well. I
The program below prints for each color a “1”. I’ve tried using the other possibilities:
ReadAsString() – prints an “Black” for each color
Read() – prints an “1”and ReadRGB.. well, how do i save it ? Won’t work with int, byte, string, char… ?
using System; using System.Threading; using MonoBrickFirmware.Sensors; using MonoBrickFirmware.Movement; using MonoBrickFirmware.Display; using MonoBrickFirmware.UserInput; namespace AMotorcolor { class Program { static void Main(string[] args) { NXTColorSensor sens = new NXTColorSensor(SensorPort.In1); Motor motorA = new Motor(MotorPort.OutA); int farbe1, farbe2; LcdConsole.WriteLine("Scanne Farbe 1..."); // reading the first color Thread.Sleep(500); farbe1 = sens.ReadRaw(); LcdConsole.WriteLine("Farbe 1 = " + farbe1); Thread.Sleep(4000); LcdConsole.WriteLine("Scanne Farbe 2..."); // reading the second color Thread.Sleep(500); farbe2 = sens.ReadRaw(); LcdConsole.WriteLine("Farbe 2 = " + farbe2); Thread.Sleep(4000); LcdConsole.WriteLine("PROGRAMMENDE..."); Thread.Sleep(1000); motorA.Off(); } } }Thanks in advance..
auctorDecember 3, 2014 at 18:27 #5028
Anders SøborgKeymasterDecember 4, 2014 at 18:12 #5029
Auctor137Participant…
I’ve used the NXT LIGHTsensor, not the COLORsensor.
Oh man.December 5, 2014 at 08:27 #5030
Tcm0ParticipantTho you can still read it with “ReadRaw ()” and “Read ()”. It just won’t return colors but light intensity in percent.
December 5, 2014 at 14:29 #5031
Auctor137ParticipantYeah I know, but i need to read the colors. I’ve used the EV3 Colorsensor now and it works fine.
-
AuthorPosts
You must be logged in to reply to this topic.

Follow