I am assumeing you can install the arduino IDE, connect arduino, find COM port, Wire up display to the I2C pins etc. Below is the code I used. You will require the associated libraries Adafruit GFX and Adafruit SSD1306.
Upload and your ready to go. Open comm port and set baud rate to 9600. Sending 1-4 switches the icons and sets a random fuel level and RPM.
Code:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire);
int PTOSPEED = 0;
boolean DIFFLOCK = false;
boolean FOURWD = false;
boolean BEACONS = false;
int RPM = 0;
int fuelLevel = 0;
//****Place Bitmaps Here*****
void setup() {
Serial.begin(9600); //Start serial comms
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x64
Serial.println(F("SSD1306 allocation failed"));
for (;;); // Don't proceed, loop forever
}
display.setRotation(2); //rotate display as this is how the OLED is mounted physically
display.clearDisplay(); //Clear buffer
display.drawBitmap(0, 0, johndeere, SCREEN_WIDTH, SCREEN_HEIGHT, 2); //Draw john deere logo to buffer
display.display(); //Display Buffer to screen
delay(1000); //Wait for one second
display.setTextColor(WHITE); //set text colour to white
drawScreen(); //run procedure called drawScreen
}
void loop() {
if (Serial.available()) //Read serial and toggle variables by sending 1,2,3 or 4
{
byte in = Serial.read();
{
if (in == '1')
{
if (PTOSPEED == 1000)
{
PTOSPEED = 0;
}
else
{
PTOSPEED = PTOSPEED + 500;
}
}
}
if (in == '2')
{
DIFFLOCK = !DIFFLOCK;
}
if (in == '3')
{
FOURWD = !FOURWD;
}
if (in == '4')
{
BEACONS = !BEACONS;
}
drawScreen();
}
}
void drawScreen()
{
display.clearDisplay(); //clear buffer
if (PTOSPEED == 0)
{
display.drawBitmap(0, 0, PTOA, 31, 32, WHITE); //display PTO off image
}
else if (PTOSPEED == 500)
{
display.drawBitmap(0, 0, PTOB, 31, 32, WHITE); //display PTO on image (500rpm)
}
else
{
display.drawBitmap(0, 0, PTOB, 31, 32, WHITE); //display PTO on image (1000rpm)
}
display.drawRect(0, 0, 31, 32, WHITE); //Draw rectangle around PTO image
if (DIFFLOCK)
{
display.drawBitmap(32, 0, diffLockB, 31, 32, WHITE); //display diff lock on image
}
else
{
display.drawBitmap(32, 0, diffLockA, 31, 32, WHITE); //display diff lock off image
}
display.drawRect(32, 0, 31, 32, WHITE); //Draw rectangle around diff lock image
if (FOURWD)
{
display.drawBitmap(64, 0, fourWheelDriveB, 31, 32, WHITE); //display 4WD on image
}
else
{
display.drawBitmap(64, 0, fourWheelDriveA, 31, 32, WHITE); //display 4WD off image
}
display.drawRect(64, 0, 31, 32, WHITE); //Draw rectangle around 4WD image
if (BEACONS)
{
display.drawBitmap(96, 0, flashingBeaconsB, 31, 32, WHITE); //display beacon on image
}
else
{
display.drawBitmap(96, 0, flashingBeaconsA, 31, 32, WHITE); //display beacon off image
}
display.drawRect(96, 0, 31, 32, WHITE); //Draw rectangle around beacon image
display.setTextSize(2); //Change text size to 2
RPM = random(750,3000); //pick a random number from 750 to 3000
display.setCursor(50, 42); //set cursor text location for RPM position
display.print(RPM); //print RPM variable
display.setTextSize(1); //Change text size to 1
display.setCursor(100, 42); //set cursor text location
display.print("RPM"); //print RPM after variable
int fuelLevel = random(0, 31); //Create a random variable for testing Level gauge
display.drawBitmap(-5, 32, fuel, 31, 32, WHITE); //Draw fuel gauge symbol
display.drawRect(26, 33, 10, 31, WHITE); //draw gauge outline
display.fillRect(26, fuelLevel + 33, 10, 31, WHITE); // draw solid infill for gauge level
display.display(); //send buffer to display
}