Created
January 10, 2016 07:53
-
-
Save psychosophonis/debbfc71d033fe0ea65f to your computer and use it in GitHub Desktop.
Increment with Edge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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.setTextSize(3); // 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' | |
if ( x >= 100){ // check each time and see if x is equal to 100 yet..then do what is between the brackets | |
x = 0; //if it is equal to 100 then make it equal to zero. (start counting form zero gain_ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment