|
Serial Musical Organ 1.0
Buzzer controller and musical organ
|
Implementation of tone generation functions for electronic organ. More...
#include "includes/CPU.h"#include <avr/io.h>#include <util/delay.h>#include "includes/organ.h"#include "includes/pinDefines.h"
Go to the source code of this file.
Functions | |
| void | playNote (uint16_t half_us, uint16_t duration_ms) |
| Generates a musical tone with specific duration. | |
| void | rest (uint16_t duration) |
Implementation of tone generation functions for electronic organ.
This file contains the implementation of functions required to generate musical tones using a piezoelectric buzzer.
Definition in file organ.c.
| void playNote | ( | uint16_t | half_us, |
| uint16_t | duration_ms | ||
| ) |
Generates a musical tone with specific duration.
Play a musical tone.
| [in] | half_us | Half period of the square wave in microseconds (1/(2*frequency)) |
| [in] | duration_ms | Total note duration in milliseconds |
This function generates a square wave on the buzzer pin to produce a musical tone. The tone is generated using the following formula:
@bugs For very small half_us (< 10), the generated frequency may be inaccurate due to loop overhead.
Implement hardware timer version for non-blocking playback
Add volume control using PWM modulation
Definition at line 66 of file organ.c.
References BUZZER_PIN, and BUZZER_PORT.
Referenced by main(), and play_twinkle_little_star().
