Project showcase
Arduino Telegraph

Arduino Telegraph © GPL3+

An Arduino-powered telegraph as an external keyboard.

  • 1,683 views
  • 0 comments
  • 6 respects

Components and supplies

Abx00004 iso both
Arduino MKR1000
×1
Red momentary pushbutton
×2
4415447 jg5sklyzsj
Resistor 220 ohm
×2

Necessary tools and machines

Saw
Drill
Clamp

Apps and online services

About this project

Inspiration:

A couple of months ago, I decided to go to a Starbucks and order a drink. I walked through the door and saw a man hunched over a typewriter, probably writing poetry or something. I immediately knew that I had to outdo this guy to become The Ultimate Hipster™, but how? I decided to take it one step further (and by further I mean backwards). Reintroducing the telegraph!

How it works:

When you push the lever, the screw pushes the button down. If you hold it down for less than 300 milliseconds, the Arduino saves this as a dot. If it's longer than 300 ms, then it is saved as a dash. After you've created your desired combination of dots and dashes, hit the red button in the front to have your letter appear on the computer. If you press this button without typing any dots or dashes beforehand, it acts like hitting the space bar. For a more in-depth explanation, check out the comments I left on my code.

"This seems pretty useless."

Just about everything I build has no practical use in everyday life and that's okay. Personally, I build because I love seeing my ideas become reality and because I love to problem-solve as I go.

What was this built for?

This was created for my school's Senior Experience Program, where high school seniors get one month off from school to either get an internship or work on a project. I had a difficult time figuring out what I was going to do during it, so I hope this helps out anybody in a similar situation!

Code

Telegraph_codeArduino
#include <Keyboard.h>

const int letterPin = 6; //you can change these two pins to whatever you want
const int spacePin = 0;

unsigned long startPressedLetter;
unsigned long endPressedLetter;
unsigned long timeHeldLetter;
int buttonStateLetter = 0;
int lastButtonStateLetter = 0;

const unsigned long cutoff = 300; //I find that 300 ms works best
String morseLetter = "";

void setup() {
  Keyboard.begin();
  Serial.begin(9600);
  pinMode(letterPin, INPUT);
  pinMode(spacePin, OUTPUT);
}

void loop() {
  //all about the letter button
  buttonStateLetter = digitalRead(letterPin); //Did the letter button state change?
  if (buttonStateLetter != lastButtonStateLetter) { //if button is pressed or released:
    if (buttonStateLetter == HIGH) { //if it was pressed
      startPressedLetter = millis(); //save the time when it was pressed
    } else { //if it was released
      endPressedLetter = millis(); //save the time it was released
      timeHeldLetter = endPressedLetter - startPressedLetter; //calculate how long it was held down for
      morseLetter += isDash(timeHeldLetter); //this will be the morse code for a single letter
      delay(50);
      Serial.println(morseLetter);
    }
  }
  lastButtonStateLetter = buttonStateLetter; //the current button state is now the old one too;
  //other buttons
  checkSpace();
}

void checkSpace(){
  if (digitalRead(spacePin) == HIGH) { //if space button pressed down
    Keyboard.print(determineLetter());
    delay(500);
    morseLetter = "";
  }
}

char determineLetter() {
  if (morseLetter == "01") {
    return 'A';
  } else if (morseLetter == "1000") {
    return 'B';
  } else if (morseLetter == "1010") {
    return 'C';
  } else if (morseLetter == "100") {
    return 'D';
  } else if (morseLetter == "0") {
    return 'E';
  } else if (morseLetter == "0010") {
    return 'F';
  } else if (morseLetter == "110") {
    return 'G';
  } else if (morseLetter == "0000") {
    return 'H';
  } else if (morseLetter == "00") {
    return 'I';
  } else if (morseLetter == "0111") {
    return 'J';
  } else if (morseLetter == "101") {
    return 'K';
  } else if (morseLetter == "0100") {
    return 'L';
  } else if (morseLetter == "11") {
    return 'M';
  } else if (morseLetter == "10") {
    return 'N';
  } else if (morseLetter == "111") {
    return 'O';
  } else if (morseLetter == "0110") {
    return 'P';
  } else if (morseLetter == "1101") {
    return 'Q';
  } else if (morseLetter == "010") {
    return 'R';
  } else if (morseLetter == "000") {
    return 'S';
  } else if (morseLetter == "1") {
    return 'T';
  } else if (morseLetter == "001") {
    return 'U';
  } else if (morseLetter == "0001") {
    return 'V';
  } else if (morseLetter == "011") {
    return 'W';
  } else if (morseLetter == "1001") {
    return 'X';
  } else if (morseLetter == "1011") {
    return 'Y';
  } else if (morseLetter == "1100") {
    return 'Z';
  } else if (morseLetter == "") {
    return ' ';
  } else if (morseLetter == "010101") {
    return '.';
  } else if (morseLetter == "110011") {
    return ',';
  } else if (morseLetter == "001100") {
    return '?';
  } else if (morseLetter == "10010") {
    return '/';
  } else if (morseLetter == "011010") {
    return '@';
  } else if (morseLetter == "01111") {
    return '1';
  } else if (morseLetter == "00111") {
    return '2';
  } else if (morseLetter == "00011") {
    return '3';
  } else if (morseLetter == "00001") {
    return '4';
  } else if (morseLetter == "00000") {
    return '5';
  } else if (morseLetter == "10000") {
    return '6';
  } else if (morseLetter == "11000") {
    return '7';
  } else if (morseLetter == "11100") {
    return '8';
  } else if (morseLetter == "11110") {
    return '9';
  } else if (morseLetter == "11111") {
    return '0';
  } else {
    Serial.println("That's not Morse.");
  }
}

boolean isDash(long input) { //true means dash, false means dot
  if (input < cutoff) {
    return false;
  } if (input >= cutoff) {
    return true;
  }
}

Schematics

Telegraph Fritzing Diagram
Tele fritz usmrjsm5vo

Comments

Similar projects you might like

Arduino-Powered Telegraph

Project showcase by Savva Osipov

  • 8,808 views
  • 4 comments
  • 27 respects

Mini Telegraph

Project showcase by Yegor_A

  • 12,436 views
  • 13 comments
  • 87 respects

Ternary Chord Keyboard

Project tutorial by Mr_Glenn

  • 3,466 views
  • 4 comments
  • 9 respects

Mind Control Drone

Project tutorial by WesleyCMD

  • 38,018 views
  • 33 comments
  • 161 respects

My Home1000 Holiday Things for HOME Automation & Control

Project showcase by Massimo Cestra

  • 5,100 views
  • 3 comments
  • 13 respects

Smart Connected Open Source Pot (Scopot)

Project showcase by Hendra Kusumah

  • 2,890 views
  • 1 comment
  • 29 respects
Add projectSign up / Login