
Beginners Guide to Robotics
Robo Explorers 1
Red Green Blue LEDs
Fun Activity!
Welcome to a fun, hands-on activity that turns numbers into blinking lights! In this project, you'll use your Yellow Tyro board and the five LEDs to see how computers talk using binary code. Here's how it works:
When you type a number between 0 and 31 into your computer, the Arduino converts that number into binary—a language made up of only 0s and 1s. Each LED represents one of these binary digits. If a digit is 1, the corresponding LED lights up; if it's 0, the LED stays off. It's like a magic trick where your number turns into a secret pattern of lights! This activity is a great way to learn about binary numbers, how computers store information, and to have fun experimenting with electronics. Enjoy bringing your numbers to life with blinking LEDs!
How It Works
Setup:
The sketch starts by opening the Serial Monitor at 9600 baud and instructs you to enter a number between 0 and 31. It also sets pins 3, 4, 5, 6, and 7 as outputs for the LEDs.Reading the Number:
In theloop()
, the Arduino checks if a number is available from the Serial Monitor. It reads that number and makes sure it is between 0 and 31.Converting to Binary:
Using thebitRead()
function, the code checks each bit of the number (from the least significant bit to the most significant bit). Each bit value determines whether the corresponding LED is turned on (if 1) or off (if 0).Displaying the Result:
The binary representation is displayed both on the LEDs and printed to the Serial Monitor.
This fun activity lets you see numbers come to life as binary patterns on your LEDs—an exciting way to explore how computers use binary to represent information!