Hi I´m try to build a GPS-Kit like the following one:
http://thecustomgeek.com/2012/07/15/really-smalls-gps/
So i ordered the Adafruit Ultimate GPS
and the Adafruit OLED 128x64
Monochrome 0.96 128x64 OLED Graphic Display - STEMMA QT : ID 326 : $17.50 : Adafruit Industries, Unique & fun DIY electronics and kits.
Both work fine with the test code and I´m able to program by myself the OLED.
I´m trying to unterstand the GPS example code I´m not 100% sure about every detail about the code.
So after that I tried to use the code from TheCustomgeek.com.
I wird all with the same pins in the Code.
But it won´t work most oft the time it shows 0:0 or 20:00 or the screen ist just black.
Here is the Code from TheCustomgeek.com:
GPS-Smalls/GPS_1306.ino at master · jersagfast/GPS-Smalls · GitHub
I have no idea what I need to chance in the code ... there are only two thinks which are by myself different:
- I use an Arduino UNO
- and a 128x64 OLED and not the 128x32 Version
So after many tries I desited to write my own Code.
At first I only build the OLED "GUI".
There is it :
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//include
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//define
//OLED
#define OLED_VIN 8
#define OLED_MOSI 9
#define OLED_CLK 10
#define OLED_DC 11
#define OLED_CS 12
#define OLED_RESET 13
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
//buttons
#define left A5 // left or top button
#define mid A4 // middle button
#define right A3 // right or bottom button
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//variables
int mode = 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//setup
void setup() {
//pinmode OLED
pinMode(OLED_VIN,OUTPUT);
digitalWrite(OLED_VIN,HIGH); //turns OLED on/off
//pinmode buttons
pinMode(left,INPUT);
pinMode(mid,INPUT);
pinMode(right,INPUT);
//setup OLED
display.begin(SSD1306_SWITCHCAPVCC);
// startupscreen
display.clearDisplay();
display.setTextSize(3);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("GPS-Kit");
display.setTextSize(1);
display.print("by Louis Fischer");
display.display();
delay(2000);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//functions
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//main
void loop() {
////////////////////////////////////////////////////////
//chose mode with right button
if( digitalRead(right)==HIGH ){
mode++;
if( mode==6 ){
mode = 1;
}
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(3);
display.setCursor(10,22);
display.print("MODE ");
display.print(mode);
display.display();
delay(500);
}
////////////////////////////////////////////////////////
//mode 1 Time
if( mode==1 ){
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(3);
display.setCursor(14,10);
display.print("12");
display.print(":");
display.println("46");
display.setTextSize(2);
display.setCursor(47,42);
display.print("13");
display.display();
}
////////////////////////////////////////////////////////
//mode 2 Speed
if( mode==2 ){
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(0,0);
display.println("Current speed:");
display.println(" ");
display.setTextSize(4);
display.println("100");
display.setTextSize(2);
display.print("km/h");
display.display();
}
////////////////////////////////////////////////////////
//mode 3 Speed data
if( mode==3 ){
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(0,0);
display.println(" ");
display.print("max: ");
display.setTextSize(2);
display.print("121");
display.println(" km/h");
display.setTextSize(1);
display.println(" ");
display.print("avg: ");
display.setTextSize(2);
display.print("40");
display.println(" km/h");
display.display();
}
////////////////////////////////////////////////////////
//mode 4 GPS data
if( mode==4 ){
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(0,0);
display.print("Fix: ");
display.print("6");
display.print(" ");
display.print("Qualy: ");
display.println("0.987");
display.println(" ");
display.println("Location:");
display.println(" ");
display.print("Latitude: ");
display.println("40.2235");
display.print("longitude: ");
display.println("10.3581");
display.display();
}
////////////////////////////////////////////////////////
//mode 5 Overview
if( mode==5 ){
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(0,0);
display.print("Time: ");
display.print("12");
display.print(":");
display.print("33");
display.print(":");
display.println("01");
display.print("Current: ");
display.print("100");
display.println(" km/h");
display.print("maximum: ");
display.print("121");
display.println(" km/h");
display.print("averange: ");
display.print("40");
display.println(" km/h");
display.print("Fix: ");
display.print("6");
display.print(" ");
display.print("Qualy: ");
display.println("0.987");
display.print("Latitude: ");
display.println("40.2235");
display.print("longitude: ");
display.println("10.3581");
display.display();
}
}
This works fine. So I tried to implement the GPS. I just copy past the Code from the GPS example code in my Code.
But now the OLED don´t work anymore it it looks like every pixel is in the wrong place and it shows only the startup screen
but it is distorted.