User Manual

takes two steps. You must first write what you want the screen to display into the
screens memory, then you must tell the screen to display what is in its memory. To
begin, we must include our Wire library to use I C, and the SFE_MicroOLED library to
control the screen. Then the code initializes the OLED using DC_JUMPER = 1 . If you
have closed the jumper on the breakout board, use DC_JUMPER = 0 .
MicroOLED oled(PIN_RESET, DC_JUMPER);
void setup()
{
delay(100);
Wire.begin();
oled.begin();
oled.clear(ALL);
oled.display();
delay(1000);
oled.clear(PAGE);
randomSeed(analogRead(A0) + analogRead(A1));
}
The code below tells the microcontroller how to print each example. This is a good place
to look to see examples of how the functions discussed earlier are implemented.
void lineExample()
{
int middleX = oled.getLCDWidth() / 2;
int middleY = oled.getLCDHeight() / 2;
int xEnd, yEnd;
int lineWidth = min(middleX, middleY);
printTitle("Lines!", 1);
for (int i=0; i<3; i++)
{
for (int deg=0; deg<360; deg+=15)
{
xEnd = lineWidth * cos(deg * PI / 180.0);
yEnd = lineWidth * sin(deg * PI / 180.0);
oled.line(middleX, middleY, middleX + xEnd, middleY + yEnd);
oled.display();
delay(10);
}
for (int deg=0; deg<360; deg+=15)
{
xEnd = lineWidth * cos(deg * PI / 180.0);
yEnd = lineWidth * sin(deg * PI / 180.0);
2
9/17