Using the NXT Color Sensor with EV3

HomeForumsMonoBrick EV3 FirmwareUsing the NXT Color Sensor with EV3

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #5026
    Author Image
    Auctor137
    Participant

    Hey 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..
    auctor

    #5028
    Author Image
    Anders Søborg
    Keymaster

    Hi there

    Use the color sensor example from Git and replace the EV3Color sensor with the NXTColor sensor. Also have a look at the documentation for the NXT color sensor found here

    /Anders

    #5029
    Author Image
    Auctor137
    Participant

    I’ve used the NXT LIGHTsensor, not the COLORsensor.
    Oh man.

    #5030
    Author Image
    Tcm0
    Participant

    Tho you can still read it with “ReadRaw ()” and “Read ()”. It just won’t return colors but light intensity in percent.

    #5031
    Author Image
    Auctor137
    Participant

    Yeah I know, but i need to read the colors. I’ve used the EV3 Colorsensor now and it works fine.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

Posted in

Make a donation