Skip to content

Instantly share code, notes, and snippets.

@psychosophonis
Created January 10, 2016 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psychosophonis/7bd4bcb272989602212d to your computer and use it in GitHub Desktop.
Save psychosophonis/7bd4bcb272989602212d to your computer and use it in GitHub Desktop.
Increment exercise
#include <Wire.h> // these are all the libraries we need for working with our screen.
#include <SPI.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#define OLED_RESET 4 // here we get the screen ready for sending instructions to using the libraries above
Adafruit_SSD1306 display(OLED_RESET);
int x = 0; // this is an important new step - here we are making a container called X to put a number in.
//this is a container that can only fit integers inside of it - an integer is a whole number (the ones we count with)
//this container is called a variable. Variables are central to maths and computing.
void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // tell the Arduino that our little OLED screen is 128 x 64 pixels
display.clearDisplay();
display.setTextColor(WHITE);
}
void loop() {
display.setCursor(0,0); // this moves our cursor right back to the top left pixel.. we should talk about this.
display.clearDisplay(); // we need to clear our screen ever time we want to draw something new on it - other wise it will just write on top of what was there.
display.setTextSize(1); // this sets the text size for anything below this point - see what happens when you chnage it.
display.println("Enter via the Polygon Door! Then exit through the window");
display.println("");
display.setTextSize(1); // this sets the text size for anyhting below this point - see what happens when you chnage it.
display.print(x); // this prints the variable that we set at the top to our displays memory.... the container called X that onlyy fits integrers (numbers);
display.display(); // this prints whats in the displays memory to the screen
x++; // this adds one to X every time we run through the 'loop'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment