Skip to content

Instantly share code, notes, and snippets.

@DenverDias
DenverDias / dotPeriod
Created Aug 16, 2013
Defining dotPeriod
View dotPeriod
#define dotPeriod 100
@DenverDias
DenverDias / Floating dotPeriod
Last active Dec 21, 2015
Defining a floating dotPeriod
View Floating dotPeriod
#define dotPeriod (analogRead(2))
@DenverDias
DenverDias / otherPeriods
Created Aug 16, 2013
Other base Morse definitions
View otherPeriods
#define dashPeriod (dotPeriod*3)
#define relaxTime (dotPeriod)
#define letterSpace (dotPeriod*2)
#define wordSpace (dotPeriod*4)
@DenverDias
DenverDias / buzz frequency and output pin
Created Aug 16, 2013
Defining fixed frequency and output pin for Morse code
View buzz frequency and output pin
#define buzz 1000
#define tonePin 3
View Floating buzz output frequency
#define buzz (analogRead(1)+200)
@DenverDias
DenverDias / Defining a dit
Created Aug 16, 2013
Setting a sequence for a dit
View Defining a dit
void dit()
{
tone(tonePin, buzz);
delay(dotPeriod);
noTone(tonePin);
delay(relaxtime);
}
@DenverDias
DenverDias / Defining a dah
Created Aug 16, 2013
Setting the sequence for a dah
View Defining a dah
void dah()
{
tone(tonePin, buzz);
delay(dahPeriod);
noTone(tonePin);
delay(relaxtime);
}
@DenverDias
DenverDias / Defining a di
Created Aug 16, 2013
Making inner dits prettier
View Defining a di
void di()
{
dit();
}
@DenverDias
DenverDias / Defining playLetter function
Created Aug 16, 2013
Setting up a construct for playing morse code
View Defining playLetter function
void playLetter(char x)
{
switch (x):
case 'E':
dit(); return;
case 'T':
dah(); return;
case 'A':
di();dah(); return;
case 'O':
View Defining setup()
void setup()
{
Serial.begin(9600);
/* Using the serial command I program the Arduino to communicate at a baud rate of 9600 bits per second. */
pinMode(tonePin, OUTPUT);
// This command sets the pin to act as output
}