Create a counter in C Show the count display in binary using

Create a counter in C. Show the count display in binary using RBO, RB1, RB2, and RB3 (RBO = LSB, RB3 = MSB). For example when the count is 0001, the RBO is high and all other LEOs are low. Four-bit counter using LED\'s in C. Four-bit counter using LED\'s in C. Bwter sounds for oppromotely one second when counter rolls from 1111 to 0000. Part 3: Use RM Pushbutton to trigger the four-bit counter LED\'s. Buzzer sounds for approximately one second when counter rolls from 1111 to 0000. Part 4: Use RA4 Pushbutton to trigger the four-bit counter LED\'s. Buzzer sounds for approximately one second when counter rolls from 1111 to 0000. Show the count on the LCD Display.

Solution

The software part in C is given below:

// 4 bit up counter

// Define Tact switch @ RC4

sbit Switch at RC4_bit;

// Define button Switch parameters

#define Switch_Pin 4

#define Switch_Port PORTC

#define Debounce_Time 20 // Switch Debounce time 20ms

unsigned short count;

void main()

{ ANSEL = 0b00000000; //All I/O pins are configured as digital

CMCON0 = 0x07 ; // Disbale comparators

TRISC = 0b00010000; // PORTC all output except RC4

TRISA = 0b00001000; // PORTA All Outputs, Except RA3

count = 0;

PORTC = count;

do

{ if (Button(&Switch_Port, Switch_Pin, Debounce_Time, 0))

{ if (!Switch)

{ count ++;

if (count ==16) count =0;

PORTC = count;

}

while (!Switch); // Wait till the button is released

  }

} while(1); // Infinite Loop

}

Output of the above program:

The counter starts from 0 (all LEDs off), and is incremented by 1 on every button press. After it reaches 15, it overflows and takes the next value 0. This repeats forever.

 Create a counter in C. Show the count display in binary using RBO, RB1, RB2, and RB3 (RBO = LSB, RB3 = MSB). For example when the count is 0001, the RBO is hig
 Create a counter in C. Show the count display in binary using RBO, RB1, RB2, and RB3 (RBO = LSB, RB3 = MSB). For example when the count is 0001, the RBO is hig

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site