0
votes

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

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

int ledPin[] = {6,7,8,9,10,11,12,13}; 
void setup() 
{ 
    Serial.begin(9600); 
    for (int i =0;i<8;i++) 
    {
        pinMode(ledPin[i], OUTPUT); 
    }
} 

void loop()
{
    String st="11111111"; 
    for(int ch=0;ch < st.length();ch++)
    { 
        if(st.charAt(ch)=='1') 
        { 
            digitalWrite(ledPin[ch],1);
        } 
        else
        { 
            digitalWrite(ledPin[ch],0);
        }
    }
}

Picture of my layout.

1
What is the implementation of digitalWrite?Jeroen Heier

1 Answers

1
votes

You're leaving out too much required info. What does your arduino sketch look like? What does your c# program look like? And what does your circuit look like?

As simple as your question is relative to each of these 3 disciplines, your question is impossible to answer as is, and would probably be put on hold if reviewed by a moderator familiar in any two...

Add some info and then we can get into the exact transport mechanism you using to send data from whatever device it is running your c# program, to which import peripheral you are using to read it on your uno board...