My project includes these parts from Core Electronics for a temperature monitoring device:
Adafruit Feather M0 Adalogger
DS3231 Precision RTC FeatherWing - RTC Add-on For Feather Boards
Adafruit FeatherWing OLED - 128x64 OLED Add-on For Feather - STEMMA QT / Qwiic
MicroSD Memory Card - 16GB Class 10 (formatted as FAT32)
These are stacked and connected through headers.
The problem:
Files are not created on and written to the SD card in my Arduino IDE sketch. I use Alarm1 to poll the probe (not connected, I am using dummy data until the probes arrive) and store a timestamp with temperature, however it fails to create a file at the line SD.open(fileName, FILE_WRITE). See code below. The SD card passes the if(!SD.begin(4)) test.
The CardInfo example sketch detects the card and displays specs + system files.
The Datalogger example sketch can create the “ANALOG00.TXT” file and subsequent increments (ANALOG01 etc.) but doesn’t write any data to the files.
I expected this microcontroller to work out of the box but it seems my code needs tweaking somewhere.
Two options I found online:
- Changing SPI speed. But the default is already 24 Mhz, the max SD functions can operate at.
- Changing the line SD.open(filename, FILE_WRITE): It was suggested using this line in setup() and FILE_APPEND in loop().
I have tried creating the file manually and running my sketch but it still fails to open the file for writing to. That is, for the line: if (myFile)… then write… but this is false and it outputs file error in the else test.
I have failed to do this myself and am at the end of my expertise, so I need assistance. Thank you.
Here is my code (apologies, the web interface does not recognise my backticks below):
#include <Wire.h>
#include <SD.h>
#include <Adafruit_SH110X.h>
#include <Adafruit_MAX31865.h>
#include "RTClib.h"
RTC_DS3231 rtc;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
// Display definitions, Adafruit Feather OLED
#define SCREEN_ADDRESS 0x3C
Adafruit_SH110X display = Adafruit_SH110X(64, 128, &Wire);
#define BUTTON_A 9
#define BUTTON_B 6
#define BUTTON_C 5
#define cardSelect 4
#define detectcard 7
// Choose your own 128x64 logo
static const uint8_t PROGMEM grdc[1024] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x80, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0xc0, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0xe0, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x61, 0xf0, 0x3c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x7c, 0xf8, 0x1c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3f, 0xf8, 0x1c, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1f, 0xfc, 0x1e, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0f, 0xfe, 0x1f, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0xfe, 0x0f, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0xff, 0x0f, 0x87, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0x8f, 0xc3, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7f, 0x87, 0xc3, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1f, 0xc7, 0xe3, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0f, 0xc7, 0xf3, 0xe0, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0xc3, 0xf3, 0xf0, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x43, 0xf9, 0xf0, 0x30, 0x00, 0x7f, 0x00, 0x7f, 0xe0, 0x0f, 0xf8, 0x00, 0x0f, 0xe0,
0xfe, 0x00, 0x03, 0xf9, 0xf8, 0x30, 0x01, 0xff, 0xc0, 0x7f, 0xf8, 0x0f, 0xff, 0x00, 0x3f, 0xf8,
0x3f, 0xe0, 0x01, 0xf9, 0xf8, 0x30, 0x03, 0xff, 0xe0, 0x7f, 0xfc, 0x0f, 0xff, 0x80, 0x7f, 0xfc,
0x0f, 0xfc, 0x01, 0xfd, 0xfc, 0x38, 0x07, 0xff, 0xe0, 0x7f, 0xfc, 0x0f, 0xff, 0xc0, 0xff, 0xfc,
0x03, 0xff, 0x80, 0xfd, 0xfc, 0x38, 0x0f, 0xc3, 0xe0, 0x78, 0x7c, 0x0f, 0x0f, 0xc1, 0xfc, 0x7c,
0x00, 0xff, 0xf0, 0xfc, 0xfe, 0x38, 0x0f, 0x81, 0x80, 0x78, 0x3e, 0x0f, 0x03, 0xe1, 0xf0, 0x38,
0x00, 0x3f, 0xfc, 0x7c, 0xfe, 0x3c, 0x0f, 0x00, 0x00, 0x78, 0x3e, 0x0f, 0x03, 0xe1, 0xf0, 0x00,
0x00, 0x1f, 0xff, 0x3c, 0xff, 0x3c, 0x0f, 0x1f, 0xf0, 0x7f, 0xfc, 0x0f, 0x01, 0xe1, 0xe0, 0x00,
0x00, 0x07, 0xff, 0xfc, 0x7f, 0x3e, 0x0f, 0x1f, 0xf0, 0x7f, 0xfc, 0x0f, 0x01, 0xe1, 0xe0, 0x00,
0x00, 0x01, 0xff, 0xfc, 0x7f, 0x3e, 0x0f, 0x1f, 0xf0, 0x7f, 0xf8, 0x0f, 0x01, 0xe1, 0xe0, 0x00,
0x00, 0x00, 0x7f, 0xf8, 0x7f, 0xbf, 0x0f, 0x9f, 0xf0, 0x7f, 0xf0, 0x0f, 0x03, 0xe1, 0xf0, 0x00,
0x00, 0x00, 0x1f, 0xf0, 0x3f, 0x9f, 0x0f, 0x81, 0xf0, 0x79, 0xf0, 0x0f, 0x03, 0xe1, 0xf0, 0x38,
0x07, 0xfe, 0x00, 0x00, 0x3f, 0x9f, 0x8f, 0xc1, 0xf0, 0x79, 0xf8, 0x0f, 0x0f, 0xe1, 0xf8, 0x7c,
0x03, 0xff, 0xfc, 0x00, 0x3f, 0x9f, 0x87, 0xff, 0xf0, 0x78, 0xf8, 0x0f, 0xff, 0xc0, 0xff, 0xfc,
0x00, 0x7f, 0xff, 0xc0, 0x1f, 0x9f, 0xc3, 0xff, 0xe0, 0x78, 0x7c, 0x0f, 0xff, 0x80, 0x7f, 0xfc,
0x00, 0x0f, 0xff, 0xf8, 0x1f, 0x8f, 0xc1, 0xff, 0xc0, 0x78, 0x7c, 0x0f, 0xff, 0x00, 0x3f, 0xf8,
0x00, 0x03, 0xff, 0xff, 0x0f, 0x8f, 0xe0, 0x7f, 0x00, 0x78, 0x3e, 0x0f, 0xf8, 0x00, 0x0f, 0xe0,
0x00, 0x00, 0xff, 0xff, 0xcf, 0x8f, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3f, 0xff, 0xf7, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0f, 0xff, 0xff, 0x07, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0xff, 0xff, 0x07, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xfe, 0x07, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x1f, 0xf8, 0x07, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7f, 0xc0, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 0x80, 0x03, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0f, 0xff, 0xfc, 0x01, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0xff, 0xff, 0xc1, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x7f, 0xff, 0xf8, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0f, 0xff, 0xfe, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static const uint8_t PROGMEM cesar[1024] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0xfe, 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x13, 0xf0, 0x0f, 0xc4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x19, 0xe3, 0xe3, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3c, 0xc7, 0xf1, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3e, 0x0f, 0x78, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x7f, 0x1e, 0x3c, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x7f, 0x9e, 0x3c, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x7f, 0x33, 0x66, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x7f, 0x21, 0xc2, 0x7f, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x20, 0x00, 0x6c, 0x00,
0x7f, 0x21, 0xc2, 0x7f, 0x01, 0x98, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x60, 0x00, 0x60, 0x00,
0xff, 0x73, 0xe6, 0x7f, 0x03, 0x01, 0xe3, 0xc7, 0x9e, 0x0d, 0x99, 0x9e, 0xf7, 0x9e, 0x6c, 0xf0,
0x7f, 0x7e, 0x3e, 0x7f, 0x03, 0x03, 0x36, 0x68, 0xd8, 0x0d, 0x99, 0xb3, 0x66, 0x23, 0x6d, 0x18,
0x00, 0x7e, 0x3e, 0x00, 0x03, 0x03, 0x37, 0x03, 0xd8, 0x0d, 0x99, 0xb8, 0x66, 0x0f, 0x6c, 0x78,
0x00, 0x7e, 0x3e, 0x00, 0x03, 0x03, 0xf3, 0xc6, 0xd8, 0x0d, 0x99, 0x9e, 0x66, 0x1b, 0x6c, 0xd8,
0xff, 0x33, 0xe6, 0x7f, 0x03, 0x03, 0x00, 0xec, 0xd8, 0x1f, 0xd9, 0x87, 0x66, 0x33, 0x6d, 0x98,
0x7f, 0x21, 0xc2, 0x7f, 0x01, 0x9b, 0x36, 0x6c, 0xd8, 0x18, 0xdb, 0xb3, 0x66, 0x33, 0x6d, 0x98,
0x7f, 0x21, 0xc2, 0x7f, 0x00, 0xf1, 0xe3, 0xc7, 0xd8, 0x18, 0xcd, 0x9e, 0x36, 0x1f, 0x6c, 0xf8,
0x7f, 0x33, 0xe6, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x7f, 0x9f, 0x7c, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x7f, 0x1e, 0x3c, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3e, 0x0e, 0x38, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3c, 0x67, 0xf3, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0xf1, 0xc7, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x11, 0xf8, 0x0f, 0xc4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static const uint8_t PROGMEM unimelb[1024] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x41, 0xe7, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xbe, 0x78, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x93, 0xff, 0x96, 0x80, 0x3e, 0x89, 0xe2, 0x24, 0x5d, 0x17, 0x30, 0x4f, 0xf4, 0x41, 0x9f,
0x00, 0x7f, 0xff, 0xf8, 0x80, 0x2a, 0x89, 0x02, 0x24, 0x49, 0x14, 0x28, 0xa5, 0x54, 0x42, 0x49,
0x00, 0x4f, 0xef, 0xe0, 0x80, 0x08, 0x89, 0x02, 0x26, 0x49, 0x14, 0x24, 0x84, 0x44, 0x44, 0x28,
0x00, 0x48, 0x44, 0x18, 0x80, 0x08, 0x89, 0x02, 0x26, 0x49, 0x14, 0x24, 0x84, 0x42, 0x84, 0x28,
0x00, 0x44, 0x44, 0x61, 0x00, 0x08, 0xf9, 0xc2, 0x25, 0x48, 0xa7, 0x24, 0x44, 0x43, 0x84, 0x2e,
0x00, 0x62, 0x4d, 0x91, 0x00, 0x08, 0x89, 0x02, 0x25, 0x48, 0xa4, 0x38, 0x24, 0x41, 0x04, 0x28,
0x00, 0x64, 0x28, 0x22, 0x00, 0x08, 0x89, 0x02, 0x24, 0xc8, 0xa4, 0x28, 0x24, 0x41, 0x04, 0x28,
0x00, 0x72, 0x20, 0x42, 0x00, 0x08, 0x89, 0x22, 0x24, 0xc8, 0x64, 0x24, 0xa4, 0x41, 0x02, 0x48,
0x00, 0x71, 0x00, 0x86, 0x00, 0x08, 0x89, 0xe1, 0xc4, 0x5c, 0x47, 0x26, 0x4e, 0x43, 0x81, 0x88,
0x00, 0x6c, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x6a, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7b, 0x80, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7f, 0xa0, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x6f, 0xf3, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x46, 0xcf, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x6c, 0x43, 0xfc, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0x00, 0x7e, 0x83, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7f, 0xcb, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7f, 0x94, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7f, 0xc0, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x5d, 0xc9, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x48, 0x88, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x5d, 0xc4, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7f, 0xc3, 0x3c, 0x00, 0x08, 0x10, 0xf9, 0xe3, 0xf0, 0x38, 0x3c, 0xe7, 0xc3, 0x87, 0x3f,
0x00, 0x7f, 0xc1, 0x1c, 0x00, 0x08, 0x10, 0xc0, 0xc1, 0x88, 0x64, 0x18, 0x46, 0x63, 0x82, 0x31,
0x00, 0x7f, 0xc8, 0x9c, 0x00, 0x08, 0x30, 0xc0, 0xc1, 0x88, 0xc2, 0x18, 0x46, 0x63, 0xc2, 0x30,
0x00, 0x7d, 0xce, 0xdc, 0x00, 0x0c, 0x30, 0xc0, 0xc1, 0x91, 0x81, 0x18, 0x46, 0x23, 0xe2, 0x30,
0x00, 0x38, 0xc2, 0x38, 0x00, 0x1c, 0x30, 0xc0, 0xc1, 0xa1, 0x81, 0x18, 0x46, 0x63, 0x62, 0x30,
0x04, 0x3d, 0xc0, 0x18, 0x40, 0x14, 0x50, 0xf8, 0xc1, 0xe1, 0x81, 0x18, 0x46, 0x43, 0x32, 0x3e,
0x3b, 0x3f, 0xff, 0x19, 0xb8, 0x16, 0x58, 0xf8, 0xc1, 0xb1, 0x81, 0x18, 0x47, 0xc3, 0x3a, 0x3e,
0x21, 0x1e, 0x00, 0xf1, 0x08, 0x12, 0x58, 0xc0, 0xc1, 0x99, 0x81, 0x18, 0x46, 0xc3, 0x1a, 0x30,
0x21, 0x0c, 0x38, 0x61, 0x08, 0x12, 0x98, 0xc0, 0xc1, 0x99, 0x81, 0x18, 0x46, 0x43, 0x0e, 0x30,
0x72, 0x99, 0xff, 0xb2, 0x9c, 0x13, 0x98, 0xc0, 0xc1, 0x89, 0x81, 0x18, 0x46, 0x63, 0x0e, 0x30,
0x0c, 0xa2, 0xfe, 0x4a, 0x60, 0x11, 0x18, 0xc0, 0xc1, 0x88, 0xc2, 0x18, 0x46, 0x23, 0x06, 0x30,
0x04, 0xcc, 0xfe, 0x26, 0x40, 0x11, 0x18, 0xc4, 0xc9, 0x88, 0x64, 0x18, 0xc6, 0x33, 0x02, 0x31,
0x07, 0xba, 0x7d, 0xdb, 0xc0, 0x31, 0x1c, 0xfd, 0xfb, 0xf0, 0x38, 0x0f, 0x87, 0x1f, 0x82, 0x7f,
0x05, 0xe5, 0x92, 0x48, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x08, 0x44, 0x46, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0d, 0x30, 0x38, 0x38, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0xc0, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static const uint8_t PROGMEM batt[18] = {
0xff, 0xf8,
0xff, 0xf8,
0xff, 0xfe,
0xff, 0xfe,
0xff, 0xfe,
0xff, 0xfe,
0xff, 0xfe,
0xff, 0xf8,
0xff, 0xf8
};
static const uint8_t PROGMEM batt2[27] = {
0xff, 0xff, 0xf0,
0xff, 0xff, 0xf0,
0xff, 0xff, 0xfc,
0xff, 0xff, 0xfc,
0xff, 0xff, 0xfc,
0xff, 0xff, 0xfc,
0xff, 0xff, 0xfc,
0xff, 0xff, 0xf0,
0xff, 0xff, 0xf0
};
// MAX31865 initialization, CS pin configuration
Adafruit_MAX31865 PT100 = Adafruit_MAX31865(A0);
String print_time(DateTime timestamp) {
char message[120];
int Year = timestamp.year();
int Month = timestamp.month();
int Day = timestamp.day();
int Hour = timestamp.hour();
int Minute = timestamp.minute();
int Second = timestamp.second();
sprintf(message, "%d-%d-%d %02d:%02d:%02d", Day, Month, Year, Hour, Minute, Second);
return message;
}
int TIS = 10;
int bat;
uint8_t status;
uint16_t rREF, rPT;
double temperature;
float getBatteryVoltage() {
pinMode(BUTTON_A, INPUT);
float measuredvbat = analogRead(A7);
delay(1);
measuredvbat *= 2; // we divided by 2, so multiply back
measuredvbat *= 3.3; // Multiply by 3.3V, our reference voltage
measuredvbat /= 1024; // convert to voltage
Serial.print("measuredvbat= ");
Serial.println(measuredvbat);
bat = ((measuredvbat - 3) / 1.14) * 100;
pinMode(BUTTON_A, INPUT_PULLUP);
return bat;
}
void setup()
{
display.begin(0x3C, true);
display.setRotation(1);
pinMode(BUTTON_A, INPUT_PULLUP);
pinMode(BUTTON_B, INPUT_PULLUP);
pinMode(BUTTON_C, INPUT_PULLUP);
pinMode(detectcard, INPUT_PULLUP);
// text display tests
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.setCursor(0,0);
rtc.disableAlarm(1);
rtc.clearAlarm(1);
if (rtc.lostPower()) {
display.clearDisplay();
display.setCursor(0,0);
display.println("RTC lost power. Reset the time!");
display.display();
rtc.adjust(DateTime(2021, 4, 22, 0, 0, 0));
}
// display initialization
display.clearDisplay();
display.drawBitmap(0, 0, grdc, 128, 64, 1);
display.display();
delay(3000);
display.clearDisplay();
display.drawBitmap(0, 0, cesar, 128, 64, 1);
display.display();
delay(3000);
display.clearDisplay();
display.drawBitmap(0, 0, unimelb, 128, 64, 1);
display.display();
delay(3000);
display.clearDisplay();
display.setCursor(20,16);
display.println("PT100");
display.setCursor(20,24);
display.println("Temperature");
display.setCursor(20,32);
display.println("Logger");
display.display();
delay(3000);
PT100.begin(MAX31865_3WIRE);
//check probe for errors
uint8_t status;
PT100.readRTD();
display.clearDisplay();
display.setCursor(0,0);
display.print("**INITIALIZING");
display.display();
delay(1000);
display.print(".");
display.display();
delay(1000);
display.print(".");
display.display();
delay(1000);
display.print(".");
display.display();
delay(1000);
display.println(".");
display.display();
delay(1000);
if (PT100.readFault())
{
display.println("Probe failure");
display.display();
delay(1000);
}
else
{
display.println("Probe OK");
display.display();
delay(1000);
}
if (! rtc.begin())
{
display.println("RTC failure");
display.display();
delay(1000);
}
else
{
display.println("RTC OK");
display.display();
delay(1000);
}
if (! SD.begin(cardSelect)) // check SD card
{
display.println("SD failure");
display.display();
delay(1000 );
}
else
{
display.println("SD OK");
display.display();
delay(1000);
}
if (! analogRead(detectcard)) // check SD card
{
display.println("No SD card inserted");
display.display();
delay(1000 );
}
else
{
display.println("SD card inserted");
display.display();
delay(1000);
}
DateTime now = rtc.now();
rtc.setAlarm2(now + TimeSpan(), DS3231_A2_PerMinute);
getBatteryVoltage();
}
void loop() {
display.clearDisplay();
DateTime now = rtc.now();
rtc.setAlarm1(now + TimeSpan(0, 0, 0, TIS), DS3231_A1_Minute);
//temperature = PT100.temperature(rPT, rREF);
temperature = 30;
status = PT100.readFault();
//display current time and temperature on OLED
display.setCursor(0,0);
display.println(print_time(now));
if (! status) {
display.println(" >>>PT100 ERROR<<< ");
}
else
{
display.setTextSize(2);
display.print(temperature);
display.print(char(247));
display.println("C ");
display.setTextSize(1);
}
display.println("Set logging interval:");
display.print(TIS);
display.print(" seconds");
if (bat > 99)
{
display.drawBitmap(106, 55, batt2, 22, 9, 1);
display.setCursor(107,56);
display.setTextColor(SH110X_BLACK);
display.print(bat);
display.setTextColor(SH110X_WHITE);
}
else
{
display.drawBitmap(113, 55, batt, 15, 9, 1);
display.setCursor(114,56);
display.setTextColor(SH110X_BLACK);
display.print(bat);
display.setTextColor(SH110X_WHITE);
}
display.display();
if (rtc.alarmFired(2) == true)
{
getBatteryVoltage();
rtc.clearAlarm(2);
}
//BUTTON_A: Begin temp logging
if (! digitalRead(BUTTON_A))
{
while (! digitalRead(BUTTON_A)) //wait for button depress to prevent cycling
{
__asm__("nop\n\t");
}
String fileName = "PT100_log_";
bool loopFile = true;
unsigned long i = 1;
while (loopFile)
{
if (!SD.exists(fileName+String(i)+".txt"))
{
display.setCursor(0,40);
display.println("Creating new logfile");
display.display();
delay(1000);
display.setTextColor(SH110X_BLACK);
display.setCursor(0,40);
display.println("Creating new logfile");
display.display();
display.setTextColor(SH110X_WHITE);
loopFile = false;
}
else
{
i += 1;
}
if (i==99)
{
loopFile = false;
}
}
fileName += String(i) + ".txt";
Serial.println(fileName);
File myFile = SD.open(fileName, FILE_WRITE); // FAILS HERE. IT DOES NOT OPEN THE FILE
while(digitalRead(BUTTON_A))
{
DateTime now = rtc.now();
display.clearDisplay();
//temperature = PT100.temperature(rPT, rREF);
temperature = 30; //DUMMY DATA
status = PT100.readFault();
//display current time and temperature on OLED
display.setCursor(0,0);
display.println(print_time(now));
if (!status) {
display.println(" >>>PT100 ERROR<<< ");
}
else
{
display.setTextSize(2);
display.print(temperature);
display.print(char(247));
display.println("C ");
display.setTextSize(1);
}
display.print("Logging at:");
display.print(TIS);
display.println("s int.");
display.println("Writing to:");
display.println(fileName);
if (bat > 99)
{
display.drawBitmap(106, 55, batt2, 22, 9, 1);
display.setCursor(107,56);
display.setTextColor(SH110X_BLACK);
display.print(bat);
display.setTextColor(SH110X_WHITE);
}
else
{
display.drawBitmap(113, 55, batt, 15, 9, 1);
display.setCursor(114,56);
display.setTextColor(SH110X_BLACK);
display.print(bat);
display.setTextColor(SH110X_WHITE);
}
display.display();
if (rtc.alarmFired(1) == true) //WRITE TEMP DATA TO SD
{
display.setCursor(0,56);
if (myFile) //ALWAYS EQUATES TO FALSE, EVEN IF THE FILE EXISTS
{
myFile.println("test");
myFile.print(print_time(now));
myFile.print(",");
myFile.println(temperature);
display.println("Data written!");
display.display();
delay(1000);
}
else
{
display.println("File error!"); //ALWAYS EQUATES TO TRUE
display.display();
delay(1000);
}
myFile.flush(); // always write completed lines
myFile.close();
rtc.clearAlarm(1);
rtc.setAlarm1(now + TimeSpan(0, 0, 0, TIS), DS3231_A1_Minute);
}
}
while (! digitalRead(BUTTON_A)) //wait for button depress to prevent cycling
{
__asm__("nop\n\t");
}
display.setCursor(0,48);
display.print("Logging stopped");
display.display();
delay(1000);
}//****END BUTTON_A****
//BUTTON_B: increment time interval
if (! digitalRead(BUTTON_B))
{
display.setCursor(0,32);
display.setTextColor(SH110X_BLACK);
display.print(TIS);
TIS++;
display.setCursor(0,32);
display.setTextColor(SH110X_WHITE);
display.print(TIS);
display.display();
while (! digitalRead(BUTTON_B)) //wait for button depress to prevent cycling
{
__asm__("nop\n\t");
}
}
//End BUTTON_B
//BUTTON_C: deccrement time interval
if (! digitalRead(BUTTON_C))
{
display.setCursor(0,32);
display.setTextColor(SH110X_BLACK);
display.print(TIS);
TIS--;
if (TIS<5)
{
display.setTextColor(SH110X_WHITE);
display.setCursor(0,40);
display.println("Can't go below 5");
display.display();
TIS = 5;
delay(2000);
}
display.setCursor(0,32);
display.setTextColor(SH110X_WHITE);
display.print(TIS);
display.display();
while (! digitalRead(BUTTON_C)) //wait for button depress to prevent cycling
{
__asm__("nop\n\t");
}
} //END BUTTON_C
}