-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathProgram.cs
More file actions
37 lines (37 loc) · 1.04 KB
/
Program.cs
File metadata and controls
37 lines (37 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using MonoBrickFirmware.Display;
using MonoBrickFirmware.UserInput;
using MonoBrickFirmware.Sensors;
using System.Threading;
namespace LightSensorExample
{
class MainClass
{
public static void Main (string[] args)
{
ManualResetEvent terminateProgram = new ManualResetEvent(false);
var lightSensor = new NXTLightSensor(SensorPort.In1);
ButtonEvents buts = new ButtonEvents ();
LcdConsole.WriteLine("Use light on port1");
LcdConsole.WriteLine("Up value ");
LcdConsole.WriteLine("Down change mode");
LcdConsole.WriteLine("Esc. terminate");
buts.EscapePressed += () => {
terminateProgram.Set();
};
buts.UpPressed += () => {
LcdConsole.WriteLine("Sensor value:" + lightSensor.ReadAsString());
};
buts.DownPressed += () => {
if(lightSensor.Mode == LightMode.Ambient){
lightSensor.Mode = LightMode.Relection;
}
else{
lightSensor.Mode = LightMode.Ambient;
}
LcdConsole.WriteLine("Sensor mode is now: " + lightSensor.Mode);
};
terminateProgram.WaitOne();
}
}
}