/*
* Blink_Trajeto-Radial
*
* Cada LED (cor) representa um determinado ponto (vértice) do espaço.
* Para o trajeto radial, a partir do vértice de origem (cor laranja), visita-se o
* vértice cor vermelho depois volta-se ao vértice de origem (cor laranja),
* e assim sucessivamente, para todos os outros vértices.
*
* Modified from the work by M Atkinson example.
*
* Displays the value as a binary number (Patterns) using an array of LEDs.
*
* Derived from work by M Atkinson.
* Original at http://www.multiwingspan.co.uk/arduino.php?page=led5
*
* Original at https://gist.github.com/skwashd/838e4e4485aceec0e102
*
* Original at - http://www.arduino.cc/en/Tutorial/Blink
*/
int ledPin[] = {7,8,9,10,11}; // LED connected to digital pin {7,8,9,10,11}
void setup() // run once, when the sketch starts
{
for (int i =0;i<5;i++)
{
pinMode(ledPin[i], OUTPUT); // sets the digital pin [i] as output
}
}
void loop() // run over and over again
{
byte nums[] = {1, 2, 1, 4, 1, 8, 1, 16, 1};
for (byte i = 0; i<9;i++)
{
displayBinary(nums[i]);
delay(1500);
}
}
void displayBinary(byte numToShow)
{
for (int i =0;i<5;i++)
{
if (bitRead(numToShow, i)==1) // Reads a bit of a number
{
digitalWrite(ledPin[i], HIGH); // sets the LED [i] on
}
else
{
digitalWrite(ledPin[i], LOW); // sets the LED [i] off
}
}
}