Arduino কোড এবং SSD1306 OLED 128 x 64 ডিসপ্লের জন্য ভিডিও
এই টিউটোরিয়ালে, আমরা শিখব কীভাবে Arduino-এর সাথে SSD1306 OLED 128 x 64 ডিসপ্লে ব্যবহার করতে হয়। SSD1306 একটি বহুমুখী ডিসপ্লে যা আপনাকে সহজেই টেক্সট, গ্রাফিক্স এবং বিভিন্ন আকৃতি দেখাতে দেয়। এই নিবন্ধের শেষে, আপনি ডিসপ্লেটি সেট আপ করতে এবং এর ক্ষমতা প্রদর্শন করে এমন কোড চালাতে সক্ষম হবেন।

আমরা আপনাকে প্রয়োজনীয় হার্ডওয়্যার সংযোগের মাধ্যমে গাইড করব এবং প্রোগ্রামে ব্যবহৃত মূল শনাক্তকারীগুলি বুঝতে সাহায্য করার জন্য কোড স্নিপেট প্রদান করব। আরও ভিজ্যুয়াল ব্যাখ্যার জন্য, সংশ্লিষ্ট ভিডিওটি (ভিডিওতে 00:00 এ) দেখতে ভুলবেন না।
হার্ডওয়্যার ব্যাখ্যা
এই প্রকল্পের প্রধান উপাদানগুলির মধ্যে রয়েছে Arduino বোর্ড এবং SSD1306 OLED ডিসপ্লে মডিউল। SSD1306 ডিসপ্লে I2C যোগাযোগ প্রোটোকল ব্যবহার করে, যা মাত্র দুটি ডেটা লাইন প্রয়োজন হওয়ায় ওয়্যারিং সহজ করে: ডেটার জন্য SDA এবং ক্লক সিগন্যালের জন্য SCL। ডিসপ্লেটি 3.3V এবং 5V এর মধ্যে ভোল্টেজে কাজ করে, যা এটিকে বেশিরভাগ Arduino বোর্ডের সাথে সামঞ্জস্যপূর্ণ করে তোলে।
ডিসপ্লে ছাড়াও, মডিউলটিকে আপনার Arduino-এর সাথে সংযোগ করতে আপনার জাম্পার তারের প্রয়োজন হবে। সংযোগগুলির মধ্যে রয়েছে পাওয়ারের জন্য VCC, গ্রাউন্ডের জন্য GND, Arduino-এর ডেটা পিনে SDA এবং ক্লক পিনে SCL। এই সেটআপটি Arduino এবং OLED ডিসপ্লের মধ্যে সহজ যোগাযোগের অনুমতি দেয়।
ডেটাশিট বিবরণ
| নির্মাতা | Adafruit |
|---|---|
| পার্ট নম্বর | SSD1306 |
| লজিক/IO ভোল্টেজ | 3.3 V - 5 V |
| সাপ্লাই ভোল্টেজ | 3.3 V - 5 V |
| ডিসপ্লে রেজোলিউশন | 128 x 64 পিক্সেল |
| I2C ঠিকানা | 0x3C |
| ইন্টারফেস | I2C |
| প্যাকেজ | মডিউল |
- সঠিক ওয়্যারিং নিশ্চিত করুন: VCC থেকে 3.3V বা 5V, GND থেকে গ্রাউন্ড, SDA থেকে A4, SCL থেকে A5 (Arduino Uno-এর জন্য)।
- যদি SDA এবং SCL লাইনে পুল-আপ রেজিস্টর আগে থেকে না থাকে তবে ডিসপ্লেটির প্রয়োজন হবে।
- কোডে I2C ঠিকানা সঠিকভাবে সেট করা আছে কিনা যাচাই করুন, সাধারণত এই ডিসপ্লের জন্য 0x3C।
- সহজ ইন্টিগ্রেশনের জন্য Adafruit_SSD1306-এর মতো উপযুক্ত লাইব্রেরি ব্যবহার করুন।
- ওভারল্যাপিং আর্টিফ্যাক্ট এড়াতে নতুন গ্রাফিক্স আঁকার আগে ডিসপ্লেটি পরিষ্কার করুন।
ওয়্যারিং নির্দেশাবলী

