Hi.
Currently writing the code for a 7-seg LED clock using 4 digits, an Arduino Uno and a HEF4511. I'm also currently pulling my hair out as I know the following code should work but it doesn't, the code multiplexes the LED display. I get an error "D was not declared in the scope" and "dig was not declared in the scope" with regards to digOn().
There's more code than what I've shown below but I don't think any of it is relative. If anyone would like to see the entire sketch, I'll gladly post it.
Thanks for taking a look
Jay
Currently writing the code for a 7-seg LED clock using 4 digits, an Arduino Uno and a HEF4511. I'm also currently pulling my hair out as I know the following code should work but it doesn't, the code multiplexes the LED display. I get an error "D was not declared in the scope" and "dig was not declared in the scope" with regards to digOn().
There's more code than what I've shown below but I don't think any of it is relative. If anyone would like to see the entire sketch, I'll gladly post it.
Thanks for taking a look
Jay
Code:
int D3 = 11; // Pin 11 to D3 of IC4511
int D2 = 10; // Pin 10 to D2 of IC4511
int D1 = 9; // Pin 9 to D1 of IC4511
int D0 = 8; // Pin 8 to D0 of IC4511
int dig0 = 4; // Pin 4 to digit 0 transistor (right right)
int dig1 = 5; // Pin 5 to digit 1 transistor (midle right)
int dig2 = 6; // Pin 6 to digit 2 transistor (midle left)
int dig3 = 7; // Pin 7 to digit 3 transistor (left left)
int number = 0; // Decimal number for output digit
int digOn; // Which digit to hold high
int binMatrix[][4] = { // Binary output to IC4511
{0,0,0,0},
{0,0,0,1},
{0,0,1,0},
{0,0,1,1},
{0,1,0,0},
{0,1,0,1},
{0,1,1,0},
{0,1,1,1},
{1,0,0,0},
{1,0,0,1}
};
int digMatrix[][4] = { // digit to be held high for muxing
{0,0,0,1}, // digit 0
{0,0,1,0}, // digit 1
{0,1,0,0}, // digit 2
{1,0,0,0}, // digit 3
};
void digitOn() { // write binary to multiplexer and mux digit
for (int I=0; i<=3; i++) {
digitalWrite (D[i], binMatrix[number][i]); // Output binary number via D0, D1, D2, D3 using binMatrix
digitalWrite (dig[i], digMatrix[digOn][i]); // Switch current digit high and the rest low using digMatrix
}//end for
}
void setup() {
pinMode (D0, OUTPUT);
pinMode (D1, OUTPUT);
pinMode (D2, OUTPUT);
pinMode (D3, OUTPUT);
pinMode (dig0, OUTPUT);
pinMode (dig1, OUTPUT);
pinMode (dig2, OUTPUT);
pinMode (dig3, OUTPUT);
}
voild loop() {
//lots of stuff here that works
}