It's a thing of beauty, is it not? Now down to business, I have to match up the pins to the rows, columns, and colors for my first sketch. Carefully going through the schematic, I came up with:
int colsr[]={9,10,11,12,13,14,15,16}; //red int colsg[]={28,27,26,25,24,23,22,21}; //green int colsb[]={1,2,3,4,5,6,7,8}; //blue int rows[]={17,18,19,20,29,30,31,32};
I'll have to come up with a little more eloquent method, but this will do to get some lights lit up. Again, referring to the schematic, I see that the LEDs are oriented so that the power is coming from the rows, so the colors/columns are specified by the ground pins. This seems backward to me since, at some point, I'm going to want to write different values to the pins to blend colors instead of just setting them to HIGH.
Next, I created my setup() routine. Here I need to initialize all of the pins for output and set their initial state.
void setup() { // put your setup code here, to run once: for(int pin=1;pin<=32;pin++){ pinMode(pin,OUTPUT); } for(int idx=1;idx<=9;idx++){ digitalWrite(colsr[idx-1],HIGH); digitalWrite(colsg[idx-1],HIGH); digitalWrite(colsb[idx-1],HIGH); digitalWrite(rows[idx-1],LOW); } }
No comments:
Post a Comment