SSD1306 OLED ডিসপ্লেটি আপনার Arduino-এর সাথে ওয়্যার করতে, এই ধাপগুলি অনুসরণ করুন:
OLED ডিসপ্লের VCC পিনটি Arduino-এর 5V (বা 3.3V) পিনের সাথে সংযুক্ত করুন। এরপর, ডিসপ্লের GND পিনটি Arduino-এর গ্রাউন্ড পিনের সাথে সংযুক্ত করুন। I2C যোগাযোগের জন্য, ডিসপ্লের SDA পিনটি Arduino-এর A4 পিনের সাথে এবং SCL পিনটি A5 পিনের সাথে সংযুক্ত করুন। এই সেটআপটি Arduino-কে I2C প্রোটোকল ব্যবহার করে OLED ডিসপ্লের সাথে যোগাযোগ করতে সক্ষম করবে।
নিশ্চিত করুন যে সমস্ত সংযোগ নিরাপদ, এবং আপনার নির্দিষ্ট ডিসপ্লে মডেলের জন্য সঠিক ভোল্টেজ ব্যবহার করছেন কিনা তা দুবার পরীক্ষা করুন। আপনি যদি একটি ভিন্ন Arduino মডেল ব্যবহার করেন, তবে SDA এবং SCL পিন ভিন্ন হতে পারে (যেমন, Arduino Mega-এর জন্য, SDA পিন 20-এ এবং SCL পিন 21-এ রয়েছে)।
কোড উদাহরণ ও ওয়াকথ্রু
কোডে, আমরা ডিসপ্লেটি ইনিশিয়ালাইজ করি এবং I2C ঠিকানা ও মাত্রার মতো প্যারামিটার সেট করি। একটি মূল শনাক্তকারী হল display, যা SSD1306 ডিসপ্লের ইনস্ট্যান্সকে প্রতিনিধিত্ব করে। সেটআপ ফাংশন থেকে একটি স্নিপেট এখানে দেওয়া হল:
void setup() {
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // I2C addr 0x3C দিয়ে ইনিশিয়ালাইজ করুন
}
এই স্নিপেটে, display.begin ফাংশনটি নির্দিষ্ট I2C ঠিকানা দিয়ে ডিসপ্লেটি ইনিশিয়ালাইজ করে। সঠিক যোগাযোগ নিশ্চিত করতে আপনার ডিসপ্লের সাথে ঠিকানাটি মিলানো অপরিহার্য।
এরপর, লুপ ফাংশনে, আমরা নতুন কন্টেন্ট আঁকার আগে স্ক্রিন পরিষ্কার করতে display.clearDisplay() মেথড ব্যবহার করি। আমরা setTextSize এবং setCursor মেথড ব্যবহার করে টেক্সটের আকার এবং অবস্থান সেট করতে পারি:
void loop() {
display.clearDisplay();
display.setTextSize(2);
display.setCursor(2,1); // উপরের বাম কোণে কার্সার সেট করুন
display.println("Robojax"); // টেক্সট প্রদর্শন করুন
}
এখানে, "Robojax" টেক্সটটি স্ক্রিনের (2,1) স্থানাঙ্কে প্রদর্শিত হয়। এটি OLED ডিসপ্লেতে টেক্সটের সুনির্দিষ্ট স্থান নির্ধারণের অনুমতি দেয়।
অবশেষে, ডিসপ্লেতে পরিবর্তনগুলি রেন্ডার করতে, আমরা display.display() কল করি। এই ফাংশনটি ডিসপ্লেতে সমস্ত বাফার করা কমান্ড পাঠিয়ে এর কন্টেন্ট আপডেট করে:
display.display();
এটি আপনার লুপ ফাংশনের শেষ লাইন হওয়া উচিত যাতে সমস্ত ড্রয়িং কমান্ড কার্যকর হয়। আপনি যদি এই ধাপটি ভুলে যান, তবে ডিসপ্লেতে কিছুই দেখা যাবে না।
মনে রাখবেন, সম্পূর্ণ কোডটি আপনার রেফারেন্সের জন্য নিবন্ধের নীচে লোড হয়।
প্রদর্শন / কী আশা করবেন
কোডটি আপনার Arduino-এ আপলোড করার পরে, আপনার OLED স্ক্রিনে "Robojax" টেক্সটটি দেখা উচিত। কোডটি ডিসপ্লেতে স্ক্রলিং টেক্সট এবং লাইন, আকৃতি এবং অন্যান্য গ্রাফিক্স আঁকারও প্রদর্শন করে। সাধারণ সমস্যাগুলির জন্য সতর্ক থাকুন, যেমন ভুল ওয়্যারিং বা অমিল I2C ঠিকানা, যা ডিসপ্লেটি সঠিকভাবে কাজ করতে বাধা দিতে পারে (ভিডিওতে 10:00 এ)।
ভিডিও টাইমস্ট্যাম্প
- 00:00 - SSD1306 OLED ডিসপ্লের পরিচিতি
- 02:30 - ডিসপ্লে ওয়্যারিং
- 05:00 - কোড ওয়াকথ্রু
- 08:00 - ডিসপ্লে বৈশিষ্ট্যের প্রদর্শন
- 10:00 - সাধারণ সমস্যা ও সমাধান
/*
* Original source: https://github.com/adafruit/Adafruit_SSD1306
* This is the Arduino code for the SSD1306 OLED 128 x 64 Display.
* Watch the video for details and demo: http://youtu.be/UmYiHTOz-5k
* This code has been modified to print specific elements such as text, lines, circles, rectangles, etc.
* I have added a custom method to make printing text easy.
If you get the error: Adafruit_GFX.h not found, download the Adafruit-GFX Library from:
https://github.com/adafruit/Adafruit-GFX-Library
Purchase this OLED module from Amazon: https://amzn.to/36zFvTb
* *
* Written by Ahmad Shamshiri for Robojax Video channel, www.Robojax.com
* Date: December 17, 2017, in Ajax, Ontario, Canada
* Permission granted to share this code, provided that this
* note is kept with the code.
* Disclaimer: This code is "AS IS" and for educational purposes only.
* This code has been downloaded from https://robojax.com
*
*/
/*********************************************************************
This is an example for our monochrome OLEDs based on SSD1306 drivers.
Pick one up today in the Adafruit shop!
------> http://www.adafruit.com/category/63_98
This example is for a 128x64 size display using I2C to communicate.
3 pins are required to interface (2 I2C and one reset).
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, check license.txt for more information.
All text above, and the splash screen must be included in any redistribution.
*********************************************************************/
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define LOGO16_GLCD_HEIGHT 16 // do not change this. Error in video
#define LOGO16_GLCD_WIDTH 16 // do not change this. Error in video
static const unsigned char PROGMEM logo16_glcd_bmp[] =
{ B00000000, B11000000,
B00000001, B11000000,
B00000001, B11000000,
B00000011, B11100000,
B11110011, B11100000,
B11111110, B11111000,
B01111110, B11111111,
B00110011, B10011111,
B00011111, B11111100,
B00001101, B01110000,
B00011011, B10100000,
B00111111, B11100000,
B00111111, B11110000,
B01111100, B11110000,
B01110000, B01110000,
B00000000, B00110000 };
// look at line 27 to 30 of Adafruit_SSD1306.h inside the library to select the dimensions
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
void setup() {
Serial.begin(9600);
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64)
// init done
}
void loop() {
display.clearDisplay();
robojaxText("Values", 3, 0, 2, false);
robojaxText("V: 41v", 3, 22, 2, false);
robojaxText("Temperature: 32C", 4, 45, 1, true);
display.drawLine(1, 37, 100, 37, WHITE);
display.drawRect(1, 20, 100,40, WHITE);
//display.drawCircle(63,31, 31, WHITE);
//display.startscrollright(0x00, 0x0F);
display.display();
delay(20000);
}
/*
* robojaxText(String text, int x, int y, int size, boolean d)
* text is the text string to be printed.
* x is the integer x position of the text.
* y is the integer y position of the text.
* size is the text size (1, 2, 3, etc.).
* d is a boolean value (true or false). Its purpose is unclear, use true.
*/
void robojaxText(String text, int x, int y,int size, boolean d) {
display.setTextSize(size);
display.setTextColor(WHITE);
display.setCursor(x,y);
display.println(text);
if(d){
display.display();
}
delay(100);
}
/*
* Original source: https://github.com/adafruit/Adafruit_SSD1306
* This is the Arduino code for the SSD1306 OLED 128 x 64 Display
* watch the video for details and demo http://youtu.be/UmYiHTOz-5k
* This code has been modified to print specific elements such as text, lines, circles, rectangles, etc.
* *
* *
* Written by Ahmad Shamshiri for Robojax Video channel www.Robojax.com
* Date: December 15, 2017, in Ajax, Ontario, Canada
* Permission granted to share this code given that this
* note is kept with the code.
* Disclaimer: this code is "AS IS" and for educational purposes only.
* This code has been downloaded from https://robojax.com
*
*/
/*********************************************************************
This is an example for our Monochrome OLEDs based on SSD1306 drivers
Pick one up today in the Adafruit shop!
------> http://www.adafruit.com/category/63_98
This example is for a 128x64 size display using I2C to communicate.
3 pins are required to interface (2 I2C and one reset).
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
*********************************************************************/
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define LOGO16_GLCD_HEIGHT 16 // do not change this. Error in video
#define LOGO16_GLCD_WIDTH 16 // do not change this. Error in video
static const unsigned char PROGMEM logo16_glcd_bmp[] =
{ B00000000, B11000000,
B00000001, B11000000,
B00000001, B11000000,
B00000011, B11100000,
B11110011, B11100000,
B11111110, B11111000,
B01111110, B11111111,
B00110011, B10011111,
B00011111, B11111100,
B00001101, B01110000,
B00011011, B10100000,
B00111111, B11100000,
B00111111, B11110000,
B01111100, B11110000,
B01110000, B01110000,
B00000000, B00110000 };
// look at line 27 to 30 of Adafruit_SSD1306.h inside the library to select the dimensions
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
void setup() {
Serial.begin(9600);
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64)
// init done
}
void loop() {
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(2,1);// set the cursor at x=2, y=1 which is top left corner of display
display.println("Robojax");// the actual text
display.setCursor(2,18);
display.println("YouTube");// set the cursor at x=2, y=18 which is top left under the first text line
display.drawLine(0,16, display.width()-1, 16, WHITE); // drawing from the point x=0, y=16 to x=64-1 y=16
display.display();
display.startscrollright(0x00, 0x0F);
delay(2000);
display.stopscroll();
delay(1000);
display.startscrollleft(0x00, 0x0F);
delay(2000);
display.stopscroll();
delay(1000);
display.startscrolldiagright(0x00, 0x07);
delay(2000);
display.startscrolldiagleft(0x00, 0x07);
delay(2000);
display.stopscroll();
delay(10000);
}
/*********************************************************************
Original source: http://playground.arduino.cc/Main/I2cScanner
This program will find the I2C address on the I2C device. Just upload the code into your Arduino
and open the serial monitor and wait. It will display the I2C address as 0x3C or similar.
* Please view other RoboJax codes and videos at http://robojax.com/learn/arduino
* If you are sharing this code, you must keep this copyright note.
*
*********************************************************************/
#include <Wire.h>
void setup()
{
Wire.begin();
Serial.begin(9600);
while (!Serial); // Leonardo: wait for serial monitor
Serial.println("\nI2C Scanner");
}
void loop()
{
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Wire.endTransmission to see if
// a device did acknowledge the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4)
{
Serial.print("Unknown error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
delay(5000); // wait 5 seconds for next scan
}
সম্পদ ও রেফারেন্সসমূহ
ফাইলসমূহ📁
ডেটাশিট (পিডিএফ)
-
SSD1306 display datasheetSSD1306 is a single-chip CMOS OLED/PLED driver with controller for organic / polymer light emitting diode dot-matrix graphic display system. It consists of 128 segments and 64commons. This IC is designed for Common Cathode type OLED panel. The SSD1306 embeds with contrast control, display RAM and oscillator, which reduces the number of external components and power consumption. It has 256-step brightness control. Data/Commands are sent from general MCU through the hardware selectable 6800/8000 series compatible Parallel Interface, I2C interface or Serial Peripheral Interface. It is suitable for many compact portable applications, such as mobile phone sub-display, MP3 player and calculator, etc.
SSD1306_display_datasheet.pdf1.79 MB