Executive decision maker for the mbed NXP1768 Application board. Ask a question, and press the center joystick button. Uses a pushbutton, PWM speaker, mbed LEDs, RGB LED, LCD, and the C rand function.

Dependencies:   C12832_lcd LCD_fonts PinDetect mbed

Committer:
4180_1
Date:
Tue Feb 03 19:42:36 2015 +0000
Revision:
0:af96f6744422
ver 1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
4180_1 0:af96f6744422 1 #include "mbed.h"
4180_1 0:af96f6744422 2 // new class to play a note on Speaker based on PwmOut class
4180_1 0:af96f6744422 3 class Speaker
4180_1 0:af96f6744422 4 {
4180_1 0:af96f6744422 5 public:
4180_1 0:af96f6744422 6 Speaker(PinName pin) : _pin(pin) {
4180_1 0:af96f6744422 7 // _pin(pin) means pass pin to the Speaker Constructor
4180_1 0:af96f6744422 8 }
4180_1 0:af96f6744422 9 // class method to play a note based on PwmOut class
4180_1 0:af96f6744422 10 void PlayNote(float frequency, float duration, float volume) {
4180_1 0:af96f6744422 11 _pin.period(1.0/frequency);
4180_1 0:af96f6744422 12 _pin = volume/2.0;
4180_1 0:af96f6744422 13 wait(duration);
4180_1 0:af96f6744422 14 _pin = 0.0;
4180_1 0:af96f6744422 15 }
4180_1 0:af96f6744422 16
4180_1 0:af96f6744422 17 private:
4180_1 0:af96f6744422 18 PwmOut _pin;
4180_1 0:af96f6744422 19 };