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
}
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:
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.)
Download Flash3.zip and unzip it into your sketchbook/libraries directory.
Exit Arduino, start it up again and open your sketch.
Import the Flash library.
Change the @-stuff to
.
.
.
Serial.println(" "); //print APAS to serial
Serial << F(" @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