void setup()
{
Serial.begin(115200);
for(byte i = 0; i < 7; i++){
pinMode(i+13,OUTPUT);
}
byte someValue = 9; //For this example, lets convert the number 9
char binary[4] = {0}; //This is where the binary representation will be stored
someValue += 16; //Adding 16 4 ^2 = 16 so that there will always be 4 digits in the string
itoa(someValue,binary,2); //Conver someValue to a string using base 2 and save it in the array named binary
char* string = binary + 0; //get rid of the most significant digit as you only want 7 bits
Serial.println(string); //print out our string.
for(byte i = 0; i < 4; i++){
digitalWrite(i+13,string[i] - '0'); //write to the pin (the - '0' converts the bit of the string to HIGH or LOW)
}
}
void loop()
{
}