Esempio n. 1
0
        public Manager(string user_id, int iteration, int[] degreeList,string taskDesc, string labelLeftMost, string labelRightMost, ArduinoUno arduinouno,TaskDisplay tDisplay)
        {
            logPath = "log_" + user_id + ".csv";
            this.user_id = user_id;
            arduino = arduinouno;
            Manager.tDisplay = tDisplay;
            tDisplay.buttonOK.Click += buttonOK_Click;

            taskQueue = new Queue<Task>();
            curTask = null;

            List<Task> taskList = new List<Task>();
            for (int i = 0; i < iteration; i++)
            {
                for (int j = 0; j < degreeList.Length; j++)
                {
                    taskList.Add(new Task(degreeList[j],taskDesc,labelLeftMost,labelRightMost));
                }
            }
            Shuffle(taskList);

            int id = 1;
            foreach (Task t in taskList)
            {
                t.Id = id;
                taskQueue.Enqueue(t);
                id++;
            }
            taskList.Clear();
            taskList = null;
        }
Esempio n. 2
0
        //Reads an Analog sensor and gives back its value from a Port number (int port)
        public static float RASensor(int pin, string port)
        {
            float value = 0;
             var Arduino = new ArduinoUno(port);
             switch (pin)
               {
               case 1:
                   value = Arduino.ReadAnalog(Sharpduino.Constants.ArduinoUnoAnalogPins.A1);
                   break;
               case 2:
                   value = Arduino.ReadAnalog(Sharpduino.Constants.ArduinoUnoAnalogPins.A2);
                   break;

               case 3:
                   value = Arduino.ReadAnalog(Sharpduino.Constants.ArduinoUnoAnalogPins.A3);
                   break;
               case 4:
                   value = Arduino.ReadAnalog(Sharpduino.Constants.ArduinoUnoAnalogPins.A4);
                   break;
               case 5:
                   value = Arduino.ReadAnalog(Sharpduino.Constants.ArduinoUnoAnalogPins.A5);
                   break;

               }

            return value;
        }
Esempio n. 3
0
        public Form1()
        {
            InitializeComponent();

            // Create a new connection
            if (!Task.debug) {
                arduino = new ArduinoUno("COM4");
                arduino.SetPinMode(ArduinoUnoPins.D13, PinModes.Output);
            }
            this.FormClosed += Form1_FormClosed;

            tDisplay = new TaskDisplay();
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            //Windows serial port
            var arduino = new ArduinoUno("COM4");

            arduino.SetPinMode(Sharpduino.Constants.ArduinoUnoPins.D13, Sharpduino.Constants.PinModes.Output);

            while (true)
            {
                arduino.SetDO(Sharpduino.Constants.ArduinoUnoPins.D13, true);
                Thread.Sleep(1000);
                arduino.SetDO(Sharpduino.Constants.ArduinoUnoPins.D13, false);
                Thread.Sleep(1000);
            }
        }
Esempio n. 5
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {

                // Create a new connection
                var arduino = new ArduinoUno("COM11");

                //// Read an analog value
                //float valueInVolts = arduino.ReadAnalog(ArduinoUnoAnalogPins.A0);

                // Read the state of a pin
                Pin p = arduino.GetCurrentPinState(ArduinoUnoPins.D2);

                lbResults.Items.Add(p.CurrentValue);

                // Write a digital value to an output pin
                arduino.SetPinMode(ArduinoUnoPins.D9_PWM, PinModes.Output);
                arduino.SetDO(ArduinoUnoPins.D9_PWM, true);

                System.Threading.Thread.Sleep(1000);
                arduino.SetDO(ArduinoUnoPins.D9_PWM, false);

                //// Write an analog value (PWM) to a PWM pin
                //arduino.SetPinMode(ArduinoUnoPins.D3_PWM, PinModes.PWM);
                //arduino.SetPWM(ArduinoUnoPWMPins.D3_PWM, 90);

                //// Use a servo
                //arduino.SetPinMode(ArduinoUnoPins.D9_PWM, PinModes.Servo);
                //arduino.SetServo(ArduinoUnoPins.D9_PWM, 90);

                // dispose of the object
                arduino.Dispose();

            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Esempio n. 6
0
 private void cmdStart_Click(object sender, EventArgs e)
 {
     string port = txtPort.Text;
     var Arduino = new ArduinoUno(port);
     textBox1.BackColor = Color.Green;
 }
Esempio n. 7
0
 private void button1_Click(object sender, EventArgs e)
 {
     int pin = Convert.ToInt32(txtinpin.Text);
     string port = txtPort.Text;
     var Arduino = new ArduinoUno(port);
 }