Have a program here I have used many times before without problems but today, when I try to upload, I get an error saying "low memory available, stability problems may occur".
Earlier today I added ATtiny to the boards manager and installed ATTiny drivers so I'm wondering if that has anything to do with it.
Code of my program and the error message below.
/* Arduino program to run UV LEDs Andrew Apel eye specialist....Brisbane
runTime in minutes is set via the DIP switches as a binary number
i.e. leftmost switch is digit 16 and rightmost switch is 1 withe other values as below
e.g. switch bit 4 and switch bit 0 ON = (16 + 1) = 17 minutes
**************************************************************************************************
NOTE....WHEN UPLOADING SKETCH, REMOVE LINK FROM PIN4 TO RESET PIN OUTERWISE SKETCH MAY NOT UPLOAD
**************************************************************************************************
*/
#include <Arduino.h>
#include <U8g2lib.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_INA219.h>
Adafruit_INA219 ina219;
//U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0);
//U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2 (U8G2_R0, A5, A4);
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
int seconds; // for Oled display timer showing seconds since start
int minutes; // for Oled display timer showing minutes since start
int runTime = 0; // time that is calculated from the DIP switch settings for the UV LEDs to run
//AUTO_RESET
int auto_reset = 4; // pin connected to reset for reset after maximum runtime. Avoids minutes coming around again after 1 hour and turning LEDs back on again
const byte startButton = 2; // start button starts the timing and turns the LEDs on
const byte mosfet = 3; // switch for turning UV Leds on and off
unsigned long currentTime;
unsigned long sTime;
void setup(void) {
pinMode(mosfet, OUTPUT); // configure pin as output for mosfet which drives the Led power to the buck converter
// DIP switches set the time the UV LEDs will be ON......"runTime"
pinMode(9, INPUT_PULLUP); // DIP switch for 1
pinMode(8, INPUT_PULLUP); // DIP switch for 2
pinMode(7, INPUT_PULLUP); // DIP switch for 4
pinMode(6, INPUT_PULLUP); // DIP switch for 8
pinMode(5, INPUT_PULLUP); // DIP switch for 16
pinMode(startButton, INPUT_PULLUP);
pinMode(mosfet, OUTPUT);
if (digitalRead(5) == LOW)
runTime += 16;
if (digitalRead(6) == LOW)
runTime += 8;
if (digitalRead(7) == LOW)
runTime += 4;
if (digitalRead(8) == LOW)
runTime += 2;
if (digitalRead(9) == LOW)
runTime += 1; // DIP switches which determine the runTime
//AUTO_RESET
digitalWrite (auto_reset, HIGH); // reset pin set to high for normal running
delay(200);
pinMode(auto_reset, OUTPUT);
//Serial.begin(9600); // FOR TESTING ONLY***********************************
// Serial.print ("runTime is set for ");
// Serial.println(runTime);
ina219.begin(); // initialise current sensor
ina219.setCalibration_16V_400mA(); // recalibrate current sensor to minimise fluctuations under load
u8g2.begin(); // initialise Oled display
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_t0_13b_tf);//u8g2_font_crox2hb_tf);
u8g2.setCursor(2, 10);
u8g2.print("TimeSet = ");
u8g2.print(runTime);
u8g2.print(" mins");
u8g2.setCursor(25,25);
u8g2.print("Press START");
//u8g2.setCursor(10, 25);
//u8g2.print("to run UV LED's");
u8g2.sendBuffer();
while (digitalRead(startButton) == HIGH) {
}
currentTime = millis();
}
void loop() {
float current_mA = 0;
sTime = millis() - currentTime;
seconds = (60 + sTime / 1000) % 60;
minutes = (60 + sTime / 60000) % 60; // method of getting the time by "remainder"
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_crox5tb_tf);
u8g2.setCursor (25, 32);
current_mA = ina219.getCurrent_mA();
// added this to compensate for fluctuating readout at zero load
if (current_mA < 1) {
current_mA = 0;
}
u8g2.print(current_mA);
u8g2.print (" mA");
u8g2.setFont(u8g2_font_crox2hb_tf);
u8g2.setCursor (20, 10);
u8g2.print (minutes);
u8g2.print ("m : ");
if (seconds < 10) u8g2.print ("0");
u8g2.print (seconds);
u8g2.print ("s");
u8g2.setCursor(100, 10);
u8g2.print (runTime);
u8g2.print("M");
u8g2.sendBuffer(); // transfer internal memory to the display
delay(200);
if (minutes > 31) {
digitalWrite(auto_reset, LOW); // after the minutes clock up to over 31 this resets the whole system
}
if (minutes < runTime) {
digitalWrite (mosfet, HIGH); // turns on UV LEDs
}
else {
digitalWrite (mosfet, LOW); // turns off UV LEDs
}
}
Sketch uses 20794 bytes (67%) of program storage space. Maximum is 30720 bytes.
Global variables use 1610 bytes (78%) of dynamic memory, leaving 438 bytes for local variables. Maximum is 2048 bytes.
Low memory available, stability problems may occur.