FREE USA SHIPPING ON ORDERS OVER $100 On Dr.Duino.com

What the heck is my Arduino doing?

Recently I was working on a program where I needed to write a ton of information to the serial monitor.

Well... all of a sudden some super weird things started happening. If statements wouldn't execute sometimes, other times, the program would appear to just stall.

After ripping out what little of my locks of love which I have left (aka hair on my head), I turned on verbose mode in the Arduino compiler.

PS- to turn on verbose mode, aka tell me all the gory details about what the compiler is doing, go to File\Preferences then click on verbose mode.

Well, well, well... what did we see there?

I WAS RUNNING OUT OF MEMORY!

But how could it be, my program really wasn't doing anything aside from a bunch of printf's.

After some digging, I realized that whenever you call Serial.print it's storing that in SRAM of which we have precious little in our beloved Arduino Uno which uses the Atmega 328p chip.

UGH.. what now?

Well after consulting the great google, I realized that there is a workaround.

Instead of using the serial monitor like this

Serial.println("Hi, I used up all of Dr.Duino's memory");

Just change it to

Serial.println(F("Hi, I used up all of Dr.Duino's memory"));

What does that lowly F do? Great question.

It tells the compiler to use your flash memory which you have tons of instead of your RAM.

and TADAAAAA.... my program compiles again and isn't acting all squirrely.

Well.. thought I'd share that nugget of love with you as I only have a few sprigs of hair left and that was driving me nuts.

If you are looking to get started with Arduino OR are a seasoned pro and need a reliable and easy to use development platform, I'd like to invite you to come check out our entire line of Arduino Uno and Nano based shields.

If you have some electronics experience the Dr.Duino Explorer is the choice for you. Just click the photo below to find out more about.

If you're new to Arduino and electronics, then the Dr.Duino Pioneer version is the best choice. Click the photo below to learn more.

 

Which one will you choose, click here to learn more about the Explorer or here to learn about the Pioneer!

 Have a look at our other popular blog posts too!

What can you do with Arduino?

What's better, Arduino or Raspberry Pi?

So what is Arduino Exactly?