I suppose as a newby I am venturing into deep water but I am trying to run a row of tiny seven segment leds (out of an old sinclair calculator - anyone remember them? little red rows of dots making up seven segments) using a bcd to seven segment chip (mc14511b) with outputs 10,11,12 amd 13 of a UNO.
I can run 2 sets of segments but when I extend to 3 sets I fail.
Each set of segments is selected by outputs 2,3 and 4 of the UNO.
I can get the outputs from 2 and 3 but output 4 gives me nothing?
If I swap the outputs in the setup of the program ( ie 'int led = 4' for int 'led =2') it still fails to give me output 4?
If I put another program in just giving me an output on 3 and 4 it works fine?
I have confirmed the leds are getting enough power by using progressively smaller resistors in series with the leds and have swapped as much in the software as I can without getting an output on 4?
I have changed the output to 1,5,7,8,9 (using PWM and non PWM outputs) but ... no change?
I have included the code and put all my info before , there is nothing after the code
I do hope someone can solve this for me ![]()
Thanks,
Matelot..
int leda = 13;
int ledb = 12;
int ledc = 11;
int ledd = 10;
int led4 = 4;
int led3 = 3;
int led2 = 2;
int count = 0;
int tens = 0;
int mins = 0;
int lane1 = LOW;
int lane2 = LOW;
int lane3 = LOW;
int ledstate = 1;
int swap = 0;
int ledstatea = LOW;
int ledstateb = LOW;
int ledstatec = LOW;
int ledstated = LOW;
long previousMillis = 0;
long interval = 1000;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(leda, OUTPUT);
pinMode(ledb, OUTPUT);
pinMode(ledc, OUTPUT);
pinMode(ledd, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led2, OUTPUT);
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led4, lane1);
digitalWrite(led3, lane2);
digitalWrite(led2, lane3);
digitalWrite(leda, ledstatea); // turn the LED on (HIGH is the voltage level)
digitalWrite(ledb, ledstateb);
digitalWrite(ledc, ledstatec);
digitalWrite(ledd, ledstated);
delay(5);
lane1 = LOW;
lane2 = LOW;
lane3 = LOW;
ledstatea = LOW;
ledstateb = LOW;
ledstatec = LOW;
ledstated = LOW;
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {// save the last time you blinked the LED
previousMillis = currentMillis;
count ++;
if (count == 10){
tens ++;
count = 0;
if (tens == 6)
mins ++;
}
if (tens == 6)
tens = 0;
Serial.print (" tens ");
Serial.print (tens);
Serial.print (" count ");
Serial.print (count);
Serial.print (" ledstate ");
Serial.print (ledstate);
Serial.print (" mins ");
Serial.println (mins);
}
if (ledstate == 1)
swap = 2;
else if (ledstate == 2)
swap = 3;
else if (ledstate == 3)
swap = 1;
ledstate = swap;
if (ledstate == 1){
lane1 = LOW;
lane2 = HIGH;
lane3 = HIGH;
}
if (ledstate == 2){
lane1 = HIGH;
lane2 = LOW;
lane3 = HIGH;
}
if (ledstate == 3){
lane1 = HIGH;
lane2 = HIGH;
lane3 = LOW;
}
if (((count == 1)&&(ledstate == 1))||((tens == 1)&&(ledstate == 2))||((mins == 1)&&(ledstate == 3))){
ledstatea = HIGH;
ledstateb = LOW;
ledstatec = LOW;
ledstated = LOW;
}
else if (((count == 2)&&(ledstate == 1))||((tens == 2)&&(ledstate == 2))||((mins == 2)&&(ledstate == 3))){
ledstatea = LOW;
ledstateb = HIGH;
ledstatec = LOW;
ledstated = LOW;
}
else if (((count == 3)&&(ledstate == 1))||((tens == 3)&&(ledstate == 2))||((mins == 3)&&(ledstate == 3))){
ledstatea = HIGH;
ledstateb = HIGH;
ledstatec = LOW;
ledstated = LOW;
}
else if (((count == 4)&&(ledstate == 1))||((tens == 4)&&(ledstate == 2))||((mins == 4)&&(ledstate == 3))){
ledstatea = LOW;
ledstateb = LOW;
ledstatec = HIGH;
ledstated = LOW;
}
else if (((count == 5)&&(ledstate == 1))||((tens == 5)&&(ledstate == 2))||((mins == 5)&&(ledstate == 3))){
ledstatea = HIGH;
ledstateb = LOW;
ledstatec = HIGH;
ledstated = LOW;
}
else if (((count == 6)&&(ledstate == 1))||((tens == 6)&&(ledstate == 2))||((mins == 6)&&(ledstate == 3))){
ledstatea = LOW;
ledstateb = HIGH;
ledstatec = HIGH;
ledstated = LOW;
}
else if (((count == 7)&&(ledstate == 1))||((tens == 7)&&(ledstate == 2))||((mins == 7)&&(ledstate == 3))){
ledstatea = HIGH;
ledstateb = HIGH;
ledstatec = HIGH;
ledstated = LOW;
}
else if (((count == 8)&&(ledstate == 1))||((tens == 8)&&(ledstate == 2))||((mins == 8)&&(ledstate == 3))){
ledstatea = LOW;
ledstateb = LOW;
ledstatec = LOW;
ledstated = HIGH;
}
else if (((count == 9)&&(ledstate == 1))||((tens == 9)&&(ledstate == 2))||((mins == 9)&&(ledstate == 3))){
ledstatea = HIGH;
ledstateb = LOW;
ledstatec = LOW;
ledstated = HIGH;
}
else if (((count == 0)&&(ledstate == 1))||((tens == 0)&&(ledstate == 2))||((mins == 0)&&(ledstate == 3))){
ledstatea = LOW;
ledstateb = LOW;
ledstatec = LOW;
ledstated = LOW;
}
}