Question
The code for above is below const int bit_A = 2; const int bit_B = 3; const int bit_C = 4; const int bit_D =
The code for above is below
const int bit_A = 2;
const int bit_B = 3;
const int bit_C = 4;
const int bit_D = 5;
void setup()
{ // Initializing the Pins as OUTPUT
pinMode(bit_A, OUTPUT);
pinMode(bit_B, OUTPUT);
pinMode(bit_C, OUTPUT);
pinMode(bit_D, OUTPUT);
// ALL pins LOW at the start of program
digitalWrite(bit_A, LOW);
digitalWrite(bit_B, LOW);
digitalWrite(bit_C, LOW);
digitalWrite(bit_D, LOW);
}
void loop()
{
char i=0; // variable "counter"
for(i=0; i
{
counter(i); // Calling the counter function with the digit to display
delay(1000); // after 1 second
}
}
void counter(char digit)
{
// Making low previous digit
digitalWrite(bit_A, LOW);
digitalWrite(bit_B, LOW);
digitalWrite(bit_C, LOW);
digitalWrite(bit_D, LOW);
if(digit >= 8)
{
digitalWrite(bit_D, HIGH);
digit = digit - 8;
}
if(digit >= 4)
{
digitalWrite(bit_C, HIGH);
digit = digit - 4;
}
if(digit >= 2)
{
digitalWrite(bit_B, HIGH);
digit = digit - 2;
}
if(digit >= 1)
{
digitalWrite(bit_A, HIGH);
digit = digit - 1;
}
}
Show transcribed data
In the previous lab, we developed a binary to seven-segment display decoder using TinkerCad. A binary counter, created on a virtual Arduino, was used to as the input to a CD4511BE decoder chip that translates the counter to the seven digital signals needed to display the binary count in the form of digits from 0 to 9. The objective of this lab is to read an analog input pin, map the result to a number between 09 and display that number on the seven-segment display. The pre-lab focuses on the code required to do thisStep 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