I am fooling around in TwinCAT3 trying and getting familiar with ST. I now have a simple question.
Say I have 8 LEDS. Each assigned to an output 1-8. Now I want to be able to send in a byte looking like such: 10101010. Lets call that variable to hold that byte setOUTPUTS. Would I initalize setOUTPUTS as follows to hold that?
bsetOUTPUTS := BYTE;
After I initialize that variable, how could I loop through it to set each LED to the corresponding bit?
For instance: setOUTPUTS = 10001000, how would i loop through setOUTPUTS variable to set LED 8 and LED 4 ON , while leaving the others OFF.
IF this is not possible, what is the alternative way using arrays?
Thanks!!


To initialize a byte you would
you can set the outputs based on a bit as follows
you might think that you could do something like to loop through the bits in the byte
but unfortunately you are unable to do this. As far as I know setting them individually is the only way to accomplish this.