Arduino Yún Remote Due Blink

Demonstrates how to upload remotely a sketch on DUE boards.

This is a special version of the basic Blink example. It's made for demonstrating how to enable the possibility to upload a sketch on a DUE board and a Yún shield using the remote upload feature (via WiFi or Ethernet) offered by the Arduino Software (IDE).

Preparing Arduino Due For Remote Upload

The only instruction added to the basic Blink is the

checkForRemoteSketchUpdate()
function. As suggested by the name this instruction is responsible to check if there is a new sketch to upload on the board. This is required only on the Due because you need to erase the flash before uploading a new sketch. The same action is performed automatically when you upload a sketch using any of the USB ports. To enable the remote upload feature you need to upload this sketch the first time with the USB cable and then make sure you will include the
checkForRemoteSketchUpdate()
function in all other sketches at the beginning of the setup() function. If you forget to include it, you will need to upload the sketch again via USB port; it could be a voluntary choice to stop the remote upload functionality.

Hardware Required

  • Arduino DUE board

  • Yún shield (optional, for subsequent remote upload via WiFi)

Circuit

The sketch must be uploaded using USB, then the next upload may use the Yún Shield and WiFi.

The Arduino Yún Shield.
The Arduino Yún Shield.

image developed using Fritzing. For more circuit examples, see the Fritzing project page

Code

The complete sketch is below :

1/*
2
3 Blink
4
5 Turns on an LED on for one second, then off for one second, repeatedly.
6
7 Most Arduinos have an on-board LED you can control. On the Uno and
8
9 Leonardo, it is attached to digital pin 13. If you're unsure what
10
11 pin the on-board LED is connected to on your Arduino model, check
12
13 the documentation at http://www.arduino.cc
14
15 This example code is in the public domain.
16
17 modified 8 May 2014
18
19 by Scott Fitzgerald
20
21 modified by Marco Brianza to show the remote sketch update feature on Arduino Due using Yún Shield
22
23 */
24
25#include <Bridge.h>
26
27// the setup function runs once when you press reset or power the board
28void setup() {
29
30 checkForRemoteSketchUpdate();
31
32 // initialize digital pin 13 as an output.
33
34 pinMode(13, OUTPUT);
35}
36
37// the loop function runs over and over again forever
38void loop() {
39
40 digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
41
42 delay(100); // wait for a second
43
44 digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
45
46 delay(100); // wait for a second
47}

Last revision 2016/05/25 by SM

Contribute to Arduino

Join the community and suggest improvements to this article via GitHub. Make sure to read out contribution policy before making your pull request.

Missing something?

Check out our store and get what you need to follow this tutorial.