![]() Using draw.text function, we draw text on the screen which scrolls on the screen. Then in the while loop, using the range function, we create scrolling text ‘HELLO WORLD’.Using oled.fill(0) we see all pixels of OLED to black, and via oled.show() we commit the previous statement. Then we define some code to draw the code. After this, we import the font in which the text is to be displayed.#oled=adafruit_ssd1306.SSD1306_SPI(width,height,spi_interface,dc,rst,cs) Oled=adafruit_ssd1306.SSD1306_SPI(128,64,board.SPI(),digitalio.DigitalInOut(board.D6),digitalio.DigitalInOut(board.D4),digitalio.DigitalInOut(board.D5)) Syntax of the line is mentioned below as comment of that line for pin identification. Then we create an object named ‘oled’ for oled display. ![]() Also, we import some other modules which are required to run code.įrom PIL import Image, ImageDraw, ImageFont First, we import Image, ImageDraw, and ImageFont from the PIL module.Now open Thonny IDE on your Pi and type some line of code.Then press Ctrl+X, Y and Enter to save the changes now reboot your Pi (sudo reboot now in terminal).To do this, open a terminal window and type the below line to open config.txt file.For both I2C and SPI MOSI, SCK are same only name gets change, so we have to set baudrate for I2C only. After this, edit your config file to set baudrate for I2C Communication.In this under Interface options enable both.Now you have to enable SPI and I2C interface of Pi using.Pip3 install adafruit-circuitpython-ssd1306 Open Terminal and type the following commands one by one:.But before we have to install few repositories. For programming, we’ll use Adafruit library of SSD1306.SSD1306 OLED (7 pin versions, SPI communication).Raspberry Pi with screen, keyboard and mouse.If you are a beginner then first have a look at Arduino Tutorial of SSD1306.So to select to from or to which sensor we have to receive or send data we use CS pin. CS pin is optional, it is used mostly when we connect multiple devices to same SCK, MISO, and MOSI pin. These are four pins which are used generally. SCK (Serial Clock), MISO (Master In Slave Out), MOSI (Master Out Slave In), and CS (Chip Select). SPI communication uses 4 or 3 wires, depends on the sensor.They send Serial Clock and Serial Data to all sensor connected to it, but according to the working of the I2C communication, only the referred sensor responds to that data.I2C communication uses two pins SCL and SDA which are clock and serial data pins.The difference between these two communications are explained clearly in the detailed explanation of these communications in basic electronics section.There are two variants of it, one with I2C communication and the other with SPI communication. Today I’m using 128×64 one which has 7 pins.SSD1306 OLED is a monochrome display that uses a ssd1306 chip to control it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |