How to Blink LED Lights in Binary Pattern with Arduino
The wizard had discovered a secret language that only the wisest of creatures could understand. It was called binary and it used only two symbols: 0 and 1. With this language, the wizard could communicate with the spirits of the elements and command them to do his bidding.
One day, the wizard decided to create a spell that would
make his orbs glow in a special pattern. He wrote the spell using a magical
code that looked like this:
This is the setup() function, which runs once when the Arduino board is powered on or reset. These lines set the pins for the LEDs as output pins, meaning that they will be used to send a signal (in this case, to turn the LEDs on and off).
This is the loop() function, which runs repeatedly after the setup() function has completed. These lines define the binary patterns for each of the 16 possible combinations of LED states, in Morse code. The digitalWrite() function is used to set the state of each LED (either HIGH or LOW).
The rest of the code is similar, but each section turns on the LEDs in a different pattern based on a binary sequence, with each LED representing a bit in the sequence. For example, the section that starts with digitalWrite(redLED,LOW) turns on the green LED to represent the binary number 0001. The binary numbers 0000 to 1111 are represented in this way, with each pattern being displayed for a duration of dat time before moving on to the next pattern.
Download the code here : ARDUINO CODE
No comments: