Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include <SPI.h> //Not Needed if using I2c - SPI Driver for OLED
- #include <Wire.h> //I2C Driver
- #include <Adafruit_GFX.h> //Graphics library
- #include <Adafruit_SSD1306.h> //SSD1306 OLED Driver
- #define OLED_RESET 4 //Digital pin 4 set aside for OLED reset
- Adafruit_SSD1306 display(OLED_RESET); //We will call out OLED object display, but you can choose any name
- int level = 0; //INT variable for reading the pot on Analog 0
- void setup() { //SETUP - ONLY RUNS ONCE
- Serial.begin(9600); //Serial comms for debugging
- display.begin(SSD1306_SWITCHCAPVCC, 0x3c); //start the oled called display with a a hex addy of 0x3c
- display.display(); //Show what's in the buffer
- delay(2000); //take a breath
- display.clearDisplay(); //clear the screen
- pinMode(A0,INPUT); //tell the nano to look for an analog signal on pin A0
- }
- void loop() { //MAIN LOOP - RUNS OVER & OVER
- level = (analogRead(A0)); //read the voltage on pin A0 and put the ADC value into variable level
- display.clearDisplay(); //always start with a clear
- display.setTextSize(4); //set up text size
- display.setTextColor(WHITE); //set text color
- display.setCursor(10,10); //where to position cursor (128,64)
- display.clearDisplay(); //another flush
- display.println(level); //add data in the buffer - the variable level
- display.display(); //show the buffer
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement