Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

We wish to drive a series of LEDs using the ATmega128 ports in order to create a

ID: 3638502 • Letter: W

Question

We wish to drive a series of LEDs using the ATmega128 ports in order to create a binary clock.

Specifications
The LED clock consists of 16 LEDs aligned in three rows. Binary LED numbers are represented in little endian form (i.e. the least significant bit is the rightmost one). There is no LED to distinguish between AM or PM.
• The top row of 4 LEDs gives the binary representation of the hour of the day (1 through 12).
• The middle row of 6 LEDs gives the binary representation of the current minute (0 through 59).
• The bottom row of 6 LEDs gives the binary representation of the current second (0 through 59).

The LEDs will be driven using ports A and B of the ATmega128. The following lists the mapping between bits on PORTA and PORTB and the LEDs on the clock. A high signal will light the LEDs.

PORTA = m3m2m1m0h3h2h1h0
PORTB = s5s4s3s2s1s0m5m4

Thus, to display a time of 1:03:02 pm:
PORTA = 0b00110001;
PORTB = 0b00001000;

There is an additional LED connect to bit3 of port C. We will use this LED as an alarm. It will turn on when the clock equals an alarm setting


Given these specifications on the LED binary clock, complete the following three functions.

// Initialize the ports
void initClock()
{

//your code here
}

// Drives the ports to make the LEDs turn on or off
void setTime(unsigned int hours, unsigned int minutes, unsigned int seconds)
{
// your code here

}

// Drive the alarm LED if the current time is alarm_time when this function is called.
void triggerAlarm(unsigned int alarm_time)
{
// your code here

}

Explanation / Answer

#include using namespace std; int main() { int m,d,y; coutm; coutd; couty; cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote