//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); }
private void cmdStart_Click(object sender, EventArgs e) { string port = txtPort.Text; var Arduino = new ArduinoUno(port); textBox1.BackColor = Color.Green; }
public void TestComponents() { IWattCalculator test = new ArduinoUno(); Assert.AreEqual(21.40, test.Measure()); test = new ArduinoDuo(); Assert.AreNotEqual(21.40, test.Measure()); Assert.AreEqual(27.43, test.Measure()); test = new Breadboard(); Assert.AreNotEqual(27.43, test.Measure()); Assert.AreEqual(3.50, test.Measure()); }
void Start() { _firmata = new ArduinoUno(portName, baudRate); try { _firmata.Open(); } catch (System.IO.IOException) { Debug.Log("No se puede conectar a arduino en puerto " + portName); return; } _connected = true; Debug.Log("Conectado a arduino en puerto: " + portName + " con baudRate: " + baudRate); }
static void Main(string[] args) { //Linux serial port var arduino = new ArduinoUno("/dev/ttyACM0"); //Windows serial port //var arduino = new ArduinoUno("COM3"); 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); } }
static void Main(string[] args) { IRGBController controller = new ArduinoUno(); Console.WriteLine("Enter colors"); while (true) { string[] numbers = Console.ReadLine().Split(' '); controller.SetColor(Int32.Parse(numbers[0]), Int32.Parse(numbers[1]), Int32.Parse(numbers[2])); } /*SerialPort a = new SerialPort(); * a.PortName = "COM4"; * a.Open(); * a.WriteLine("255, 255, 0\n"); * a.Close(); * Console.ReadKey();*/ }
public void TestComplicated() { double testWatts; IWattCalculator test = new ArduinoUno(); Assert.AreEqual(21.40, test.Measure()); testWatts = test.Measure(); test = new RGBLED(test); Assert.AreEqual(testWatts + 15.48, test.Measure()); testWatts = test.Measure(); test = new Buzzer(test); Assert.AreEqual(testWatts + 8.91, test.Measure()); testWatts = test.Measure(); test = new Resistor(test); Assert.AreEqual(testWatts + 17.24, test.Measure()); testWatts = test.Measure(); test = new LED(test); Assert.AreEqual(testWatts + 12.36, test.Measure()); }
private void button1_Click(object sender, EventArgs e) { int pin = Convert.ToInt32(txtinpin.Text); string port = txtPort.Text; var Arduino = new ArduinoUno(port); }