Hi,
I am trying to use a UNO with an 1306 OLED LCD display in conjunction with an SD card module.
Both work fine separately with test code but when I merge the code together the display wont work. Are these not compatible?
Any help appreciated...
Code is below
// --------------------------------------------------------
// Needed for Display
//
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
long lastTime = 0;
long minutes = 0;
long hours = 0;
long trig_minutes = 2;
long trig_hours = 0;
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
#if (SSD1306_LCDHEIGHT != 32)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
//
// ---------------------------------------------------------
//
//
// SD Card Parameters
//
#include <ThreeWire.h>
#include "SD.h" //SD Card Library
#include "TMRpcm.h" //Audio Library
#include "SPI.h" //SD SPI library
#define SD_ChipSelectPin 4 //Chip select is pin number 4
#define countof(a) (sizeof(a) / sizeof(a[0]))
TMRpcm play_audio;
ThreeWire myWire(8,2,10); // IO, SCLK, CE
//
// ---------------------------------------------------------
//
//
//
//
//
void setup(){
//
// Needed to wake up Audio with Test Ding...
//
play_audio.speakerPin = 9; // Audio Out on pin 9
play_audio.play("ring5.wav");
Serial.println("DING on Power Up");
delay (50);
play_audio.stopPlayback();
//
// SD Card Initialization
//
Serial.begin(9600); //Serial COM for debugging
if (!SD.begin(SD_ChipSelectPin))
{
Serial.println("SD fail");
return;
}
//
// Display Initialization
//
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
display.clearDisplay();
//
// Define IO Lines
//
pinMode(3, INPUT_PULLUP); // Handset Onhook/Offhook Detection
pinMode(7, INPUT_PULLUP); // Manual Trigger Button
pinMode(6, INPUT); // Button to Increment Minutes
pinMode(5, INPUT); // Button to Increment Hours
//
// Initial Text on Serial Terminal
//
Serial.println(" --- TEST ---");
delay (1000);
}
void loop ()
{
//
// Start Timer
//
if(millis()-lastTime > 60000)
{
minutes++;
lastTime = millis();
}
if(minutes > 59)
{
hours++;
minutes = 0;
}
display.display();
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("PHONE SIMULATOR");
display.setCursor(0,12);
display.println("ELAPSED:");
display.setCursor(52,12);
display.println(hours);
display.setCursor(68,12);
display.println(minutes);
Serial.println(minutes);
display.setCursor(0,22);
display.println("TRIGGER:");
display.setCursor(52,22);
display.println(trig_hours);
display.setCursor(68,22);
display.println(trig_minutes);
//
// Check if timer = preset hour & minute settings
//
if ((minutes == trig_minutes) and (hours == trig_hours))
{
display.clearDisplay();
display.setCursor(20,12);
display.println("RINGING");
Serial.println("Bingo ! Time Triggered");
Audio_Ringer();
}
}
void Audio_Ringer()
//
// **********************************
// * *
// * Play Audio Routine *
// * *
// **********************************
//
{
digitalWrite(6, LOW);
a: play_audio.play("ring5.wav"); // Play Ring File
Serial.println("RING RING"); // Update Serial Display
display.clearDisplay(); //
display.setCursor(20,12); // Update I2C Display
display.println("RINGING"); //
a1: Serial.println("RING LOOP");
if (digitalRead(3)==LOW) // Handset has been Lifted
{
play_audio.stopPlayback();
play_audio.play("x-files.wav"); // Play Msg
a2: Serial.println("PLAYING MSG"); // Update Serial Display
display.clearDisplay(); //
display.setCursor(20,12); // Update I2C Display
display.println("PLAYING MSG"); //
if (digitalRead(3)==HIGH)
{
Serial.println("STOP PLAYING MSG");
display.clearDisplay();
play_audio.stopPlayback();
delay (7000);
goto a;
}
goto a2;
}
if (digitalRead(7)==LOW)
{
goto a;
}
goto a1;
}
Hi,
I am trying to use a UNO with an 1306 OLED LCD display in conjunction with an SD card module.
Both work seperately with test code but when I merge the code display wont work. Ar ethese not compatible?
https://www.ebay.com.au/itm/0-96-I2C-IIC-Serial-128X64-128-64-Blue-OLED-LCD-LED-Display-Module-Hot/202698047598?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649
https://www.ebay.com.au/itm/For-Arduino-New-Micro-SD-Storage-Board-Mciro-SD-TF-Card-Memory-Shield-Module-SPI/391599342659?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649
Code is below