Com Anode 7 Segment Display topmost segment unit won't light up!

I’m using a common anode display and the topmost segment won’t light up. Please help.

Please don’t ask if there are problems in the hardware, for the wirings are working (I’ve tested the other wires that are used in the working segments, the Arduino itself is working ( I’ve tested changing the pins) The 7 Segment display is working as I’ve tried changing one of the working output wires into the seems-to-be “not working” topmost segment. The breadboard is working, I’ve tried changing the position of the 7 segment display, and other 6 segments are working, leaving the segA or the topmost segment not working.

The code includes a servo motor and a 7 segment display. The setup works in a way that when the push button is HIGH in “IN”, the 7 segment display decrements from 9 to one, one by one everytime the push button is hit. when the push button is HIGH in “OUT” the 7 segment display increments from one to 9, one by one everytime the push button is hit. I’ve got no problem with the mechanism, but I’ve got problems with the display of the digit, the topmost segment of the 7 segment display does not light up with any value. PLEASE HELPPP!!!
This is the code I’ve modified from Arduining.com

#include <Servo.h>
Servo myservo;  // create servo object to control a servo

#define ServoM    12        //Connected to the servo motor.
#define Bright    11        //servo library disable PWM on pins 9 and 10.
#define Exit      9         //Pin connected to the EXIT button.
#define In        8         //Pin connected to the IN button.

#define BarLow    90       //Low position of the barrier.
#define BarUp     160        //Up position of the barrier.
#define CAPACITY  9         //Capacity of the parking lot.
#define INTEN     80        //Display intensity %

//Pins conections to segments (cathodes).
#define  segA  0
#define  segB  1
#define  segC  2
#define  segD  3
#define  segE  4
#define  segF  5
#define  segG  6

//Array with the segments to represent the decimal numbers (0-9).
byte segments[10] = {
// pgfedcba  <--- segments
  B11000000, // number 0
  B11111001, // number 1
  B10100100, // number 2
  B10110000, // number 3
  B10011001, // number 4
  B10010010, // number 5
  B10000010, // number 6
  B11111000, // number 7
  B10000000, // number 8
  B10010000  // number 9
};

void setup(){
  myservo.attach(ServoM);          // attaches the servo.

  pinMode(Exit, INPUT);           // set "EXIT" button pin to input
  pinMode(In, INPUT);             // set "IN" button pin to input
  digitalWrite(Exit, HIGH);       // Connect Pull-Up resistor.
  digitalWrite(In, HIGH);         // Connect Pull-Up resistor.
  pinMode(segA,OUTPUT);
  pinMode(segB,OUTPUT);
  pinMode(segC,OUTPUT);
  pinMode(segD,OUTPUT);
  pinMode(segE,OUTPUT);
  pinMode(segF,OUTPUT);
  pinMode(segG,OUTPUT);
  pinMode(Bright,OUTPUT);
  analogWrite(Bright,255*INTEN/100);
  myservo.write(BarLow);          //Barrier in the low position
//  delay(1000);
}

int  Available= 9;                    // Number of places available.

//================================================================
void loop(){
Display(Available);
if(digitalRead(In)==0)
{
  if(Available != 0){
    Available--;
    myservo.write(BarUp);
    delay(3000);
    myservo.write(BarLow);
    }
  }
if(digitalRead(Exit)==0)
{
  if(Available != CAPACITY){
    Available++;
    myservo.write(BarUp);
    delay(3000);
    myservo.write(BarLow);
    }
  }
}

/*-------------------------------------------------------------------
Put the segments according to the number.
--------------------------------------------------------------------*/
void Display(int number){
byte segs =  ~segments[number];        //"~" is used for common anode.

digitalWrite(segA, bitRead(segs, 0) );
digitalWrite(segB, bitRead(segs, 1) );
digitalWrite(segC, bitRead(segs, 2) );
digitalWrite(segD, bitRead(segs, 3) );
digitalWrite(segE, bitRead(segs, 4) );
digitalWrite(segF, bitRead(segs, 5) );
digitalWrite(segG, bitRead(segs, 6) );
}

again, segA or topmost is not working

Hello saiyojeff

#define  segA  0
#define  segB  1

Digital pins 0 and 1 are used for serial monitor. Try changing these segments to other pins.

Regards

Ray

Use 2 - 8 for the segments and 9 - 10 for the buttons.
Stay away from 0 & 1 as they are used to upload your sketch and for Serial I/O.
Also, you can’t drive the common anode with pin 11, too much load on it.
Put the anode to +5V or for PWM you need a transistor driver.

You have the common anode connected (directly) to an Arduino pin.

You cannot do that!

(I should not need to explain why - read a lot of other discussions here; you really need to!)

You have the common anode connected (directly) to an Arduino pin.

You cannot do that!

(I should not need to explain why - read a lot of other discussions here; you really need to!)

Put the anode to +5V or for PWM you need a transistor driver.

In other words the anode should be connected directly to +5V.
If you want to use a transistor then you could try a Series-Pass configuration with the collector connected directly to +5V and the emitter to the anode of the display and a 330 ohm current limiting resistor between your PWM pin and the base of the transistor. Try a 2N2222,

If you connect the Anode to +5, and disconnect the Resistor from 0 and connect the resistor to Gnd, does the A segment light up?
If so, then likely SegA is suferring from insufficient current from pin 11.
The 470 limits current to about 5-6mA, with all segments on you are right on the hairy edge of overstressing pin 11.
Having pin 11 drive a PNP or P-channel MOSFET thru a 270ohm up to 1K resistor would be much better for the life of your 328 chip. When the pin goes low, the PNP or P-channel turns on and acts as a high side switch to allow current to flow from 5V to the anode. Lower values of PWM would be brighter, and higher values dimmer.

If you connect the Anode to +5, and disconnect the Resistor from 0 and connect the resistor to Gnd, does the A segment light up?
If so, then likely SegA is suferring from insufficient current from pin 11.

And if not, then likely SegA is damaged.

Guys it's working now. looks like because.its a Com anode i need to reverse the codes. like 1s will be 0s and 0s will be 1s.