Arduino won't work with one specific program

I have an Arduino Nano clone board and I have a program that I uploaded and used yesterday, the program itself has been uploaded to this board numerous times yesterday and worked every single time and had no issues at all.
I tried uploading the program again as the Lcd output wasn't showing anything once I powered it up as it should, and nothing is output to the serial monitor, I've uploaded other programs, such as the BMP180 test program and it worked perfectly with. However when I try to upload this specific program it doesn't work, the board is picked up by the serial port and I get no compiling errors or board errors when uploading, so it lets me upload the code but it does nothing.

Nothing is wired up extra or shorted, I even removed everything just to try and print to the serial port and even that gave me nothing.

I have the correct serial port selected, board and boot loader, everything fine and works with other programs, just seems to be this file which was working yesterday.

Here's my code if its the root of the problem
<#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_BMP085.h>
#include <DS3231.h>
Adafruit_BMP085 bmp;

DS3231 clock;
RTCDateTime dt;

String Min ;
String Sec ;
String Zero = "0";

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
Serial.begin(9600);
clock.begin();
lcd.begin();

Serial.println("Starting");

lcd.backlight();
lcd.clear();
lcd.setCursor(0,0);

if (!bmp.begin()) {
Serial.println("Could not find a valid BMP085 sensor, check wiring!");
//while (1) {}
}
}

void loop() {
dt = clock.getDateTime();
Min = String(dt.minute);
Sec = String(dt.second);
Serial.print("Temperature = ");
Serial.print(bmp.readTemperature());
Serial.println(" *C");
if ((dt.minute < 10) && (dt.second < 10)){
Min = Zero + Min;
Sec = Zero + Sec;
}else if ((dt.minute < 10) && (dt.second >= 10)){
Min = Zero + Min;
}else if ((dt.minute >= 10) && (dt.second < 10)){
Sec = Zero + Sec;
}

Serial.print(dt.year); Serial.print("-");
Serial.print(dt.month); Serial.print("-");
Serial.print(dt.day); Serial.print(" ");
Serial.print(dt.hour); Serial.print(":");
Serial.print(Min); Serial.print(":");
Serial.print(Sec); Serial.println("");

lcd.clear();
lcd.setCursor(0,0);
lcd.print(bmp.readTemperature(),1);
lcd.print(" *C");
lcd.setCursor(0,1);
lcd.print(dt.day);
lcd.print("-");
lcd.print(dt.month);
lcd.print(" ");
lcd.print(dt.hour);
lcd.print(":");
lcd.print(Min);
lcd.print(":");
lcd.print(Sec);
delay(999);
}

Again I had no issues at all yesterday, just today any help would be appreciated

Please post your code using code tags.

If it indeed compiles and is uploaded then I am going to guess it is stuck initializing some hardware. My method to find such errors is to put a serial print after each line of code in setup to see where it gets stuck.

What I do is when I get a new part I connect it and generate code to make it work, document it and save it. Later if I have a problem with a part I load the code that was specifically written for that piece of hardware. Normally I leave all hardware connected and can narrow it down fairly fast that way. In your case I would start with the I2C scanner code to see if the display shows up. Then go down the line one by one loading the code specific to that piece of hardware. This goes a long way in understanding the hardware devices. When debugging I always put "delay(5000); as the first line of my setup code. That way if I flood the serial with debug statements I can recover the Arduino, typically by uploading the blink sketch.

<#include <Wire.h>

Get rid of the first "<".

#include <Wire.h>

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.