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!!
You can compare each bit of your setOutputs variable with a bit that is shifted through the length of setOutputs: