In setup i turn a integer value into binary array.
In loop:
And I want to blink led according to number my led doesn't turn off. only on it is.
Please help thank you.
//---------------var-----------------
char binary[9];
char* string;
//---------------var end-------------
void setup()
{
Serial.begin(115200);
for(byte i = 0; i < 7; i++){
pinMode(i+13,OUTPUT);
}
byte someValue = 13; //For this example, lets convert the number 20
binary[9] = {0}; //This is where the binary representation will be stored
someValue += 128; //Adding 128 so that there will always be 8 digits in the string
itoa(someValue,binary,2); //Conver someValue to a string using base 2 and save it in the array named binary
string = binary + 1; //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 < 7; 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()
{
for(byte i = 0; i < 7; i++){
Serial.println(string[i]);
if(string[i]==1){digitalWrite(D0,HIGH);}
else if(string[i]==0){digitalWrite(D0,LOW);}
delay(1000);
}
delay(5000);
Serial.println(string);
}