/*Write a program to display only even numbers in binary form, using 4 LEDs, with a
delay of 1 sec. When it reaches the maximum value, wait 2 seconds and start from the
minimum.*/
const int pins[] = {1, 5, 9, 13};
void setup() {
// put your setup code here, to run once:
Serial1.begin(115200);
for (int i = 0; i < 4; i++)
pinMode(pins[i], OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int arr[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;
arr[i][j] = n;
}
}
for (int i = 1; i < 15; i = i + 2)
{
for (int j = 0; j < 4; j++)
{
if (arr[i][j] == 1)
{
digitalWrite(pins[j], HIGH);
}
else
{
digitalWrite(pins[j], LOW);
}
}
delay(2500);
}
delay(5000);
}