Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This is a highly modified version of the Example sketch available by clicking in the Arduino IDE File -> Examples -> Adafruit SSD1306 -> OLED_featherwing
- //To get this to work you need to follow the instructions in the first review by calBear at
- //https://www.amazon.com/SSD1306-Self-Luminous-Display-Compatible-Raspberry/dp/B08LYL7QFQ/ref=sr_1_3?dchild=1&keywords=128x64%2BOLED&qid=1627471545&sr=8-3&fbclid=IwAR2lzvpr5-noXW7rSlxwR5lF8OPrLJmvdJVk6vPRBobZDewJUZnqU1lXoSg&th=1
- //I have these instructions saved in an OLED Research.docx file
- //Read this article to understand what all of these buttons are from
- //Source 1 - https://learn.adafruit.com/adafruit-oled-featherwing/usage
- //Source 2 - https://lastminuteengineers.com/oled-display-arduino-tutorial/ - very useful article that explains the sketch below
- //#include <SPI.h> //Only used in the serial version of the OLED - not needed for I2C version
- #include <Wire.h>
- #include <Adafruit_GFX.h>
- #include <Adafruit_SSD1306.h>
- Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &Wire);
- // OLED FeatherWing buttons map to different pins depending on board:
- //This mapping is for the Arduino's ATMega328P processor
- //#define BUTTON_A 9 - Not needed since not using this Adafruit board mentioned in Source 1
- //#define BUTTON_B 6 - Not needed since not using this Adafruit board mentioned in Source 1
- //#define BUTTON_C 5 - Not needed since not using this Adafruit board mentioned in Source 1
- void setup() {
- Serial.begin(9600);
- Serial.println("OLED FeatherWing test");
- // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
- display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Address 0x3C for 128x32
- Serial.println("OLED begun");
- // Show image buffer on the display hardware.
- // Since the buffer is intialized with an Adafruit splashscreen
- // internally, this will display the splashscreen.
- display.display();
- delay(1000);
- // Clear the buffer.
- display.clearDisplay();
- display.display();
- Serial.println("IO test");
- //pinMode(BUTTON_A, INPUT_PULLUP);
- //pinMode(BUTTON_B, INPUT_PULLUP);
- //pinMode(BUTTON_C, INPUT_PULLUP);
- // text display tests
- display.setTextSize(1);
- display.setTextColor(SSD1306_WHITE);
- display.setCursor(0,0);
- //display.print("Connecting to SSID\n'adafruit':");
- //display.print("connected!");
- //display.println("IP: 10.0.1.23");
- //display.println("Sending val #0");
- display.println("Hello! My name is ");
- display.print("Jonathan DeWitt");
- display.setCursor(0,0);
- display.display(); // actually display all of the above
- }
- void loop() {
- //if(!digitalRead(BUTTON_A)) display.print("A");
- //if(!digitalRead(BUTTON_B)) display.print("B");
- //if(!digitalRead(BUTTON_C)) display.print("C");
- //delay(10);
- //yield();
- //display.display();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement