

advance to the next position in the array:ĪnalogAverage = AnalogValueTotal / numReadings Readings = analogRead(ECsensorPin) ĪnalogValueTotal = AnalogValueTotal + readings initialize serial communication with computer:įor (byte thisReading = 0 thisReading =AnalogSampleInterval)ĪnalogValueTotal = AnalogValueTotal - readings OneWire ds(DS18B20_Pin) // on digital pin 2 Unsigned long AnalogSampleTime,printTime,tempSampleTime

Unsigned int AnalogAverage = 0,averageVoltage=0 // the average Unsigned long AnalogValueTotal = 0 // the running total Unsigned int readings // the readings from the analog inputīyte index = 0 // the index of the current reading Unsigned int AnalogSampleInterval=25,printInterval=1000,tempSampleInterval=1000 //analog sample interval serial print interval temperature sample interval Sorry for a mess code, but I guess you can focus on void serialEvent() in Arduino code, and arduino.WriteLine("180") or arduino.WriteLine("0") in Visual Studio code.Ĭonst byte numReadings = 20 //the number of sample timesīyte ECsensorPin = A1 //EC Meter analog output,pin on analog 1īyte DS18B20_Pin = 2 //DS18B20 signal, pin on digital 2 I want to make a program that when I clicked start button, the servo will rotate 180 degrees, and when I clicked stop, the servo will rotate to 10 degrees. I can control the servo via serial monitor, but nothing happen when I try to control servo via Visual Studio.

But now I'm stuck with controlling when to start the reading via command to my servo. I'm done with sending analog value and display it with GUI. I'm trying to create a GUI that read analog value from Arduino, and display them in zedGraph via GUI.
