/*Write a program to display the numbers in increasing order from 1 to 15 in binary form, using 4 LEDs, with a delay of 1 sec.
When it reaches the maximum value (15), wait 2 seconds and start from the minimum (1).*/
const int numLEDs = 4;
const int GPIO_Pins[] = {1, 5, 8, 15};
const int blinkRate = 1000;
void setup() {
// put your setup code here, to run once:
for (int i = 0; i < numLEDs; i++)
pinMode(GPIO_Pins[i], OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int binary[15][4];
for (int i = 0; i < 15; i++)
{
int num = i + 1;
for (int j = 3; j >= 0; j--)
{
int n = num % 2;
num = num / 2;
binary[i][j] = n;
}
}
for(int i = 0; i < 15; i++)
{
for (int j = 0; j < 4; j++)
{
if (binary[i][j] == 1)
{
digitalWrite(GPIO_Pins[j], HIGH);
}
else
{
digitalWrite(GPIO_Pins[j], LOW);
}
}
delay(1000);
}
delay(2000);
}