One Key Writer

by tonygo2 in Circuits > Microcontrollers

712 Views, 3 Favorites, 0 Comments

One Key Writer

OneKeyWriter.jpg

Do you remember Stephen Hawking? He was the Cambridge professor and famous mathematician in the wheelchair with a computer generated voice. He suffered from Motor Neurone Disease and towards the end of his life, after he lost his speech, he was able to communicate through a speech-generating device – initially through use of a handheld switch, and eventually by using a single cheek muscle.

I thought I would have a go at creating a single switch text writing device. Just one switch - ON or OFF. What can you do with that?

We need to consider time. If you close a switch and then open it some moments later you have control of another variable. We can make use of the time delay between the closing and opening of the switch to generate different inputs and turn them into text strings or messages. I want to be able to write "HELLO, WORLD!" and send it to the Serial Monitor - all from a single button.

There is a millisecond timer running in your Arduino. It clicks on by 1 every 0.001 seconds. You can read its value with the statement

int t = millis();

// Do something

int tt = millis();

int timeDiff = tt - t;

Supplies

I'm going to use items which most Arduino users will already have and are quite cheap to purchase:

  • Arduino UNO
  • 16 x 2 LCD
  • 220 Ohm and 10K Ohm resistors
  • 10K Ohm potentiometer
  • Button switch
  • Breadboard or stripboard
  • Connecting wires

The Method

OKWInstr.jpg

Here we have a grid containing all the letters, digits 0 to 9 and come punctuation marks. The letter "A" is in row 1 and column 2. The digit "9" is in row 7 and column 1. (You might want to print this screen out to have in front of you while running the script later.)

The instructions tells you how to use the switch. If you hold down the button the row value will slowly count up from zero. Lift your finger from the button when the row value is 1.

Hold down the button again and the column number will start to count up from zero. Lift your finger when it shows 2 and you have picked the "A" from row:1 and column:2.

We now need to transfer the "A" to the message on the bottom row. Hold down the button and lift your finger on action 1 - add the chararacter.

To insert the "9" we pick row 9 and column 1 then add it with action 1.

Action 2 clears the whole message.

Action 3 Dumps a wrongly picked character without adding it to the message string. (Mis-picks are common!)

Action 4 sends the message from the LCD screen to the Serial Monitor.

Connecting Things Up

board for LCD.jpg

If you have a Liquid Crystal Display screen you will probably be using it all the time. It's a good idea to build a little connection board holding the LCD, potentiometer (for adjusting screen brightness) and the protecting resistor with single wires for 5 volts and GND. The track is cut on the reverse of the board, under the 220 Ohm resistor. I later added output sockets to the board for 5V and GND because the Arduino only has a single 5V socket. This saves time, wires and testing next time you need the LCD in another project. The "official method" is here:

https://www.arduino.cc/en/Tutorial/HelloWorld

The button was wired to pin 8 with a 10K pull-up resistor and to GND.

Here Is My Setup

setup.jpg

On the next page is a link toTinkercad version to try.

Use the mouse pointer and button to close and open the button switch in the centre of the diagram. You need to open the code window and then the Serial monitor at the bottom of the page to enable a message to be sent from the LCD screen to the Serial monitor. The "Start Simulation" button begins code execution.

You will probably find it quite difficult at first. Just think how frustrating it would be if this was your only method of communication.

Tinkercad Version

Main.jpg

I embedded a Tinkercad version here but there were too many buffering and timing problems to give a good experience. The window was also too small to allow the circuit, Code and essential Serial Monitor window to be displayed properly.

https://www.tinkercad.com/things/daSgRAOl0g1-oneke...

Here is the link to the Tinkercad original which is probably a good bit bigger and much easier to have the code window open during the simulation so that you can see the Serial Monitor. The essential timings work properly.

I hope you have enjoyed this Instructable and learned something along the way.

I entered this Instructable in the Arduino Contest and would be grateful for your vote if you enjoyed it.