#include <Gamer.h>
Gamer gamer;
void setup() {
gamer.begin();
}
void loop() {
}
Gamer
Library
Want to get more creative
with your DIY Gamer Kit? Well
here’s a helping hand to get
you on your way. A cheat sheet
with code and Arduino layout
for you to refer to whenever
you’re stuck in your electronic
exploration. Make, Play, Code
and Invent!
www.technologywillsaveus.org
@techwillsaveus
Made in Hackney, London
void setLED(bool value);
Sets the programmable LED to either HIGH or LOW.
void toggleLED();
Toggles / flips the programmable LED’s value.
Inputs
Use these functions to check if buttons are pressed or held. You can also read the raw value of the light dependent resistor.
bool isPressed(uint8_t input); Returns true if the button is pressed. (unique press!)
bool isHeld(uint8_t input); Returns true if the button is held. (continuous press!)
int ldrValue();
Returns the raw value of the LDR. void setldrThreshold(uint16_t threshold); If you treat the LDR as a button, this sets its trigger theshold.
Outputs
These functions help you write stuff to the display, as well as trigger the programmable red LED on the Gamer. void setRefreshRate(uint16_t refreshRate); Sets the refresh rate of the display. void updateDisplay();
Converts your display array into binary and burns it to the display.
void allOn();
Turns on all of the pixels. void clear();
Clears everything on the display. void printImage(byte* img); Burns a byte image into the display.
Keywords
Instead of trying to find out which input is plugged into which pin, you can use the following keywords as references to the pin numbers. For example, if you want to check if the “up” button is pressed, use the function isPressed(UP); #define UP 0 #define LEFT 1 #define RIGHT 2 #define DOWN 3 #define START 4 #define LDR 5
Setup
It’s very important to call the begin() function in your Arduino sketch, specifically within your setup function. This makes sure that all pins are set to inputs or outputs and prepares the hardware.
void begin();
Variables
You have full access to two variables. The 2 dimensional display array holds your world of pixels. Whenever you call updateDisplay() the display array is converted to the image array. Each row of the display is one byte. All of the rows live inside the image array. Most of the time, you will want to manipulate the display array, but if you’re a smarty-pants and you want to play around with more low-level things, feel free to tweak the bytes in the image array. It’s your fault if it breaks though!
byte display[8][8]; byte image[8];
Gamer
Lettering
This sheet will help you to get
coding and animating your
own images on the gamer. We
wanted to help you get started,
so we created the DIY Gamer
alphabet for you to use. Copy
the code next to the associated
letter to create it on screen.
Look at the code closely and
you can see how it
correlates with the pixels of the
screen. Use this system to
design your own letter-forms
and illustrations!
www.technologywillsaveus.org
@techwillsaveus
Made in Hackney, London
gamer.image[0] = B11111000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B11111000; gamer.image[4] = B10001000; gamer.image[5] = B10001000; gamer.image[6] = B10001000; gamer.image[7] = B00000000; gamer.image[0] = B10001000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B11111000; gamer.image[4] = B10001000; gamer.image[5] = B10001000; gamer.image[6] = B10001000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B10001000; gamer.image[4] = B10001000; gamer.image[5] = B10001000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B10001000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B10001000; gamer.image[4] = B10001000; gamer.image[5] = B01010000; gamer.image[6] = B00100000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B11111000; gamer.image[4] = B10001000; gamer.image[5] = B10001000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B00100000; gamer.image[1] = B00100000; gamer.image[2] = B00100000; gamer.image[3] = B00100000; gamer.image[4] = B00100000; gamer.image[5] = B00100000; gamer.image[6] = B00100000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B11111000; gamer.image[4] = B10000000; gamer.image[5] = B10000000; gamer.image[6] = B10000000; gamer.image[7] = B00000000; gamer.image[0] = B10101000; gamer.image[1] = B10101000; gamer.image[2] = B10101000; gamer.image[3] = B10101000; gamer.image[4] = B10101000; gamer.image[5] = B10101000; gamer.image[6] = B11011000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B10000000; gamer.image[2] = B10000000; gamer.image[3] = B11111000; gamer.image[4] = B10000000; gamer.image[5] = B10000000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B10000000; gamer.image[1] = B10000000; gamer.image[2] = B10000000; gamer.image[3] = B10000000; gamer.image[4] = B10000000; gamer.image[5] = B10000000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B10000000; gamer.image[2] = B10000000; gamer.image[3] = B11111000; gamer.image[4] = B00001000; gamer.image[5] = B00001000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B00001000; gamer.image[2] = B00010000; gamer.image[3] = B00100000; gamer.image[4] = B01000000; gamer.image[5] = B10000000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B11110000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B10001000; gamer.image[4] = B10001000; gamer.image[5] = B10001000; gamer.image[6] = B11110000; gamer.image[7] = B00000000; gamer.image[0] = B10001000; gamer.image[1] = B10010000; gamer.image[2] = B10100000; gamer.image[3] = B11000000; gamer.image[4] = B10100000; gamer.image[5] = B10010000; gamer.image[6] = B10001000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B11111000; gamer.image[4] = B10100000; gamer.image[5] = B10010000; gamer.image[6] = B10001000; gamer.image[7] = B00000000; gamer.image[0] = B10001000; gamer.image[1] = B10001000; gamer.image[2] = B01010000; gamer.image[3] = B00100000; gamer.image[4] = B00100000; gamer.image[5] = B00100000; gamer.image[6] = B00100000; gamer.image[7] = B00000000; gamer.image[0] = B01110000; gamer.image[1] = B10001000; gamer.image[2] = B10000000; gamer.image[3] = B10000000; gamer.image[4] = B10011000; gamer.image[5] = B10001000; gamer.image[6] = B01110000; gamer.image[7] = B00000000; gamer.image[0] = B11001000; gamer.image[1] = B10101000; gamer.image[2] = B10101000; gamer.image[3] = B10101000; gamer.image[4] = B10101000; gamer.image[5] = B10101000; gamer.image[6] = B10011000; gamer.image[7] = B00000000; gamer.image[0] = B10001000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B10001000; gamer.image[4] = B10001000; gamer.image[5] = B10001000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B10000000; gamer.image[2] = B10000000; gamer.image[3] = B10000000; gamer.image[4] = B10000000; gamer.image[5] = B10000000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B00001000; gamer.image[1] = B00001000; gamer.image[2] = B00001000; gamer.image[3] = B00001000; gamer.image[4] = B10001000; gamer.image[5] = B10001000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B10001000; gamer.image[4] = B10101000; gamer.image[5] = B10011000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B10001000; gamer.image[1] = B10001000; gamer.image[2] = B01010000; gamer.image[3] = B00100000; gamer.image[4] = B01010000; gamer.image[5] = B10001000; gamer.image[6] = B10001000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B10000000; gamer.image[2] = B10000000; gamer.image[3] = B11111000; gamer.image[4] = B10000000; gamer.image[5] = B10000000; gamer.image[6] = B10000000; gamer.image[7] = B00000000; gamer.image[0] = B11011000; gamer.image[1] = B10101000; gamer.image[2] = B10101000; gamer.image[3] = B10101000; gamer.image[4] = B10101000; gamer.image[5] = B10101000; gamer.image[6] = B10101000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B00100000; gamer.image[2] = B00100000; gamer.image[3] = B00100000; gamer.image[4] = B00100000; gamer.image[5] = B00100000; gamer.image[6] = B00100000; gamer.image[7] = B00000000;
Arduino
Cheat
Sheet
Need a hand starting with your
Arduino board and software?
This sheet explains some of the
basics to get you going on your
coding adventure!
www.technologywillsaveus.org
@techwillsaveus
Made in Hackney, London
Arduino Environment
Software written using Arduino are called sketches. These sketches are written in the Arduino Integrated Development Environment (IDE). Sketches are saved with the file extension .ino. The IDE has features for cutting/pasting and for searching/ replacing text. The message area gives feedback while saving and exporting and also displays errors. The console displays text output by the Arduino environment including complete error messages and other information. The bottom righthand corner of the window displays the current board and serial port.
The Toolbar
Below are the toolbar functions you’ll find when you open your Arduino software.
Sketch
A sketch is the name that Arduino uses for a program. It’s the unit of code that is uploaded to and run on an Arduino board.
Code
The setup() function is called when a sketch starts. Use it to initialize variables, pin modes, start using libraries, etc. The setup function will only run once, after each powerup or reset of the Arduino board.
After creating a setup() function, the loop() function does precisely what its name suggests, and loops consecutively, allowing your program to change and respond as it runs. Code in the loop() section of your sketch is used to actively control the Arduino board.
The code below won’t actually do anything, but its structure is useful for copying and pasting to get you started on any sketch of your own. It also shows you how to make comments in your code.
Any line that starts with two slashes (//) will not be read by the compiler, so you can write anything you want after it. Commenting your code like this can be particularly helpful in explaining, both to yourself and others, how your program functions step by step. void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Menus
Edit
Copy for Forum - Copies the code of your sketch to the clipboard in a form suitable for posting to the forum, complete with syntax colouring. Copy as HTML - Copies the code of your sketch to the clipboard as HTML, suitable for embedding in web pages.
Sketch
Verify/Compile - Checks your sketch for errors.
Show Sketch Folder - Opens the current sketch folder.
Add File - Adds a source file to the sketch (it will be copied from its current location). The new file appears in a new tab in the sketch window. Files can be removed from the sketch using the tab menu.
Import Library - Adds a library to your sketch by inserting #include statements at the start of your code.
Tools
Auto Format - This formats your code nicely: i.e. indents it so that opening and closing curly braces line up, and that the statements inside curly braces are indented more.
Archive Sketch - Archives a copy of the current sketch in .zip format. The archive is placed in the same directory as the sketch.
Board - Select the board that you’re using.
Serial Port - This menu contains all the serial devices (real or virtual) on your machine. It should automatically refresh every time you open the top-level tools menu.
Verify - Check your code for errors.
Upload - Compiles your code and uploads it to the Arduino I/O board.
New - Creates a new sketch. Open - Presents a menu of all the sketches in your sketch-book. Clicking one will open it within the current window. Save - Saves your sketch.
Serial Monitor - Opens the serial monitor.
Arduino Layout
The basic components on your Arduino board have been labelled below. These are the ones you will need to know about to get you started with Arduino.
Digital Pins Input LED Reset Button USB Connection Power Input Analog Pins
Power Pins Oscillator
Power LED Microcontroller Chip
Animation
Generator
Want to draw images for your
gamer but don’t want to have to
code it? The Animation
Generator allows you to create
images using a piece of
specially designed software
which generates code from
your drawings. Which you can
then upload to your gamer. It
also allows you to build
animations for your Gamer with
no coding required.
Wish that stick man you just drew could jump and run...now he can! As the animation generator allows you to combine single frames you’ve drawn in order to create an animation.
Image Example
Start by opening your GamerAnimPainter.pde file in Processing.Press (run) and the sketch will open.
Draw your image
Then hit c to Copy your code to your clipboard. Then head to Ardunio open File > Examples > Gamer > Alien. Delete existing code between the lines: Gamer gamer and void setup() } then paste your copied code from the clipboard here and hit Upload.
Or...
www.technologywillsaveus.org
@techwillsaveus
Made in Hackney, London
Start by opening your
GamerAnimGenerator.pde file in Processing.
Press (run) and the sketch will open.
Draw your first frame
Press Shift and f. This will duplicate the current frame.
Then draw the next frame.
Once you’ve drawn all your frames, preview your animation by pressing the spacebar.
Finally hit c to Copy your code to your clipboard. Then head to Ardunio and open - File > Examples > Gamer > Animationexample and delete existing code where it states. Replace this with yours! Then paste your copied code from the clipboard here and hit Upload.
Repeat this step until you are happy with your animation.
You can skip between frames and edit them using the left and right keys.
Animation Example
This example will show you how to use the animator to create a stereo levels animation.Animation Generator Toolbar
Press i to invert your image
Hold shift and click with your mouse to erase.
Press s to save
Press c to copy to clipboard Press + to add a blank frame Press Shift and f to duplicate the current frame
Press - to remove the current frame Press x to start from scratch
Left and Right keys navigate between frames
Spacebar toggles playback Press h to toggle help bar Press backspace to clear
Save animation
Load animation Toggle playback Clear all frames Previous frame Next frame Add blank frame Duplicate current frame Remove frame Load Paint mode Erase mode Copy Code Save
Design your animation
Want to create an animation for your DIY Gamer but want to map it out before you start coding it or inputting it into our
animation software? This worksheet is for you to print off and use as a template to sketch out frame by frame what you
want your animation to look like.
Frame 1: Stationary alien. Frame 2: Alien mid-jump. Frame 3: Alien full jump. Frame 4: Alien mid-landing...
Example
Use this worksheet
to design and plan
out the animation
you want to create
for your DIY Gamer.
Sketch and make
notes so you know
exactly how your
animation will
work.
Cheat
Sheet
Want to get more creative
with your DIY Gamer Kit? Well
here’s a helping hand to get
you on your way. A cheat sheet
with code and Arduino layout
for you to refer to whenever
you’re stuck in your electronic
exploration. Make, Play, Code
and Invent!
www.technologywillsaveus.org
@techwillsaveus
Made Hackney, London
Keywords
Instead of trying to find out which input is plugged into which pin, you can use the following keywords as references to the pin numbers. For example, if you want to check if the “up” button is pressed, use isPressed(UP);
#define UP 0 #define LEFT 1 #define RIGHT 2 #define DOWN 3 #define START 4 #define LDR 5
Setup
It’s very important to call the begin() function in your Arduino sketch, specifically within your setup function. This makes sure that all pins are set to inputs or outputs and prepares the hardware.
voidbegin();
Outputs
These functions help you write stuff to the display, as well as trigger the programmable red LED on the Gamer.
voidsetRefreshRate(uint16_t refreshRate); Sets the refresh rate of the display.
voidupdateDisplay();
Converts your display array into binary and burns it to the display.
voidallOn();
Turns on all of the pixels.
voidclear();
Clears everything on the display.
voidprintImage(byte* img); Burns a byte image into the display.
Inputs
Use these functions to check if buttons are pressed or held. You can also read the raw value of the light dependent resistor.
boolisPressed(uint8_t input); Returns true if the button is pressed. (unique press!)
boolisHeld(uint8_t input); Returns true if the button is held. (continuous press!)
intldrValue();
Returns the raw value of the LDR.
voidsetldrThreshold(uint16_t threshold); If you treat the LDR as a button, this sets its trigger theshold.
Variables
You have full access to two variables. The 2 dimensional display array holds your world of pixels. Whenever you call updateDisplay() the display array is converted to the image array. Each row of the display is one byte. All of the rows live inside the image array. Most of the time, you will want to manipulate the display array, but if you’re a smarty-pants and you want to play around with more low-level things, feel free to tweak the bytes in the image array. It’s your fault if it breaks though!
bytedisplay[8][8];
byteimage[8];
Board Pin Out
voidsetLED(bool value);
Sets the programmable LED to either HIGH or LOW.
voidtoggleLED();
Toggles / flips the programmable LED’s value.
Cheat
Sheet
This sheet will help you to get
coding and animating your
own images on the gamer. We
wanted to help you get started,
so we created the DIY Gamer
alphabet for you to use. Copy
the code next to the associated
letter to create it on screen.
Look at the code closely and
you can see how it
correlates with the pixels of the
screen. Use this system to
design your own letter-forms
and illustrations!
www.technologywillsaveus.org
@techwillsaveus
Made Hackney, London
gamer.image[0] = B11111000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B11111000; gamer.image[4] = B10001000; gamer.image[5] = B10001000; gamer.image[6] = B10001000; gamer.image[7] = B00000000; gamer.image[0] = B10001000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B11111000; gamer.image[4] = B10001000; gamer.image[5] = B10001000; gamer.image[6] = B10001000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B10001000; gamer.image[4] = B10001000; gamer.image[5] = B10001000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B10001000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B10001000; gamer.image[4] = B10001000; gamer.image[5] = B01010000; gamer.image[6] = B00100000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B11111000; gamer.image[4] = B10001000; gamer.image[5] = B10001000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B00100000; gamer.image[1] = B00100000; gamer.image[2] = B00100000; gamer.image[3] = B00100000; gamer.image[4] = B00100000; gamer.image[5] = B00100000; gamer.image[6] = B00100000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B11111000; gamer.image[4] = B10000000; gamer.image[5] = B10000000; gamer.image[6] = B10000000; gamer.image[7] = B00000000; gamer.image[0] = B10101000; gamer.image[1] = B10101000; gamer.image[2] = B10101000; gamer.image[3] = B10101000; gamer.image[4] = B10101000; gamer.image[5] = B10101000; gamer.image[6] = B11011000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B10000000; gamer.image[2] = B10000000; gamer.image[3] = B11111000; gamer.image[4] = B10000000; gamer.image[5] = B10000000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B10000000; gamer.image[1] = B10000000; gamer.image[2] = B10000000; gamer.image[3] = B10000000; gamer.image[4] = B10000000; gamer.image[5] = B10000000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B10000000; gamer.image[2] = B10000000; gamer.image[3] = B11111000; gamer.image[4] = B00001000; gamer.image[5] = B00001000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B00001000; gamer.image[2] = B00010000; gamer.image[3] = B00100000; gamer.image[4] = B01000000; gamer.image[5] = B10000000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B11110000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B10001000; gamer.image[4] = B10001000; gamer.image[5] = B10001000; gamer.image[6] = B11110000; gamer.image[7] = B00000000; gamer.image[0] = B10001000; gamer.image[1] = B10010000; gamer.image[2] = B10100000; gamer.image[3] = B11000000; gamer.image[4] = B10100000; gamer.image[5] = B10010000; gamer.image[6] = B10001000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B11111000; gamer.image[4] = B10100000; gamer.image[5] = B10010000; gamer.image[6] = B10001000; gamer.image[7] = B00000000; gamer.image[0] = B10001000; gamer.image[1] = B10001000; gamer.image[2] = B01010000; gamer.image[3] = B00100000; gamer.image[4] = B00100000; gamer.image[5] = B00100000; gamer.image[6] = B00100000; gamer.image[7] = B00000000; gamer.image[0] = B01110000; gamer.image[1] = B10001000; gamer.image[2] = B10000000; gamer.image[3] = B10000000; gamer.image[4] = B10011000; gamer.image[5] = B10001000; gamer.image[6] = B01110000; gamer.image[7] = B00000000; gamer.image[0] = B11001000; gamer.image[1] = B10101000; gamer.image[2] = B10101000; gamer.image[3] = B10101000; gamer.image[4] = B10101000; gamer.image[5] = B10101000; gamer.image[6] = B10011000; gamer.image[7] = B00000000; gamer.image[0] = B10001000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B10001000; gamer.image[4] = B10001000; gamer.image[5] = B10001000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B10000000; gamer.image[2] = B10000000; gamer.image[3] = B10000000; gamer.image[4] = B10000000; gamer.image[5] = B10000000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B00001000; gamer.image[1] = B00001000; gamer.image[2] = B00001000; gamer.image[3] = B00001000; gamer.image[4] = B10001000; gamer.image[5] = B10001000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B10001000; gamer.image[2] = B10001000; gamer.image[3] = B10001000; gamer.image[4] = B10101000; gamer.image[5] = B10011000; gamer.image[6] = B11111000; gamer.image[7] = B00000000; gamer.image[0] = B10001000; gamer.image[1] = B10001000; gamer.image[2] = B01010000; gamer.image[3] = B00100000; gamer.image[4] = B01010000; gamer.image[5] = B10001000; gamer.image[6] = B10001000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B10000000; gamer.image[2] = B10000000; gamer.image[3] = B11111000; gamer.image[4] = B10000000; gamer.image[5] = B10000000; gamer.image[6] = B10000000; gamer.image[7] = B00000000; gamer.image[0] = B11011000; gamer.image[1] = B10101000; gamer.image[2] = B10101000; gamer.image[3] = B10101000; gamer.image[4] = B10101000; gamer.image[5] = B10101000; gamer.image[6] = B10101000; gamer.image[7] = B00000000; gamer.image[0] = B11111000; gamer.image[1] = B00100000; gamer.image[2] = B00100000; gamer.image[3] = B00100000; gamer.image[4] = B00100000; gamer.image[5] = B00100000; gamer.image[6] = B00100000; gamer.image[7] = B00000000;
Arduino
Cheat
Sheet
Need a hand starting with your
Arduino board and software?
This sheet explains some of the
basics to get you going on your
coding adventure!
www.technologywillsaveus.org
@techwillsaveus
Made Hackney, London
Arduino Environment
Software written using Arduino are called sketches. These sketches are written in the Arduino Integrated Development Environment (IDE). Sketches are saved with the file extension .ino. The IDE has features for cutting/pasting and for searching/ replacing text. The message area gives feedback while saving and exporting and also displays errors. The console displays text output by the Arduino environment including complete error messages and other information. The bottom righthand corner of the window displays the current board and serial port.
The Toolbar
Below are the toolbar functions you’ll find when you open your Arduino software.
Sketch
A sketch is the name that Arduino uses for a program. It’s the unit of code that is uploaded to and run on an Arduino board.
Code
The setup() function is called when a sketch starts. Use it to initialize variables, pin modes, start using libraries, etc. The setup function will only run once, after each powerup or reset of the Arduino board.
After creating a setup() function, the
loop() function does precisely what its name suggests, and loops consecutively, allowing your program to change and respond as it runs. Code in the loop() section of your sketch is used to active-ly control the Arduino board.
The code below won’t actually do anything, but its structure is useful for copying and pasting to get you started on any sketch of your own. It also shows you how to make comments in your code.
Any line that starts with two slashes (//) will not be read by the compiler, so you can write anything you want after it. Commenting your code like this can be particularly helpful in explaining, both to yourself and others, how your program functions step by step.
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Menus
Edit
Copy for Forum - Copies the code of your sketch to the clipboard in a form suitable for posting to the forum, complete with syntax colouring. Copy as HTML - Copies the code of your sketch to the clipboard as HTML, suitable for embedding in web pages.
Sketch
Verify/Compile - Checks your sketch for errors.
Show Sketch Folder - Opens the current sketch folder.
Add File - Adds a source file to the sketch (it will be copied from its current location). The new file appears in a new tab in the sketch window. Files can be removed from the sketch using the tab menu.
Import Library - Adds a library to your sketch by inserting #include statements at the start of your code.
Tools
Auto Format - This formats your code nicely: i.e. indents it so that opening and closing curly braces line up, and that the statements inside curly braces are indented more.
Archive Sketch - Archives a copy of the current sketch in .zip format. The archive is placed in the same directory as the sketch.
Board - Select the board that you’re using.
Serial Port - This menu contains all the serial devices (real or virtual) on your machine. It should automatically refresh every time you open the top-level tools menu.
Verify - Check your code for errors.
Upload - Compiles your code and uploads it to the Arduino I/O board.
New - Creates a new sketch. Open - Presents a menu of all the sketches in your sketch-book. Clicking one will open it within the current window. Save - Saves your sketch.
Serial Monitor - Opens the serial monitor.
Arduino Layout
The basic components on your Arduino board have been labelled below. These are the ones you will need to know about to get you started with Arduino.
Digital Pins Input LED Reset Button USB Connection Power Input Analog Pins Power Pins Oscillator Power LED Microcontroller Chip
Image
Painter
Animation
Generator
Want to draw images for your
gamer but don’t want to have
to code it? The Image Painter
allows you to create images
using a piece of specially
designed software which
generates code from your
drawings. Which you can then
upload to your gamer.
Wish that stick man you just
drew could jump and run...now
he can! The Animation
Generator works very similarly
to the Image Painter but allows
you to combine single frames
you’ve drawn in order to create
an animation.
www.technologywillsaveus.org
@techwillsaveus
Made Hackney, London
Image Painter Toolbar
Press backspace to clear the page Press i to invert your image
Hold shift and click with your mouse to erase.
Press s to save
Press c to copy to clipboard
Example
Start by opening your GamerImagePainter.pde file in Processing.
Press (run) and the sketch will open.
Draw your image
Then hit c to Copy your code to your clipboard. Then head to Ardunio open File > Examples > Gamer > Alien. Delete existing code between the lines: Gamer gamer and void setup() } then paste your copied code from the clipboard here and hit Upload.
Example
This example will show you how to use the animator to create a stereo levels animation.
Start by opening your
GamerAnimGenerator.pde file in Processing.
Press (run) and the sketch will open.
Draw your first frame
Press Shift and f. This will duplicate the current frame.
Then draw the next frame
Repeat this step until you are happy with your animation.
You can skip between frames and edit them using the left and right keys.
Once you’ve drawn all your frames, preview your animation by pressing the spacebar.
Finally hit c to Copy your code to your clipboard. Then head to Ardunio and open - File > Examples > Gamer > Animationexample and delete existing code where it states. Replace this with yours! Then paste your copied code from the clipboard here and hit Upload.
Animation Generator Toolbar
Press i to invert your image
Hold shift and click with your mouse to erase.
Press s to save
Press c to copy to clipboard Press + to add a blank frame Press Shift and f to duplicate the current frame
Press - to remove the current frame Press x to start from scratch
Left and Right keys navigate between frames
Spacebar toggles playback Press h to toggle help bar Press backspace to clear