I want to count 0 to 9 by converting decimal to BCD in Arduino. Then sent it to CD4511 decoder which translates it to a seven-segment display. But it is not working. Please help. Photo of circuit and arduino code is attached.circuit design is as follows:-
the Arduino code for decimal to BCD is from 0 to 9 is `
    void setup(){
        pinMode(1, OUTPUT);
        pinMode(2, OUTPUT);
        pinMode(3, OUTPUT);
        pinMode(4, OUTPUT);
    }
void loop()
{
    int a,b,c,d;
    for (int x=0;x<10;x++){
    a=x%2;
    b=(x/2)%2;
    c=(x/4)%2;
    d=(x/8)%2;
    digitalWrite(1,a );
    digitalWrite(2,b );
    digitalWrite(3,c );
    digitalWrite(4,d );
  }
   
  
 }
`