The Occupy Mars Learning Adventure

Training Jr. Astronauts, Scientists & Engineers

Morse Code Project 6 for Occupy Mars Learning Adventures

Leave a comment

Barboza Space Center USA Tiger teams are working on several emergency communication systems for the planet Mars.  This is one of six systems that our students are working on.  www.BarbozaSpaceCenter.com

Morse Code

by J.B. Wylzan

Project 13:  Morse Code 
This project  shows how to control an RGB Led colors using **modular programming.

Hardware:
RGB led
3 resistors
connecting wires
breadboard
Arduino R3 UNO board

Block Diagram:

Code # 13:

/*
iHackLab Morse Code
powered by Arduino
sketched by J.B. Wylzan
modified by Lawsinium

The RGB LED will display the morse code for I LOVE YOU.
This example code is public domain.
*/

int redPin = 8;
int greenPin = 7;
int bluePin = 6;

void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
//pinMode(bluePin, OUTPUT);
}

// .. / .-.. — …- . / -.– — ..-   <<< I LOVE YOU

void loop()
{

dit(); dit();
pause();
dit(); dat(); dit(); dit();
dat(); dat(); dat();
dit(); dit(); dit(); dat();
dit();
pause();
dat(); dit(); dat(); dat();
dat(); dat(); dat();
dit(); dit(); dat();
delay(1000);
}
// …………………………………………………………………………………………………….

( Only for Reference; don’t add the pic on your sketch )

// …………………………………………………………………………………………………….
void dit()
{
digitalWrite(redPin , HIGH);
delay(250);
digitalWrite(redPin , LOW);
delay(250);
}

void dat()
{
digitalWrite(greenPin , HIGH);
delay(1000);
digitalWrite(greenPin , LOW);
delay(250);
}

void pause()
{
digitalWrite(bluePin, HIGH);
delay(1000);
digitalWrite(bluePin, LOW);
delay(1000);
}

**Programmers Technique**

Modular Programming is one of the techniques programmers use to shorten their programs. Instead of writing very long algorithm, programs are contain into a chunk, a modular procedure. The functions dit(), dat(), and pause() are all procedures put into functional modules. This means that instead of writing all the sketch in every module inside the void loop() section, we simply use the shortcuts: dit(), dat(), and pause().

Challenge:
1. Sketch a program using a speaker that will produce the morse code sound for I LOVE YOU.
2. Sketch a program with a push button that will mimic the morse code for I LOVE YOU.

Actual Layout:



Procedure:
1. Build the prototype as shown above
2. Run the Arduino Interface
3. Select File > New
4. Copy Code # 13 above
5. Paste Code #13
6. Click File > Save
7. Click Verify
8. Click Upload
9. The RGB led will blink on and off like a morse code.

Advertisements

Author: Kids Talk Radio

Bob Barboza is an educator, STEM journalist, software designer and founder of The Occupy Mars Learning Adventures and the Barboza Design and Space Centers. He leads a team of scientists, engineers and STEAM++ educators. They are training students to become Jr. astronauts, scientists and engineers. His team provides internships and workshops in STEAM++ and the integration of Common Core State Standards and Next Generations Science Standards. Contact information: Bob.Barboza@Gmail.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s