Pages: 1 [2]   Go Down
Author Topic: seven segment display help  (Read 376 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

here is some code

Code:
void display_time(int& minute, int& second)
{
  digitalWrite( GND4, HIGH);    //digit 4
  pickNumber(second%10);
  delay(DTime);
  digitalWrite( GND4, LOW);

  digitalWrite( GND3, HIGH);    //digit 3
  pickNumber(second/10);
  delay(DTime);
  digitalWrite( GND3, LOW);

  digitalWrite( GND2, HIGH);   //digit 2
  pickNumber(minute%10);
  delay(DTime);
  digitalWrite( GND2, LOW);
 
  digitalWrite( GND1, HIGH);   //digit 1
  pickNumber(minute/10);
  delay(DTime);
  digitalWrite( GND1, LOW);

}
void read_four_switches(byte& temp_m10, byte& temp_m1, byte& temp_s10, byte& temp_s1)
{
  int button_present = digitalRead(btn1);
  if (!button_present && button1_previous)
  {
    temp_m10++;
    if (temp_m10>=10){ temp_m10 -=  10;}
  }
  button1_previous = button_present;
  button_present=digitalRead(btn2);
  if (!button_present && button2_previous)
  {
    temp_m1++;
    if(temp_m1>=10) {temp_m1 -= 10;}
  }
  button2_previous = button_present;
  button_present=digitalRead(btn3);
  if (!button_present && button3_previous)
  {
    temp_s10++;
    if(temp_s10>=6) {temp_s10 -= 6;}
  }
  button3_previous = button_present;
  button_present=digitalRead(btn4);
  if (!button_present && button4_previous)
  {
    temp_s1++;
    if(temp_s1>=10){temp_s1 -= 10;}
  }
  button4_previous = button_present;  
}

void pickNumber(int x){
   switch(x){
     case 1: one(); break;
     case 2: two(); break;
     case 3: three(); break;
     case 4: four(); break;
     case 5: five(); break;
     case 6: six(); break;
     case 7: seven(); break;
     case 8: eight(); break;
     case 9: nine(); break;
     default: zero(); break;
   }
}
« Last Edit: July 28, 2014, 09:51:02 pm by santino » Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 93
Posts: 3965
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Put your code in code tags. Read this.

Here is a circuit of mine driving a 4-digit 7-segment common anode display. It's a single unit display, all the segments are connected together internally. It's also a 3V circuit, so the 100Ω segment resistors may be too small for your project. 220Ω should be a safe value to start out with.

PS: We'll probably want to see all the code, not just some of it.


* mpx.png (43.66 KB, 1869x680 - viewed 2 times.)
« Last Edit: July 28, 2014, 09:50:46 pm by Jack Christensen » Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok thanks.. sorry bout that.. i am going to be using 3v in the end.. so should i change my 220 to 100? and should i change my pnp to a 4403 pnp?
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 93
Posts: 3965
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

ok thanks.. sorry bout that.. i am going to be using 3v in the end.. so should i change my 220 to 100?

Resistor selection may require some experimentation with your particular display.

Quote
and should i change my pnp to a 4403 pnp?

Most any general-purpose small-signal PNP type should work. I might have actually built the thing with 2N3906s, I forget...
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

well then i dont get it?? my display still wont work right.. ugh.. is my code right?
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 93
Posts: 3965
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

well then i dont get it?? my display still wont work right.. ugh.. is my code right?

Can't see near enough of it to tell. Post it all, please.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 93
Posts: 3965
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh, if you're using PNP high-side drivers, the code needs to keep all the bases pulled HIGH except for the one digit being displayed, pull that one LOW.  Looks to be backwards in the code above.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I changed the PNP to the 4403 as well. Now the same digits (sort of) are showing, and no matter what button I push, all of the digits change.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok so i ran this code on my break out using this
https://www.sparkfun.com/products/9483

as my display.. now i have NO resistors and NO transistors .. i was just doing this just to see what it displays quickly and it shows the code no issue? ..

so i move back to my MAN71A seven segment displays and i dont get the same feedback? i am using 220ohm res and pnp transistors? whats the big difference in these displays?
Logged

Pages: 1 [2]   Go Up
Jump to: