Arduino Basics for EnviroDIY

Overview

Teaching: 0 min
Exercises: 120 min
Questions
  • What are the parts of an Arduino board?

  • How do I create, upload and modify an Arduino code sketch?

Objectives
  • Learn basic Arduino skills, including uploading, running, and modifying sketches.

Prerequisites

In Part 1: Arduino and IoT for EnviroDIY, we introduce you to general skills to prepare you for using ModularSensors for environmental monitoring. We do this largely by leveraging interactive online tutorials that are not directly related to environmental monitoring. We have intentionally chosen this approach to acquaint users to the broader world of Arduino-framework micro-controllers.

Actively Participate

We strongly recommend that you actively participate in the activities in each tutorial because you will need to be comfortable with both physical connectivity to an Arduino and code edits prior to using EnviroDIY Modular Sensors Library.

Episode 1: Arduino Basics for EnviroDIY

The Arduino sketches in this episode are simple and require a minimal number of libraries to run. We include a short note for each tutorial to help users know how elements of the tutorial will apply to their use of EnviroDIY Modular Sensors for environmental monitoring and to modify the sketch for use with the EnviroDIY Mayfly.

Ladyada’s Learn Arduino by Limor Fried, lessons 0-2

The Serial Monitor

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 8 as an output.
  pinMode(8, OUTPUT);

  // initialize a serial port
  Serial.begin(9600);
  // print a header line to the serial port
  Serial.println("This is the output of the Blink Arduino sketch.");
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(8, HIGH);   // turn the LED on (HIGH is the voltage level)
  Serial.println("The LED is on."); // print a message to the serial port
  delay(1000);              // wait for a second

  digitalWrite(8, LOW);    // turn the LED off by making the voltage LOW
  Serial.println("The LED is off.");
  delay(1000);              // wait for a second
}

Adafruit Learn Arduino by Simon Monk, lessons 0 and 2
NOTE: Please read through the two lessons to learn how breadboards and resistors work. To participate fully in this tutorial, you will need additional parts, but this is optional. The additional parts include a breadboard, resistors, LED lights, and jumper wires, such as those included with either an Arduino Uno Starter Kit, an Adafruit Metro 328 Starter Pack, or a Sparkfun RedBoard Tinker Kit.

Complement your Learning (Optional)

Key Points

  • Arduino-framework microcontroller boards are designed to be programed to interact with the real world.

  • An Arduino code sketch has comments, statements and functions organized into two main blocks, the setup() function block and the loop() function block.

  • An Arduino has different pins, which are designated for analog or digital inputs and outputs.

  • The Serial Monitor allows you to view outputs that you send from your Arduino.