Question: I need help writing a program that creates a BCD 00 - 99 up counter on two seven segment displays. I'm using a 4 digit

I need help writing a program that creates a BCD 00 - 99 up counter on two seven segment displays. I'm using a 4 digit 7 segement display and have made all of the connections but I'm having trouble coding the multiplexing part. I'm only using 2 of the segments with the common cathode pins being 8 and 9 on the display being connected to pins a PD5 and PD4 on the arduino I just can't find examples that are writing the code like I am without using pinmode and digitalwrite functions, I'd rather it be formatted similar to what I've already coded. This is the code I already have. It counts up from 0 to 9 when the common pins are grounded, but the displays are doing the same thing.

#include #define F_CPU 16000000 #include //below is an array consisting of the numbers 0,1,2,3,4,5,6,7,8,9, int display[10] = {0b00111111, 0b00000110, 0b01011011, 0b01001111, 0b01100110, 0b01101101, 0b01111100, 0b00000111,0b01111111, 0b01100111}; void setup(); int main() {setup(); while(1)

{

for (int dig0 = 0; dig0 < 10; dig0++) { PORTB = display[dig0]; // send a byte to portb to display numbers PORTD = PORTB; // bit PB6 copied to PD6 _delay_ms(500); } // Wait for 0.5 sec before updating the display

} //end while loop

} //end main

//* void setup() { DDRB = 0b00111111; // portB pins are set as output DDRD = 0b01110000; // pins D6,D5,D4 are set as output }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!