Triple 7 Segment Display flickering

Hi there.

I’m having a problem with a code and a triple 7 segment display.
I am building a soldering station that displays the temperature via a triple 7 segment display.
The problem is that I am using the PID library in the same time and the display is flickering.
I tried using the TimerOne for the display, but it doesn’t have any effect. I also tried to change the PID interval to 10mS, but that didn.t help either.

#include <PID_v1.h>

byte const digits[] = {

int digit_common_pins[]={A3,A4,A5};  //A3 A4 A5
int max_digits =3;  
int current_digit=max_digits-1;

//Define Variables we'll be connecting to
double Setpoint, Input, Output;

//Define the aggressive and conservative Tuning Parameters
double aggKp=4, aggKi=0.2, aggKd=1;
double consKp=1, consKi=0.05, consKd=0.25;

//Specify the links and initial tuning parameters
PID myPID(&Input, &Output, &Setpoint, consKp, consKi, consKd, DIRECT);

void setup()

 DDRD = B11111111;  // sets Arduino pins 0 to 7 as outputs
 for (int y=0;y<max_digits;y++)
  pinMode(11, OUTPUT);

void loop()
  Input = analogRead(0);
  Input = map(Input, 0, 510, 25, 350);
  double Setpoint = analogRead(1);
  Setpoint = map(Setpoint, 0, 1023, 150, 350);
  double gap = abs(Setpoint-Input); //distance away from setpoint
  {  //we're close to setpoint, use conservative tuning parameters
    myPID.SetTunings(consKp, consKi, consKd);
     //we're far from setpoint, use aggressive tuning parameters
     myPID.SetTunings(aggKp, aggKi, aggKd);

  analogWrite(11, Output);

void show(int value) { 
  int digits_array[]={};  
  boolean empty_most_significant = true; 

  for (int z=max_digits-1;z>=0;z--)

    digits_array[z] = value / pow(10,z); 
    if(digits_array[z] != 0 ) empty_most_significant = false;  
    value = value - digits_array[z] * pow(10,z);

    if(!empty_most_significant || z==0){ 
                        PORTD = ~digits[digits_array[z]];
      PORTD = B11111111;  

     digitalWrite(digit_common_pins[z], HIGH);
     digitalWrite(digit_common_pins[z], LOW);


      if(current_digit < 0) 
        current_digit= max_digits; 

The problem is that I am using the PID library in the same time and the display is flickering.

This is because the PID library takes up a lot of time and does not allow access to the multiplexing display often enough.
The normal course of action is to off load the mindless multiplexing to some hardware. The MAX 7219 chip is a favorite for controlling seven segment displays. One chip can control 8 displays.

I managed to solve the problem.

I was using ATMEGA8 which doesn t work quite well with Arduino IDE 1.6.0 +. My code was running at 1MHz instead of 16MHz because of wrong fuses.

This solved my problem : "efuse" memory type not defined for part "ATMEGA8" · Issue #2541 · arduino/Arduino · GitHub