Created
December 4, 2017 10:02
-
-
Save hugohil/05f0c675409601949a600d43c934128f to your computer and use it in GitHub Desktop.
arduinoled-test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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