In this tutorial, we are going to build an Arduino project that can be used to generate hundreds of unique stories !
To do this we are going to make use of a keyboard library that turns your Arduino into a USB keyboard
Note: This only works for certain arduinos (Leonardo, Micro, or Due)
Step 1: Wire Up Your Arduino
The first job is to connect five wires to your arduino:
- A blue wire into analog pin A0
- A black wire into one of the GND (ground) pins
- A red wire into the 5v pin
- Another black wire into another of the GND (ground) pins
- A yellow wire into digital pin 7
Step 2: Connect Your Potentiometer
Next we connect three wires to a dial potentiometer (here we use a 10k potentiometer, but most other types will also work). Connect one of the black wires to the first pin, the blue wire to the second and the red wire to the third (as show in the photo).
Step 3: Connect Your Button
In this project, we will also make use of a push button (tact switch)
Insert one into a breadboard as shown in the photo - make sure you position it the right way around (metal legs at the sides, rather than top and bottom).
Connect a black wire from GND to the top left leg of the button.
Connect the yellow wire from pin 7 to the bottom left leg of the button.
Step 4: Write Your Code
The next step is to write some code to generate a story based on the potentiometer and button input.
Download the StoryTeller.ino file and open it up in the Arduino application.
You can tinker with it if you like, or just use it as it is.
You'll notice the sentences that make up the story are near the top of the file. You can change these to whatever storylines you like (just make sure you update the numberOfSentences variable if you change the number of lines). Or just use them as they are for the time being.
For an explanation of "INPUT_PULLUP" see step 2 of this instructable
Step 5: Tell a Story
Upload your code onto your Arduino in the usual way (you might have to wait a short while after the code starts running since it can take the keyboard library a bit of time to start up).
Turn the potentiometer all the way to the right (clockwise) and then turn it back, all the way to the left (anti-clockwise). This calibrates the potentiometer so that the code know what the max and min values are.
Open up a text editor (any one will do - I use TextEdit on my Mac, you could use Notepad on Windows).
Every time you press the button, a line from the story will appear in your text editor.
Turn the potentiometer and press the button again - a different line will appear.
Experiment with different combinations and sequences to tell your own unique stories.
Step 6: Customise !!!
You can customise this project in a number of different ways...
Go back and change the sentences in the code so that you can tell completely different stories (making sure to update the numberOfSentences variable if you change the number of lines).
You can even customise your hardware - I added a glass crystal knob to my potentiometer and made a brass case for the arduino out of an old clock. I think it looks better for story telling ;o)