Hi, I am new to Arduino and working on a project for a class in which I need to have 4 7-segment displays (common anode) multiplexed w/o the use of a shift register or similar device. It must all be done by code and the correct wiring. I have looked at many of the other posts and still cannot figure out what I am doing wrong. I have tried using the setup that others have used in making clocks and such to test my wiring and it doesn't work accordingly.
The wiring is set up such than the the segment pins come from outputs 0-6 and go through 1k resistors to the first digit. They are then 'daisy chained' to the other digits. It is done this way so that I only need to use 7 outputs for all four digits and then each digit is controlled by four other outputs.
Below is the code. It is adapted from several other sets of code I have found.
#define MIDDLE 0 // G
#define UPPER_L 1 // F
#define LOWER_L 2 // E
#define BOTTOM 3 // D
#define LOWER_R 4 // C
#define UPPER_R 5 // B
#define TOP 6 // A
int groundPins[7] = {0, 1, 2, 3, 4, 5, 6}; // G, F, E, D, C, B, A
int digitPins[4] = {7, 8, 9, 10};
int ON = LOW;
int OFF = HIGH;
int number[10][7];
int digit[4];
int hours = 12;
int minutes = 00;
int elapsedMinutes = 0;
int seconds = 0;
int secon;
unsigned long prevtime;
void setup()
{
initNumber();
for(int i=0; i < 7; i++)
{
pinMode(groundPins*, OUTPUT);*
_ digitalWrite(groundPins*, LOW); _
_ }_
_ for(int i=0; i < 4; i++) {_
_ pinMode(digitPins, OUTPUT);
digitalWrite(digitPins, HIGH);
}
}
void loop()
{
int n = 0;
unsigned long time = millis() - (elapsedMinutes * 60000);
seconds = (time / 1000);
if (seconds > 60)
{
seconds = 0;
minutes--;
elapsedMinutes++;
if (minutes >= 60) {
minutes = 0;
hours--;
if (hours > 12) {
hours = 1;
}
}
}
n = (hours * 100) + minutes;
setDigit(n);
}*_
void setDigit(int n)
{
* n = n % 2000;*
* digit[0] = n % 10;*
* digit[1] = (n / 10) % 10;*
* if ((digit[1] == 0) && (n < 10)) {*
* digit[1] = -1;*
* }*
* digit[2] = (n / 100) % 10;*
* if ((digit[2] == 0) && (n < 100)) {*
* digit[2] = -1;*
* }*
* digit[3] = (n / 1000) % 10;*
* if (digit[3] == 0) {*
* digit[3] = -1;*
* }*
}
void initNumber()
{
* number[0][MIDDLE] = OFF;*
* number[0][UPPER_L] = ON;
number[0][LOWER_L] = ON;
_ number[0][BOTTOM] = ON;_
number[0][LOWER_R] = ON;
number[0][UPPER_R] = ON;
_ number[0][TOP] = ON;
number[1][MIDDLE] = OFF;_
number[1][UPPER_L] = OFF;
number[1][LOWER_L] = OFF;
_ number[1][BOTTOM] = OFF;_
number[1][LOWER_R] = ON;
number[1][UPPER_R] = ON;
_ number[1][TOP] = OFF;
number[2][MIDDLE] = ON;_
number[2][UPPER_L] = OFF;
number[2][LOWER_L] = ON;
_ number[2][BOTTOM] = ON;_
number[2][LOWER_R] = OFF;
number[2][UPPER_R] = ON;
_ number[2][TOP] = ON;
number[3][MIDDLE] = ON;_
number[3][UPPER_L] = OFF;
number[3][LOWER_L] = OFF;
_ number[3][BOTTOM] = ON;_
number[3][LOWER_R] = ON;
number[3][UPPER_R] = ON;
_ number[3][TOP] = ON;
number[4][MIDDLE] = ON;_
number[4][UPPER_L] = ON;
number[4][LOWER_L] = OFF;
_ number[4][BOTTOM] = OFF;_
number[4][LOWER_R] = ON;
number[4][UPPER_R] = ON;
_ number[4][TOP] = OFF;
number[5][MIDDLE] = ON;_
number[5][UPPER_L] = ON;
number[5][LOWER_L] = OFF;
_ number[5][BOTTOM] = ON;_
number[5][LOWER_R] = ON;
number[5][UPPER_R] = OFF;
_ number[5][TOP] = ON;
number[6][MIDDLE] = ON;_
number[6][UPPER_L] = ON;
number[6][LOWER_L] = ON;
_ number[6][BOTTOM] = ON;_
number[6][LOWER_R] = ON;
number[6][UPPER_R] = OFF;
_ number[6][TOP] = ON;
number[7][MIDDLE] = OFF;_
number[7][UPPER_L] = OFF;
number[7][LOWER_L] = OFF;
_ number[7][BOTTOM] = OFF;_
number[7][LOWER_R] = ON;
number[7][UPPER_R] = ON;
_ number[7][TOP] = ON;
number[8][MIDDLE] = ON;_
number[8][UPPER_L] = ON;
number[8][LOWER_L] = ON;
_ number[8][BOTTOM] = ON;_
number[8][LOWER_R] = ON;
number[8][UPPER_R] = ON;
_ number[8][TOP] = ON;
number[9][MIDDLE] = ON;_
number[9][UPPER_L] = ON;
number[9][LOWER_L] = OFF;
_ number[9][BOTTOM] = ON;_
number[9][LOWER_R] = ON;
number[9][UPPER_R] = ON;
_ number[9][TOP] = ON;
}*_