How to automate uploading a series of sketches

A brief description of my project concept:
I am using a dynamic NFC tag (RF430CL330H) with an Arduino Uno connected via USB to OS X. I have 5 different sketches that each have a different NDEF message that I want to upload to the Arduino every 45 seconds automatically possibly looping indefinitely.

My question is what are the best ways to accomplish this?

Thanks for any help.

Turn on verbose output for upload in the Arduino IDE and capture the avrdude command line used to upload each sketch.
Then put them (with suitable delays) in a script.
Any reason you cannot combine all five sketches into one?

doboi718:
that I want to upload to the Arduino every 45 seconds automatically possibly looping indefinitely.

Do you really mean that you want to upload a different program to an Arduino every 45 seconds?

Won't that wear out the Flash memory very quickly?

As @Riva said, combine all 5 programs into one and save yourself a ton of trouble.

...R

Thanks @Riva and @Robin2 for the feed back. The NFC tag can only handle one NDEF message at a time so combining them wouldn't achieve the desired effect. For instance, if you are watching a product slide show on a display in a store I want the NFC tag to update to take the user to see that particular product site that is currently showing. The next product in the slide show could update the tag to link to an app.

However, I never even thought about wearing out the Flash memory. That is indeed a concern.

I will try to capture the avrdude command line and utilize that for now. Thanks again all.

Surely, all you need to do is have one sketch which has an array containing all 5 codes,

Then every 45 secs the sketch just sets a different code into the NFC tag.

No need to upload more than once

You are clearly confusing the concepts of uploading of sketches, with communicating data to that Arduino.

What you have in mind is a very common application of the Arduino - a "bridge" between a PC and a device using a particular protocol; in this case an NFC device but in others, temperature sensors, encoders, LCD or LED displays and such, where it is inconvenient to have the PC handle the interface to that device.

So what you actually want to do, is to write a sketch which receives data strings from your Mac using Serial.read() and writes it to your NFC device. That is quite straightforward, though how you do it will depend on the size of the strings and the protocol required as the RAM of the UNO is quite modest.

It would probably help if the OP could tell us why they were doing this in the first place.

It seems odd to keep changing the code of the NFC device e.g. Every 45 seconds, but yet only have 5 different codes.

I could understand it more if they were changing the code once a minute and that there were limitless number of codes, e.g. So that the code would be a date time stamp updated once a minute

See Demonstration code for several things at the same time - Project Guidance - Arduino Forum

doboi718:
Thanks @Riva and @Robin2 for the feed back. The NFC tag can only handle one NDEF message at a time so combining them wouldn't achieve the desired effect.

We are NOT suggesting that you combine the tags. All we are suggesting is that a single Arduino program can upload several different tags, one at a time. There is no need to upload different programs.

You could probably store several tags in the Arduino and send a different one every time at 45 sec intervals. From time to time you could upload different tags when the product line changes

Or you could have the Arduino linked to your PC with the USB cable and then the PC would send a new tag to the Arduino (once every 45 secs) and the Arduino would then upload it to the tag.

You would probably also need to use the Arduino to control the slideshow to eliminate the risk that the slides and the tags get out of sync.

...R

rogerClark:
It would probably help if the OP could tell us why they were doing this in the first place.

It always would as that is the most important piece of information, but it can be so difficult to force that piece of information out of OPs, presumably because the project is top secret and their code represents critically valuable and irreproducible intellectual property.

The other factor is of course, that we are assumed to be psychic. :astonished: