Sale!

CPE 301 EMBEDDED SYSTEMS DESIGN HOMEWORK No. 5 solution

$30.00 $25.50

Category:

Description

5/5 - (4 votes)

1. Modify the Blink program you did from Chapter 3 (Arduino UNO version on page 85 of the
textbook) so that the function MyDelay(mSecondsApx) uses the Arduino ATmega2560 timer1 in
Normal mode to generate a delay of (mSecondsApx * one millisecond) before returning.
2. The international tuning standard for musical instruments is “A” above middle C” at a frequency of
440Hz. Write an Arduino Mega C language program to generate this tuning frequency and sound a 440
Hz tone on a loudspeaker connected to PortB.6 using Timer 1.
3. Write an Arduino Mega C language program using the Arduino ATmega2560 timer1 in Normal mode
to generate a 12 kHz square wave on PortB.6 using Timer 1.
4. Write an Arduino Mega C language program to generate a 500Hz signal on PortB.6 using Timer 1 in
Normal mode. The wave should have a 30% duty cycle (duty cycle = high time / period).
——————————————————————————————————————————
Extra Credit question (optional) – Total points possible for this HW = 150
——————————————————————————————————————————
5. Write an Arduino Mega C language function using Timer 1 in Normal mode to open and close a
digital camera shutter. Assume when the shutter release is pressed, the shutter speed is passed to your
function and that PortB.7 controls the camera shutter. When PortB.7 is 0 the shutter is closed and when
PortB.7 is 1 the shutter is open. Assume an initialization program has initialized and cleared PortB.7.
Typical shutter speeds are expressed in fractions of a second. Create a table for your function to use to
create shutter speeds of: 1, 1/2, 1/4, 1/8, 1/15. 1/30, 1/60, 1/125, 1/250, 1/500, 1/1000. The values passed
corresponding to these shutter speeds are 0 through 10. That is, if a 0 is passed the shutter speed is to be
1 second and if a 1 is passed the shutter speed is to be one half second, etc.