Question
A 7-segment display is just a set of seven LED bars contained in a convenient package, as depicted in Figure 6.6. They are generally provided
A 7-segment display is just a set of seven LED bars contained in a convenient package, as depicted in Figure 6.6. They are generally provided in two different packages: commoncathode and common-anode. The common-cathode package ties all cathodes together, which then needs to be connected to ground; each LED can be illuminated by applying positive voltage to the individual anodes (i.e., write a 1 to a port pin connected to that LED bar). The common-anode package ties all anodes together, which then needs to be connected to power; each LED can be illuminated by applying ground to the individual cathodes (i.e., write a 0 to a port pin connected to that LED bar). Write a C function that will take in a char variable, and output an appropriate 7-segment set of signals to display the associated alphabetic (both upper and lower case) and numeric character.
Within the setup() function, set seven available port pins (i.e., pins other than those already used for specific functionality) to output by setting the respective port pin data direction register bits to 1.
Create a function that takes in a char argument, then changes the seven port pins to either 1 or 0 in order to turn on or off the respective LED bar of the display in order to output an image of the corresponding argument. For example, if the argument is A, then a, b, c, e, f, g should all be 1 and d should be 0, assuming a common-cathode display (reverse the bit values for a common-anode display).
Within the loop() function, create some test code that will exercise your new function by looping through all the characters. Be sure to add enough delay() in between each call in order to see the output on the display.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started