Reply To: Can the color sensor detect orange?

HomeForumsMonoBrick EV3 FirmwareCan the color sensor detect orange?Reply To: Can the color sensor detect orange?

#5048
Author Image
Auctor137
Participant

Hi everybody,

I’m a litte bit confused.. the new EV3 Colorsensor is not able to read RGB ? Why would LEGO do that?
I’ve tried this Code out of the new Tutorial from Max Mustermann, but with the EV3 Sensor it doesn’t work.
Red 0
Green 0
Blue 0
all the time.

using System;
using System.Threading;
using MonoBrickFirmware.Sensors;
using MonoBrickFirmware.Movement;
using MonoBrickFirmware.Display;
using MonoBrickFirmware.UserInput;

namespace farbsensor
{
    class farbsensor
    {
        static void Main(string[] args)
        {
            EV3ColorSensor farbsens = new EV3ColorSensor(SensorPort.In1);
            
            bool abfrage = true;
            string rotwert, gruenwert, blauwert;

            RGBColor RGBFarben = new RGBColor(0, 0, 0);
            ButtonEvents buts = new ButtonEvents();

            buts.EscapePressed += () => 
            { abfrage = false; };

            while (abfrage == true)
            {
                rotwert = Convert.ToString(RGBFarben.Red);
                LcdConsole.WriteLine("Rot :" + rotwert);

                gruenwert = Convert.ToString(RGBFarben.Green);
                LcdConsole.WriteLine("Gruen :" + gruenwert);

                blauwert = Convert.ToString(RGBFarben.Blue);
                LcdConsole.WriteLine("Blau :" + blauwert);
                Thread.Sleep(2000);
            }
            LcdConsole.WriteLine("###############");
            LcdConsole.WriteLine("PROGRAMMENDE...");
            Thread.Sleep(3000);

        }
    }
}

#EDIT
I forgot
RGBFarben = farbsens.ReadRGBColor();
infront of the “while-loop”, but farbsens does not have the function ReadRGBColor(), how can i do it?

  • This reply was modified 9 years, 4 months ago by Author ImageAuctor137.
  • This reply was modified 9 years, 4 months ago by Author ImageAuctor137.
Posted in

Make a donation