Create a Test Sketch
Generate Sketch Scaffolding
Create a new test sketch or copy the testSketch.ino file from the following GitHub repository: github.com/chriscummings/remote-arduino-deployment
Test Sketch Code
Paste the following into the generate sketch folder.
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop()
{
Serial.println("Hello");
digitalWrite(13, HIGH); // LED on
delay(500);
digitalWrite(13, LOW); // LED off
delay(500);
}
Code Explained
In an Arduino sketch, before any other code executes, the setup() function is called once.
In this example the setup() function:
- Sets the baud rate of the serial connection to
9600. Documenation forSerial.begin(). - Configures pin 13 to be an output. Documentation for pinMode().
After the setup() function runs, the loop() function is called and continues to repeat until the program is explicitly exited or crashes.
In this example the loop() function repeats the following actions:
- Prints Hello to the serial connection. Documentation for
Serial.println() - Turns pin 13 "on" applying a 3.3V current. Documentation for
digitalWrite() - Waits 500 milliseconds. Documentation for
delay() - Turns pin 13 "off" removing current.
- Waits 500 milliseconds.
What's special about pin 13?
There is an onboard LED connected to it so that whenever 13 is "on" or "high" that LED lights up. It is commonly used for testing purposes because of this. Thus, every run of the loop() function causes this LED to blink on and off.