Ashim
Ashim

Reputation: 1

How do I make an Arduino run a specific script every time it boots?

I currently have an Arduino Uno, (version 1.3) with a pn532 NFC shield manufactured by Adafruit.

I was wondering if there was a way to make it so that the Arduino runs a particular code I have written every time it boots? Does this involve playing around with the bootloader?

I have no prior experience with Arduinos, and my coding knowledge is fairly basic (have only really coded in Python), so suggestions that start from the absolute ground level would be highly appreciated! :)

Upvotes: 0

Views: 1574

Answers (1)

datafiddler
datafiddler

Reputation: 1835

An Arduino Uno is a microcontroller, which has all of it's code permanently in something you'd call the BIOS, if it were a computer. This code is executed from the start address when power is applied or the reset button is released. There's no operating system to be loaded from disk at boot time.

Your own code consists of two entry points:

  • setup() is called once when inital variable values are initialized. Here you put things to run once after start.
  • loop() is then called forever and ever, to perform your everrunning stuff.

If you have the Arduino connected to the PC software, where you develop your code or find examples in the internet, there's the additional possibility to trigger a reset and exchange the "fixed" content of arduino's memory before a new start. (This is when that bootloader comes into play) Usually there's no difference between the first start after a fresh load and following ones. (If this is what you call "boot") If you think you need such a differentiation, you're probably thinking in the wrong direction ;)

Upvotes: 1

Related Questions