Go Down

Topic: Reading the state of a pin in C# (Read 1 time) previous topic - next topic


I'm trying to read the state of a pin on the arduino and get the C# app to do a certain task, i know how to write to the arduino from the C# app, but i cant figure out how to get it to read the value of the pin ( high=1/low=0 ) from the serial and then make the app do a task ( ex. open a new form in the app or change the color of a box).
I just need the program to read the serial without showing the actual serial data, just do a task when it receives a 1 in the serial data, and do its task.

I have done a few c# programs before but only to send data over serial when a button is pressed or a event have been triggered.

Does anyone have an idea to do this, or could give me a few pointers how to do this? any help is appreciated


Seems pretty simple:

if (Serial.available()>0){  // new byte came in?
incomingByte = Serial.read();  // read it
if ( (B00000001 & incomingByte)) == 1){ // is bit 0 a 1?
// do some action
else {
// do some other action (or leave this out if no other action)
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


google arduino c# serial => 365.000 hits 0.18 seconds :)

check - http://jtoee.com/2009/02/talking-to-an-arduino-from-net-c/ -  trick is   OnReceived()
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


Thank you both now i have something to work with.

Go Up