CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171
Posted: 01:07pm 12 May 2025
kind of goes without saying you'll get some sun soon - we haven't had a drop of rain to be worth mentioning here in central England in about 6 weeks... but we have had that pesky north wind which really takes the edge off the sun
So... As @Volhout has already pointed out, the PORT command is your friend here. It allows you to address a whole load of pins in one go - sounds exactly what you want. Set your GPIO pins so they act as the bits of the port (doesn't have to be 8 bits) and then you just write a value to the port and the binary represenation would light up the LEDs of your choice
Assuming your LEDs are active on logic 1...
If you want single LEDs to light, choose a number between 0 and 5 (to keep the LED numbers nice and "computery), then PORT 2^number for just a single LED. When you want them all off, just write 0 to the PORT
For n=1 to 100'sparkle the LEDs PORT(GP2,6) = 2^Int(Rnd*6) Pause 100 Next