Home Chapter 8 Maxuino/Arduino controlling many LEDS
Maxuino/Arduino controlling many LEDS

 

 

 

You can control many LEDs at different rates dynamically by using Max MSP code to write to each pin.

 

You can also have LEDs play in sequence on the Arduino running through Maxuino. In this code, as all the LEDs are controlled by a single metro box you can control their speed by increasing the numbers in the number box.

Notice that you will need to choose the pin number to output to and the Arduino UNO.

Arduino method of driving an LED High low

arduino Pins 2-17

const int row1 = 2; // the number of the row pin 9

const int row2 = 3; // the number of the row pin 14

const int row3 = 4; // the number of the row pin 8

const int row4 = 5; // the number of the row pin 12

const int row5 = 17; // the number of the row pin 1

const int row6 = 16; // the number of the row pin 7

const int row7 = 15; // the number of the row pin 2

const int row8 = 14; // the number of the row pin 5

//the pin to control COl

const int col1 = 6; // the number of the col pin 13

const int col2 = 7; // the number of the col pin 3

const int col3 = 8; // the number of the col pin 4

const int col4 = 9; // the number of the col pin 10

const int col5 = 10; // the number of the col pin 6

const int col6 = 11; // the number of the col pin 11

const int col7 = 12; // the number of the col pin 15

const int col8 = 13; // the number of the col pin 16

void setup(){

int i = 0 ;

for(i=2;i<18;i++)

{

pinMode(i, OUTPUT);

}

pinMode(row5, OUTPUT);

pinMode(row6, OUTPUT);

pinMode(row7, OUTPUT);

pinMode(row8, OUTPUT);

for(i=2;i<18;i++) {

digitalWrite(i, LOW);

}

digitalWrite(row5, LOW);

digitalWrite(row6, LOW);

digitalWrite(row7, LOW);

digitalWrite(row8, LOW);

}

void loop(){

int i;

//the row # 1 and col # 1 of the LEDs turn on

digitalWrite(row1, HIGH);

digitalWrite(row2, LOW);

digitalWrite(row3, LOW);

digitalWrite(row4, LOW);

digitalWrite(row5, LOW);

digitalWrite(row6, LOW);

digitalWrite(row7, LOW);

digitalWrite(row8, LOW);

 

digitalWrite(col1, LOW);

digitalWrite(col2, HIGH);

digitalWrite(col3, HIGH);

digitalWrite(col4, HIGH);

digitalWrite(col5, HIGH);

digitalWrite(col6, HIGH);

digitalWrite(col7, HIGH);

digitalWrite(col8, HIGH);

 

delay(1000);

 

//turn off all

for(i=2;i<18;i++) {

digitalWrite(i, LOW);

}

 

delay(1000);

}