Skip to content

Instantly share code, notes, and snippets.

@hugohil
Created December 4, 2017 10:02
Show Gist options
  • Save hugohil/05f0c675409601949a600d43c934128f to your computer and use it in GitHub Desktop.
Save hugohil/05f0c675409601949a600d43c934128f to your computer and use it in GitHub Desktop.
arduinoled-test
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
unsigned long frame = 0;
const float pi = 3.14;
const float speed = 10;
void setup() {
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
}
void loop() {
display.clearDisplay();
for (int x = 0; x < 128; x ++) {
int y = (int) ((sin((x + frame) / pi) + 1) * 4) + 12;
display.drawPixel(x, y, WHITE);
}
display.display();
frame += speed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment