Reply To: Trying to run a program(doesn't work)

HomeForumsMonoBrick EV3 FirmwareTrying to run a program(doesn't work)Reply To: Trying to run a program(doesn't work)

#4798
Author Image
Roy Toren
Participant

I posted it already, I have tried both of them:

first:

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

using System.Threading;
namespace ColorSensorExample
{
class MainClass
{
public static void Main (string[] args)
{
EventWaitHandle stopped = new ManualResetEvent(false);
ColorMode[] modes = {ColorMode.Color, ColorMode.Reflection, ColorMode.Ambient, ColorMode.Blue};
int modeIdx = 0;
var sensor = new EV3ColorSensor(SensorPort.In1);
ButtonEvents buts = new ButtonEvents ();
LcdConsole.WriteLine(“Use color on port1″);
LcdConsole.WriteLine(“Up read value”);
LcdConsole.WriteLine(“Down raw value”);
LcdConsole.WriteLine(“Enter change mode”);
LcdConsole.WriteLine(“Esc. terminate”);
buts.EscapePressed += () => {
stopped.Set();
};
buts.UpPressed += () => {
LcdConsole.WriteLine(“Sensor value: ” + sensor.ReadAsString());
};
buts.DownPressed += () => {
LcdConsole.WriteLine(“Raw sensor value: ” + sensor.ReadRaw());
};
buts.EnterPressed += () => {
modeIdx = (modeIdx+1)%modes.Length;
sensor.Mode = modes[modeIdx];
LcdConsole.WriteLine(“Sensor mode is set to: ” + modes[modeIdx]);
};
stopped.WaitOne();
}
}
}

secound:

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

using System.Threading;
namespace ev3test
{
class MainClass
{
public static void Main(string[] args)
{
LcdConsole.WriteLine(“Hello World!”);
System.Threading.Thread.Sleep(10000);
}
}
}

What I dont get is, I copied the first source code from the sensor example and so it is supposed to work.
but when i compile in the visual studio it throws an exeption and when i try to use the exe in the brick it runs it for 2 seconds and then quits

Posted in

Make a donation