LED Sequence
LED Sequence
I started by following online schematics to build an LED matrix, Sodered the matrix following this example.
After completing the matrix I proceeded to go on the web to find programming forums for this matrix. I found this forum and used it as an example for my code. Adding the code I learned from a class I had completed what I had set out to accomplish.
After completing the matrix I proceeded to go on the web to find programming forums for this matrix. I found this forum and used it as an example for my code. Adding the code I learned from a class I had completed what I had set out to accomplish.
I would like to use code like this for some sort of signage coding.
/*1.) On your breadboard, create a circuit with at least six (6) LEDs - each on their own Arduino pin.
2.) Write and upload an Arduino sketch that times the LEDs to blink in some kind of sequence
3.) Document your circuit, code, and a VIDEO of your working sequence - and include these in your blog post.
***Any video should be included as an embedded youtube video!
*
4.) Include a brief (1-2 sentence) reflection on this process. Consider challenges and successes encountered.
5.) Include a brief (1-2 sentence) thought on a potential light-based art work. (there are no wrong answers here!)
Bonus Points:
1.) Use PWM pins to create a "fade" effect for one or more of the LEDs.
2.) Avoid using the delay() function - and time your sequence only with counter variables!
3.) Use a for() loop to manipulate multiple LEDs at once!
*/
int dir = 0;
int counter = 0;
int rows[3]={7,8,9};
int cols[3]={10,11,12};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
}
void loop() {
//Use a switch to control between for loop and brightness control
analogWrite(3,counter/2);
counter++;
Serial.println("Counter = ");
Serial.println(counter);
Serial.println(" ");
Serial.println("Direction = ");
Serial.println(dir);
if (counter > 500){
counter = 0;
}
for (int r=0; r < 3; r++){
for (int c=0; c < 3; c++){
if (counter < 100){
config1(r,c);
}
if (counter > 100 && counter < 110){
config2(r,c);
}
}
}
if (counter > 110 && counter < 150){
digitalWrite(7,HIGH);
}
if (counter > 150 && counter < 190){
digitalWrite(8,HIGH);
digitalWrite(7,LOW);
}
if (counter > 190 && counter < 230){
digitalWrite(9,HIGH);
digitalWrite(8,LOW);
}
if (counter > 230 && counter < 280){
digitalWrite(7,HIGH);
digitalWrite(9,LOW);
}
if (counter > 280 && counter < 290){
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
}
if (counter > 290 && counter < 350){
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
digitalWrite(12,HIGH);
}
if (counter > 350 && counter < 400){
digitalWrite(7,LOW);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
}
if (counter > 400 && counter < 405){
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
}
if (counter > 405 && counter < 450){
digitalWrite(7,HIGH);
digitalWrite(8,LOW);
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
}
if (counter > 450 && counter < 455){
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
}
if (counter > 455 && counter < 500){
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
}
}
void config1(int row, int col)
{
digitalWrite(rows[row], HIGH);
digitalWrite(cols[col], LOW);
}
void config2(int row, int col)
{
digitalWrite(rows[row], LOW);
digitalWrite(cols[col], LOW);
}



Comments
Post a Comment