I am trying to program Arduino UNO light-up 4 Leds using C sharp code

I have Arduino UNO, Bread Board, resistors, LEDs and jumper wires.

I am able to light on/off only 1 LED from my c sharp program. How can I set inputs to all leds to turn on/off all leds at same time through C Sharp code.

try
{

int intVal;
int binVal;
int.TryParse(decimalTxtBox.Text, out intVal);
string binaryValue = ConvertDecimalToBinary(intVal); // converts decimal to binary
binaryLbl.Text = binaryValue.PadLeft(4, '0'); // does the padding if binary is less than 4 digits
Thread.Sleep(2000);
foreach (char bin in binaryLbl.Text) // takes each bits of binary
{
int.TryParse(bin.ToString(), out binVal);
if (binVal == 1)
{
serialPort1.Write("1"); // writes to input to LEDs turns ON LEDs
}

else
{
serialPort1.Write("0"); // writes to input to LEDs turns OFF LEDs
}

}

This program is wrting to one LED but I want each input to different LEDs.

Can anyone help me to resolve this issue?

Without seeing your Arduino code how can we help?

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

As you have control of the PC program as well as the Arduino program I suggest you use the system in the 3rd example as it will be most reliable.

...R

How can I set inputs to all leds to turn on/off all leds at same time through C Sharp code.

The ONLY way to make more than one LED turn on or off AT THE SAME TIME is to use Direct Port Manipulation. But, believe me, you would NOT be able to tell the difference between lighting all the LEDs AT THE SAME TIME vs. as quickly as possible one after the other.

How is the Arduino supposed to know WHICH LED you want to turn on, when all you send is On or Off?