写一段在ssd1106屏幕上画一个折线图的代码
时间: 2023-03-13 09:32:59 浏览: 62
示例代码:#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1106.h>#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1106 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);void setup() {
Serial.begin(115200); // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
} // Clear the buffer
display.clearDisplay(); // Draw a line of the graph
display.drawLine(0, 0, 64, 32, WHITE);
display.drawLine(64, 32, 128, 64, WHITE);
display.display();
}void loop() {
// Do nothing
}