Go Down

Topic: 7x4 LED matrix HSC project (Read 73 times) previous topic - next topic

Ethan_Gee

Jul 24, 2016, 05:01 am Last Edit: Jul 24, 2016, 02:35 pm by Ethan_Gee
Hi all, im in my final year of high school and i am doing a Design technology project for my HSC. I am making a medication management assistant  and i need help with creating a flashing 7x4 LED matrix. currently the code only just turns it on once for the delay and then goes to the next LED, but i want it to flash for the duration of the delay before it moves to the next LED. Like a loop within a loop, im currently using an arduino UNO

Below is my code
int colPin1 = 9;
int colPin2 = 8;
int colPin3 = 7;
int colPin4 = 6;
int colPin5 = 5;
int colPin6 = 4;
int colPin7 = 3;
int rowPin1 = 10;
int rowPin2 = 11;
int rowPin3 = 12;
int rowPin4 = 13;
void setup() {
pinMode(colPin1, OUTPUT);
pinMode(colPin2, OUTPUT);
pinMode(colPin3, OUTPUT);
pinMode(colPin4, OUTPUT);
pinMode(colPin5, OUTPUT);
pinMode(colPin6, OUTPUT);
pinMode(colPin7, OUTPUT);
pinMode(rowPin1, OUTPUT);
pinMode(rowPin2, OUTPUT);
pinMode(rowPin3, OUTPUT);
pinMode(rowPin4, OUTPUT);
}
void loop()
{
// DAY 1 MORNING
// Please note that due to the opposing wire configuration that HIGH means off for coloumns and LOW means ON
digitalWrite(colPin1, HIGH);
digitalWrite(colPin2, HIGH);
digitalWrite(colPin3, HIGH);
digitalWrite(colPin4, HIGH);
digitalWrite(colPin5, HIGH);
digitalWrite(colPin6, HIGH);
digitalWrite(colPin7, LOW);
digitalWrite(rowPin1, HIGH);
digitalWrite(rowPin2, LOW);
digitalWrite(rowPin3, LOW);
digitalWrite(rowPin4, LOW);
delay(1000);
// DAY 1 NOON
// Please note that due to the opposing wire configuration that HIGH means off for coloumns and LOW means ON
digitalWrite(colPin1, HIGH);
digitalWrite(colPin2, HIGH);
digitalWrite(colPin3, HIGH);
digitalWrite(colPin4, HIGH);
digitalWrite(colPin5, HIGH);
digitalWrite(colPin6, HIGH);
digitalWrite(colPin7, LOW);
digitalWrite(rowPin1, LOW);
digitalWrite(rowPin2, HIGH);
digitalWrite(rowPin3, LOW);
digitalWrite(rowPin4, LOW);
delay(1000);
// DAY 1 EVE
// Please note that due to the opposing wire configuration that HIGH means off for coloumns and LOW means ON
digitalWrite(colPin1, HIGH);
digitalWrite(colPin2, HIGH);
digitalWrite(colPin3, HIGH);
digitalWrite(colPin4, HIGH);
digitalWrite(colPin5, HIGH);
digitalWrite(colPin6, HIGH);
digitalWrite(colPin7, LOW);
digitalWrite(rowPin1, LOW);
digitalWrite(rowPin2, LOW);
digitalWrite(rowPin3, HIGH);
digitalWrite(rowPin4, LOW);
delay(1000);
// DAY 1 BED
// Please note that due to the opposing wire configuration that HIGH means off for coloumns and LOW means ON
digitalWrite(colPin1, HIGH);
digitalWrite(colPin2, HIGH);
digitalWrite(colPin3, HIGH);
digitalWrite(colPin4, HIGH);
digitalWrite(colPin5, HIGH);
digitalWrite(colPin6, HIGH);
digitalWrite(colPin7, LOW);
digitalWrite(rowPin1, LOW);
digitalWrite(rowPin2, LOW);
digitalWrite(rowPin3, LOW);
digitalWrite(rowPin4, HIGH);
delay(1000);


and so on moving up the colPins until day 7 is complete


any advice or help would be greatly appreciated.

Thanks!

marco_c

Flashing is a combination of setting the LEDs and clearing them, with delays in between.

I would suggest that you create functions for each of the 'days' you have in the main loop, one per function. Then you can simply call the function/clear with delays to create the desired effect.
Arduino Libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com
Arduino++ blog https://arduinoplusplus.wordpress.com

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy