I am using Vex
RobotC
and have a function: setTouchLEDRGB(portx, R,G,B);
which sets the RGB colour of a touch LED.
I have 9 TouchLEDs and want to change the colour of them all at once, now annoyingly this is 9 lines of code at a time, i hope to create a function with an iteration such as:
for (int i = 0, i < 9, i++)
{
setTouchLEDRGB(port[i], R, G, B);
}
Is there a way to accomplish this?
setTouchLEDRGB(portx, R,G,B);
Not sure about the platform, but you could create an array containg the ports:
#define NUM_PORTS 9
// 'int' should be the type of your port parameter
int ports[NUM_PORTS] = {PORTA, PORTB, etc};
for (int i = 0; i < NUM_PORTS; ++i) {
setTouchLEDRGB(ports[i], R, G, B);
}