Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem: 1. Your health club has something called the 30 Minute Workout which consists of several machines and step stations that you complete in order.

Problem:

1. Your health club has something called the 30 Minute Workout which consists of several machines and step stations that you complete in order. On the wall are two lights, one red and one green, which indicate how much time you should spend at each station. However, the lights are on a fixed cycle and some patrons find the time between cycles either too long or too short. The health club has asked you to design an ATmega328-controlled system that can be installed at each station. It works as follows: the red light is on until the user presses a button to start. Once the button is pressed, the green light goes on for 60 seconds. After 60 seconds, the green light turns off and the red light turns on until the next time the button is pushed.

You think this is going to be easy until you realize that the longest delay you can get from Timer1 is around 4 seconds. You ask your professor for help and she suggests that instead of delaying 60 seconds at once, you can delay 4 seconds 15 times. She indicates that the easiest way to do this is to set up timer1 for a 4 second interrupt and then update a counter in the ISR. The main loop monitors the button for a push, controls the red and green lights and monitors the counter to know when to turn them on and off.

Write the program to control the station lights for the 30 Minute Workout using register programming. You may not use any ArduinoC instructions because the code needs to be portable to any ATmega328 platform.

*note when a variable is updated in an ISR and read in the main loop, it should be declared as volatile. If not, the compiler may deem it unnecessary and optimize it out. Ex: volatile int counter = 0;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

International Baccalaureate Computer Science HL And SL Option A Databases Part I Basic Concepts

Authors: H Sarah Shakibi PhD

1st Edition

1542457084, 978-1542457088

More Books

Students also viewed these Databases questions