Problem when using lcd and Serial.println

The other day I built the "APAS"...
All
Purpose
Arduino
System

and I want it to print APAS (with @ symbols) into the serial monitor when I plug it into my computer.
When it comes on it displays the temp on an lcd screen, but when I tell it to print APAS to serial in the same code it doesn't do anything but flash the led on pin 13 and then waits about 2 seconds then flashes again. The screen doesn't even come on, almost like it's stuck or something.

Here's the code:

It doesn't turn out right in the preview so if you open a new arduino window then maximize it and paste it in it looks right.

float vcc = 5.00; // only used for display purposes, if used
// set to the measured Vcc.
float pad = 1996; // balance/pad resistor value, set this to
// the measured resistance of your pad resistor
float thermr = 10000; // thermistor nominal resistance
float Thermistor(int RawADC) {
long Resistance;
float Temp; // Dual-Purpose variable to save space.
Resistance=((1024 * pad / RawADC) - pad);
Temp = log(Resistance); // Saving the Log(resistance) so not to calculate it 4 times later
Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
Temp = Temp - 273.15; // Convert Kelvin to Celsius
// Uncomment this line for the function to return Fahrenheit instead.
//temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert to Fahrenheit
return Temp; // Return the Temperature
}

#include <math.h>
#define ThermistorPIN 1
#include <LiquidCrystal.h>
LiquidCrystal lcd(7,8,9,10,11,12);

int var;

void setup(){
pinMode(6, OUTPUT); //output to transistor to control backlight of lcd
pinMode(5, OUTPUT); //out to buzzer
Serial.begin(9600); //start serial
lcd.begin(16, 2);
delay(100);
digitalWrite(6,HIGH); //turn on the backlight
lcd.print("APAS starting"); //print APAS to lcd
Serial.println(" "); //print APAS to serial
Serial.println(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@ ");
Serial.println(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@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@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@ ");
while(var < 1){
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { //Make the buzzer get louder
analogWrite(5, fadeValue);
delay(30);
}
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { //then softer
analogWrite(5, fadeValue);
delay(30);
}
var++;
}
delay(1000); //wait a second
}

void loop(){
float temp;
temp=Thermistor(analogRead(ThermistorPIN));
temp = (temp * 9.0)/ 5.0 + 32.0; //convert to deg. F
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(temp,1); //print the temp
lcd.print(" F");
lcd.setCursor(0, 1);
lcd.print(millis() / 1000); //print seconds
delay(1000); //wait a second before refreshing
}

Are you actually opening the serial monitor?

Your "@ lines" will take up a ton of RAM. (All strings are copied to RAM before being used.) Try using less of them and/or using for() loops.

  1. Yes, I am opening up the serial monitor.

  2. I already cut them in half because even if all I did was tell it to print the @ signs it wouldn't.

And how would I use for() loops?

Something like: (note: untested)

void PrintAts ( int numAts )
{
     for ( int i=0; i<numAts; i++ ) serial.print ( '@' );
}

mrnobody669:

  1. Yes, I am opening up the serial monitor.

  2. I already cut them in half because even if all I did was tell it to print the @ signs it wouldn't.

And how would I use for() loops?

Get rid of them all together! With only one line of Serial.println("APAS"); will it work?

mrnobody669:
2. I already cut them in half because even if all I did was tell it to print the @ signs it wouldn't.

The @ symbols as shown consume 2,509 bytes. The Arduino is based on the ATmega328 which has 2,048 bytes of RAM. As I said before, strings are copied from program-memory to RAM which is being consumed by your @-statements. (My original suggestion to use for loops was before I realized you were trying to print something.)

Even if you cut out 1/2 of the "@-lines", you are still using 1254 bytes of RAM on just that part of the sketch.

The behavior you are seeing is the ATmega328 when it runs out of RAM. Take out the "@-lines" all together and see if it the sketch starts working as expected.

After doing that and getting the rest of it to work, then you can put the @-stuff back in as follows:

  1. Read about the Flash library here: Flash | Arduiniana It makes it easy put constant strings into program memory, where there is more room. (I am assuming that the program itself doesn't occupy more than about 28 K bytes in an ATmega328P.)

  2. Download Flash3.zip and unzip it into your sketchbook/libraries directory.

  3. Exit Arduino, start it up again and open your sketch.

  4. Import the Flash library.

  5. Change the @-stuff to

.
.
.
    Serial.println("   ");       //print APAS to serial
    Serial << F("  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@     @@@@@@@@@@@@@@@@@@@@@@@@@\r\n");
    Serial << F(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n");
    Serial << F(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n");
    Serial << F(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n");
    Serial << F(" @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@\r\n");        
    Serial << F(" @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@\r\n");
    Serial << F(" @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@\r\n");
    Serial << F(" @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@\r\n");
    Serial << F(" @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n");
    Serial << F(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@@\r\n");
    Serial << F(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@     @@@@@@@@@@@@@@@@@@@@@@@@@\r\n");
    Serial << F(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@      @@@@@@@@@@@@@@@@@@@@@@@@\r\n");
    Serial << F(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@               @@@@@@@@@@@@@@@\r\n");
    Serial << F(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@      @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@               @@@@@@@@@@@@@@@\r\n");
    Serial << F(" @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@                     @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n");
    Serial << F(" @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@                     @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n");
    Serial << F(" @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@                     @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n");
    Serial << F(" @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@                     @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@\r\n");
  while(var < 1){
.
.
.

Output:


  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@     @@@@@@@@@@@@@@@@@@@@@@@@@
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@
 @@@@@@@@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@@@@@@@@@@@@@@@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@               @@@@@@@@@@@@@@@
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@      @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@               @@@@@@@@@@@@@@@
 @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@                     @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@
 @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@                     @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@
 @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@                     @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@
 @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@                     @@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@

Regards,

Dave