Final Project

Networking ver 1.0 (Networking and communications(week 14) + α)

I2C to display OLED

OLED display

0.96 inches 128x64 dots OLED display

  • Maker: SUNHOKEY Electronics Co.,Ltd.
  • Vcc voltage: 3~5.5V
  • Control protocol: I2C
  • Microchip: SSD1306
  • Resolution: 128x64 dot
  • Color of charactor: white
  • I2C address(default) 0x3C

Datasheet

I used software libraries to display the values from input devices

For using above libraries, I made a simple exampleas follows. I commented some important points in program to use above libraries on megaTinyCore(AVR 1-serires).

IC2.OLED.SSD1306.01.ino

  #include 
  #include 
  #include 
  
  #define SCREEN_WIDTH 128 // OLED display width, in pixels
  #define SCREEN_HEIGHT 64 // OLED display height, in pixels
  
  #define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
  
  Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
  
  void setup() {
    // https://github.com/SpenceKonde/megaTinyCore
    // set the pins for SCL:PA2(15) and SDA:PA1(14) on ATtiny3216
    // default is swap(0) that means SCL:PB0(9) and SDA:PB1(8)
    Wire.swap(1);
    // I2C address for OLED device is 0x78 (01111000)
    // after shift 1 bit, 00111100 is 0x3C
    display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  }
  
  void loop() {
    display.clearDisplay();
  
    display.setTextSize(2);
    display.setTextColor(WHITE);
    display.setCursor(0, 10);
  
    display.println("Hello");
    display.println("ATTiny3216");
  
    display.display();
  
    delay(1000);
  }
  

Test code to display value from input board to OLED over I2C

For my final project, I want to display the value that I selected by tactile switches.

Test code for displaying value from tactile switches controlled by ATtiny3216 input board is:

final_Input_brd_v0.30_i2c.ino

Reference

Weekly Assignment