Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using MonoBrick.NXT;//use this to run the example on the EV3
- //using MonoBrick.NXT;//use this to run the example on the NXT
- namespace Application
- {
- public static class Program{
- static void Main(string[] args)
- {
- try{
- var brick = new Brick<Sensor,Sensor,Sensor,Sensor>("COM33");
- brick.Connection.Open();
- var brick2 = new Brick<Sensor,Sensor,Sensor,Sensor>("COM29");
- brick2.Connection.Open();
- ConsoleKeyInfo cki;
- Console.WriteLine("Press Q to quit");
- do
- {
- cki = Console.ReadKey(true); //press a key
- switch(cki.Key){
- case ConsoleKey.NumPad8:
- brick.MotorA.On(100);
- brick.MotorB.On(100);
- brick.MotorC.On(100);
- brick2.MotorA.On(100);
- brick2.MotorB.On(100);
- brick2.MotorC.On(100);
- break;
- case ConsoleKey.NumPad2:
- brick.MotorA.On(-100);
- brick.MotorB.On(-100);
- brick.MotorC.On(-100);
- brick2.MotorA.On(-100);
- brick2.MotorB.On(-100);
- brick2.MotorC.On(-100);
- break;
- case ConsoleKey.NumPad4:
- brick.MotorA.On(-100);
- brick.MotorB.On(-100);
- brick.MotorC.On(-100);
- brick2.MotorA.On(100);
- brick2.MotorB.On(100);
- brick2.MotorC.On(100);
- break;
- case ConsoleKey.NumPad6:
- brick.MotorA.On(100);
- brick.MotorB.On(100);
- brick.MotorC.On(100);
- brick2.MotorA.On(-100);
- brick2.MotorB.On(-100);
- brick2.MotorC.On(-100);
- break;
- case ConsoleKey.NumPad5:
- brick.MotorA.Brake();
- brick.MotorB.Brake();
- brick.MotorC.Brake();
- brick2.MotorA.Brake();
- brick2.MotorB.Brake();
- brick2.MotorC.Brake();
- break;
- }
- } while (cki.Key != ConsoleKey.Q);
- }
- catch(Exception e){
- Console.WriteLine("Error: " + e.Message);
- Console.WriteLine("Press any key to end...");
- Console.ReadKey();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment