33#include <avr/interrupt.h>
34#include <util/delay.h>
41static uint16_t duration[6] = {2000,1000,500,250,125,62};
51 TCCR0A |= (1 << WGM01);
52 TCCR0A |= (1 << COM0B0);
53 TCCR0B |= (1 << CS00);
57 uint8_t count_value = (((F_CPU / carrier_freq) / 2) - 1);
64 TCCR1B |= (1 << WGM12);
65 TCCR1B |= (1 << CS11);
66 TIMSK1 |= (1 << OCIE1A);
73 ANTENNA_DDR ^= (1 << ANTENNA);
82 duration[SEMIBREVE] = (60000 / bpm) * 4;
83 duration[MINIM] = (duration[SEMIBREVE] >> 1);
84 duration[CROTCHET] = (duration[MINIM] >> 1);
85 duration[QUAVER] = (duration[CROTCHET] >> 1);
86 duration[SEMIQUAVER] = (duration[QUAVER] >> 1);
87 duration[DEMISEMIQUAVER] = (duration[SEMIQUAVER] >> 1);
103 for (uint16_t count = 0; count < duration[note_length]; ++count)
112 ANTENNA_DDR |= (1 << ANTENNA);
122 for (uint16_t count = 0; count < duration[rest_length]; ++count)
void am_radio_transmit_note(note_pitch_t pitch, note_duration_t note_length)
Transmits a square wave, monophonic note for the specified duration.
void init_am_radio(frequency_khz_t carrier_freq)
Initialises timer/counter for radio transmission at a specified carrier frequency.
void arpeggio_in_c_test(void)
Test sequence, transmits an arpeggio scale in C major.
void am_radio_rest(note_duration_t rest_length)
Waits a specified duration before playing the next note.
void am_radio_set_tempo(uint8_t bpm)
Sets tempo for musical tones to be transmitted (in BPM).
Driver for a small, low power AM radio transmitter, to broadcast monophonic square wave tones over a ...
frequency_khz_t
Enum to expose the predefined carrier frequency options.
note_duration_t
Enum to expose the predefined duration options.
ISR(TIMER0_COMPA_vect)
Interrupt Service Routine.
Definitions for pin mapping (for CCS81 gas sensor)
note_pitch_t
Enum to expose the count values required to generate the pitches.