My question is: how to receive data from serial port using wpf application? I've tried a lot of times but still can't get it; Here comes my Arduino code:
int switchPin = 7;
int ledPin = 13;
boolean lastButton = LOW;
boolean currentButton = LOW;
boolean flashLight = LOW;
void setup()
{
pinMode(switchPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
boolean debounce(boolean last)
{
boolean current = digitalRead(switchPin);
if (last != current)
{
delay(5);
current = digitalRead(switchPin);
}
return current;
}
void loop()
{
currentButton = debounce(lastButton);
if (lastButton == LOW && currentButton == HIGH)
{
Serial.println("UP");
digitalWrite(ledPin, HIGH);
}
if (lastButton == HIGH && currentButton == LOW)
{
Serial.println("DOWN");
digitalWrite(ledPin, LOW);
}
lastButton = currentButton;
}
It sends messages "DOWN" and "UP" each time the button is pressed. But how to receive it from C# application? Please, write an example of such wpf app.