Skip to content

Instantly share code, notes, and snippets.

@krobro
krobro / morse_decoder.ino
Created March 24, 2015 22:06
Convert light signals received via light sensor from morse code to text.
//
// morse_decoder
//
// Convert light signals received via light sensor from morse code to text
//
// We are using port S1 on the Duinobot board for the light sensor.
// The value of THRESHOLD is dependent on your ambiant light ... it
// may need to be adjusted for your environment.
// A morse dot is assumed to be 500 msec (see DOT) ... have not tried any
// other speeds yet.
@krobro
krobro / Morse_Hello2.ino
Created March 24, 2015 22:05
Use the LED to send out 'HELLO' in morse code. This is an example solution to assignment 2 which utilizes procedures.
//
// Morse_Hello2
//
// Use the LED to send out 'HELLO' in morse code.
// This is an example solution to assignment 2.
//
// The Circuit:
// We use pin 13 as depending on the Arduino board
// (the Duinobot in our case), it has either:
// - a built-in LED or,
@krobro
krobro / Morse_Blinker.ino
Created March 24, 2015 22:02
Use the LED to send out arbitrary messages in morse code.
//
// Morse_Blinker
//
// Use the LED to send out arbitrary messages in morse code.
//
// We use pin 13 as depending on the Arduino board
// (the Duinobot in our case), it has either:
// - a built-in LED or,
// - a built-in resistor so that you only need to add an LED.
//
//I got my DuinoBot to play In the Hall of the Mountain King!
//Here's the sketch if you want to try it out.
//(I've also included the sketch to stop the program, because
//I foolishly started it before I could stop it from playing. all. day.)
//I used one of the examples to do this, DelayTone.
//http://www.kendormusic.com/str2004/parts/9841p1.jpg
//This is only the first 4 bars of the melody, so if any of you are interested
//
// UltrasoundPingTest
//
// Test the Ultrasound Sensor
//
// We are using port S5 on the Duinobot board
//
// NOTES:
// - Ports S0-S5 are analog input pins
// - S0 is identical to Arduino A0 and so on (S5=A5)
//
// ISeeLight
//
// Print the value of the light sensor to the Serial Monitor.
// Also, make electronic music ... like a theremin.
//
// We are using port S2 on the Duinobot board for the light sensor.
//
// NOTES:
// - Ports S0-S5 are analog input pins
//
// PressAButton
//
// Pressing the button causes the LED to light up.
//
// We are using ports S0 and S1 on the Duinobot board
// * The LED device will be plugged into S0,
// * The Button sensor will be plugged into S1.
//
// NOTES:
//Mario main them song
int melody[] = {
NOTE_E7, NOTE_E7, 0, NOTE_E7,
0, NOTE_C7, NOTE_E7, 0,
NOTE_G7, 0, 0, 0,
NOTE_G6, 0, 0, 0,
NOTE_C7, 0, 0, NOTE_G6,
0, 0, NOTE_E6, 0,
//
// SoundAndMusic
//
// Play music and blink the LED in synchronization
//
// We are using port S0 on the Duinobot board
//
// NOTES:
// - Ports S0-S5 are analog input pins
// - S0 is identical to Arduino A0 and so on (S5=A5)
/*
toneDelay Example:
Based on toneMelody by Tom Igoe.
The toneDelay function is an alternative to the tone function.
Basically is the same except it is a blocking function, i.e. it does not use a timer for frequency generation
Author: Federico Lanza
*/