Do you want to control your Arduino using C# on your computer?
Start with controlling your Arduino using serial monitor. When you have the code working, you can change to your C# program, or use anything else that can use serial communication on your computer.
Opening the serial port resets the Arduino. You don't give it time to reset before you jam data at it. Of course that data isn't going to be recognized/acted on.
Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. Using code tags and other important information is explained in the How to use this forum post. Please read it.
PaulS:
Opening the serial port resets the Arduino. You don't give it time to reset before you jam data at it. Of course that data isn't going to be recognized/acted on.
Open the port ONCE. Close the port ONCE.
I have modified the code & done suggested by you .
Still failing to control pin 12 / 11 /10 etc .
Can you plessr read reply #11 again and follow the procedure to properly post code.
For now, I like to see your Arduino code first (and use code tags !!) and want to know if you can switch the led on pin 12 on and off using the serial monitor by sending
arduino code working perfectly , and led blinking as per code -
void setup() {
// put your setup code here, to run once:
pinMode(12, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(12, LOW); // turn the LED off by making the voltage LOW
delay(5000);
}
Hey there, biswa07. I think you've got a basic misunderstanding. Your C# code runs on your PC. Your Arduino sketch runs on your Arduino. In order for your C# app to blink an LED on your Arduino, your C# app and your Arduino sketch have to communicate with one another. Right now, your Arduino sketch isn't reading from the serial port or doing anything that would permit it to know that your C# app wants it to twiddle an LED.