Post by jxssicanguyenn on Feb 23, 2018 21:25:30 GMT
In this assignment you will use the DigitalIn and PwmOut interfaces on the mbed
microcontroller board to implement sound effects and blinking LEDs for a toy science fiction
spaceship.
Connect the piezo transducer (it looks like a small black cylinder with a hole at the top to emit
sound) between the mbed’s p21 and GND. Connect two pushbutton switches, one between the
mbed’s p19 and VOUT and another between p20 and VOUT. Connect a red LED in series with a
220 ohm resistor between the mbed’s p22 and GND (the LED’s cathode should be oriented
towards GND).
The mbed should start in an idle mode in which all of the LEDs are off and the piezo transducer
is silent. If either switch is pressed, the mbed begins one of two different effects, one effect for
each switch. When no effects are active, the mbed should return to the idle mode.
If the switch connected to p19 is pressed, the mbed should generate a “pew-pew” laser effect and
repeat the effect until the switch is released. During this effect the piezo transducer should
generate a descending frequency from 1760 Hz to 880 Hz over the span of 0.5 seconds.
Synchronized with this sound effect, the 4 built-in LEDs should sequentially fade on. For
example, as the piezo frequency transitions from 1760 Hz to 1540 Hz, LED1 should
simultaneously transition from full off to fully on. LED2, LED3, and LED4 should similarly fade
on for piezo frequencies between 1540 Hz to 1320 Hz, 1320 Hz to 1100 Hz, and 1100 Hz to 880
Hz respectively.
If the switch connected to p20 is pressed, the mbed should generate a “red alert” effect and
repeat the effect until the switch is released. During this effect the piezo transducer should
generate an ascending frequency from 440 Hz to 880 Hz over the span of 1 second, and then
remain silent for 0.5 second. Synchronized with this sound effect, the red led should fade on as
the piezo is generating the tone and remain off when the piezo is silent.
microcontroller board to implement sound effects and blinking LEDs for a toy science fiction
spaceship.
Connect the piezo transducer (it looks like a small black cylinder with a hole at the top to emit
sound) between the mbed’s p21 and GND. Connect two pushbutton switches, one between the
mbed’s p19 and VOUT and another between p20 and VOUT. Connect a red LED in series with a
220 ohm resistor between the mbed’s p22 and GND (the LED’s cathode should be oriented
towards GND).
The mbed should start in an idle mode in which all of the LEDs are off and the piezo transducer
is silent. If either switch is pressed, the mbed begins one of two different effects, one effect for
each switch. When no effects are active, the mbed should return to the idle mode.
If the switch connected to p19 is pressed, the mbed should generate a “pew-pew” laser effect and
repeat the effect until the switch is released. During this effect the piezo transducer should
generate a descending frequency from 1760 Hz to 880 Hz over the span of 0.5 seconds.
Synchronized with this sound effect, the 4 built-in LEDs should sequentially fade on. For
example, as the piezo frequency transitions from 1760 Hz to 1540 Hz, LED1 should
simultaneously transition from full off to fully on. LED2, LED3, and LED4 should similarly fade
on for piezo frequencies between 1540 Hz to 1320 Hz, 1320 Hz to 1100 Hz, and 1100 Hz to 880
Hz respectively.
If the switch connected to p20 is pressed, the mbed should generate a “red alert” effect and
repeat the effect until the switch is released. During this effect the piezo transducer should
generate an ascending frequency from 440 Hz to 880 Hz over the span of 1 second, and then
remain silent for 0.5 second. Synchronized with this sound effect, the red led should fade on as
the piezo is generating the tone and remain off when the piezo is silent.