Hi 1st post asking for help, been trying to set up a nano, and a 128 x 64 oled for use on my model rail set up, i want the display to act as an arrival / departures board generating random times and destinations.
I can get it running using fixed times & destinations but am having issues with the random part, my current sketch is below.
any help would be greatly appreciated.
Steve
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>
/* Uncomment the initialize the I2C address , uncomment only one, If you get a totally blank screen try the other*/
#define i2c_Address 0x3c //initialize with the I2C addr 0x3C Typically eBay OLED's
//#define i2c_Address 0x3d //initialize with the I2C addr 0x3D Typically Adafruit OLED's
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // QT-PY / XIAO
Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
char *myString[]={"London","Birmingham","Manchester","Munich","Berlin","Hamburg","Paris","Madrid","Rome","Amsterdam","Brussells",};
char *yoString[]={"10:15","10:20","10:25","10:30","11:15","11:25","11:35",};
void setup() {
Serial.begin(9600);
delay(250); // wait for the OLED to power up
display.begin(i2c_Address, true); // Address 0x3C default
display.display();
delay(2000);
display.clearDisplay();
}
void loop()
{
display.setTextSize(1.5);
display.setTextColor(SH110X_WHITE);
display.setCursor(0, 0);
display.println(" ARRIVALS");
display.setTextSize(1);
display.println("10:20 Stutgartd");
display.println("10:43 London");
display.println("10:50 Hamburg");
display.println("11:02 Paris");
display.println("11:13 Rome");
display.print("11:26"); display.println(" Berlin");
display.display();
delay(2000);
display.clearDisplay();
// text display tests
// display.setTextSize(1.5);
// display.setTextColor(SH110X_WHITE);
// display.setCursor(0, 0);
// display.println(" DEPARTURES");
// display.setTextSize(1);
// display.println("12:20 2Stutgartd");
// display.println("12:43 2London");
// display.println("12:50 2Hamburg");
// display.println("13:02 2Paris");
// display.println("13:13 2Rome");
// display.print("13:26"); display.println(" 2Berlin");
// display.display();
// delay(2000);
// display.clearDisplay();
display.setTextSize(1.5);
display.setTextColor(SH110X_WHITE);
display.setCursor(0, 0);
display.println(" DEPARTURES");
display.setTextSize(1);
for (int i = 0; i < 9; i++) {
display.println(yoString[i+1])+(myString[i+1]);
display.println(yoString[i+2]);(myString[i]);
display.println(yoString[i+3]);(myString[i]);
display.println(yoString[i+4]);(myString[i]);
display.println(yoString[i+5]);(myString[i]);
display.println(yoString[i+6]);(myString[i]);
display.println(yoString[i+7]);(myString[i]);
display.display();
delay(2000);
display.clearDisplay();
}
}
this part does part of what i want in that it displays the times in a column, but i can't get the code to add the destinations, as you can see i've tried several ways of doing this but none seem to work.