Programming an Arduino Uno




100 Points
Learning Objectives

Inland UNO R3Arduino UNO R3

A microcontroller runs one program that is loaded into ROM.
When the power is cycled the same program will run again.
These instructions will show you how to create and upload 'sketches' or programs onto an Arduino UNO microcontroller.
Microcontrollers are becoming common-controlling automobile engines and many other complex systems.
They automate tasks to save time. Examples.
They are going to provide substantial cost savings in automobiles, like Teslas, when used effectively.
In later assignments you will continue working with and experiencing the capabilities of the Arduino UNO.

After completing this assignment you will be able to:

  1. Obtain, modify or create a sketch
  2. Upload the sketch to the UNO
  3. Test and debug the sketch
  4. Upload a screen shot to D2L.

Arduino PinoutArduino Pinout

Assignment Overview
This assignment reviews basic computer concepts that you will need in this course and throughout your career.
For this assignment, you will install the Arduino IDE on a Windows computer.
Then you will learn to work with the Arduino IDE and upload sketches.
Later assignments will show you how to modify, create and debug these sketches.

You are expected to have a working knowledge of microcontroller hardware and software.
If you do not understand how to use an item, perform a Google Search, refer to the WSU Technology Knowledge Base,  ask a teaching assistant, or ask the instructor.


Exercise 1-Arduino UNO IDE

The 'sketches' or programs that run on an Arduino Uno can be created on many devices-a laptop or Raspberry Pi.
In this exercise you will install the Arduino UNO Integrated Development Environment (IDE) onto your laptop.

  1. On your Windows computer, download and install the latest Arduino IDE by visiting this url.
  2. Make sure to connect the Arduino UNO to the USB-C dock using a USB A to B cable.
  3. When the Arduino UNO is connected to a power source via the USB A to B cable, an orange light on the Arduino UNO may begin flashing.
    This is not a problem, the UNO may be running a default sketch that was uploaded previously.
  4. -- WHEN DONE --, the Arduino IDE can be accessed by pressing Start and typing 'Arduino'
    The Arduino IDE will appear.
  5. Open the Arduino IDE
    It will display a blank sketch, with a name based on the current date.
  6. In the lower right corner you will see 'Arduino Uno on COM1'.
    From the menu choose Tools>Serial Port>/dev/ttyACM0
    If this does not show up, you may need to try again later when you compile and try to upload.
    This connects the Windows computer to the Arduino UNO via the USB cable.
  7. From the menu choose File>Examples>01.Basics>Blink
    The code that appears is well commented.
    Read the comments and the code.
    The program creates a variable to manipulate an LED, then enters an infinite loop that turns the LED on for 1 second, and off for 1 second, ad infinitum.
  8. To verify the code syntax is correct, from the menu choose Sketch>Verify / Compile.
    In the status window at the bottom you should see a 'Done compiling' message.
    If not, time to trouble-shoot.

    compiled sketch Sketch Compiled Properly


Exercise 2-Upload a Sketch

Once a sketch is verified and compiled, the next step is to transfer (upload) it to the Arduino UNO.
A microcontroller is designed to run one sketch at a time, and is simple to use.
Pi or Arduino?

  1. From the Arduino IDE choose File>Upload
    After a few seconds the status bar will display the message 'Done uploading.'
    The orange light will be blinking-on 1 second, off 1 second, until power is removed, or another sketch is uploaded.

    Blinking Light Blinking Light


    Note: the green light at the right side of the UNO indicates power is applied to the board.

Exercise 3-Test and Debug

You will next modify the sketch and save it with a new name.
Then you will upload the sketch and verify it works.

  1. In the Arduino IDE, Blink sketch, choose File>Save As... name it Blink01, saving it in the ..\sketchbook\ folder as suggested.
  2. Note that the sketch name, Blink01, appears in the Arduino IDE title bar.
  3. Modify the sketch.
    Copy the four lines of code that turn the LED on and off.
    Paste those four lines below where they currently end, being careful not to delete the brace '}' character.
    Modify the On/Off timings, noting that 1000 represents 1000 milliseconds or 1 second.
    Update the comments to reflect the timings that you chose.
    Review and then 'Verify' your code by pressing the check in the left end of the toolbar.
    Your sketch will look something like this:

    Modified Blinking Light ProgramModified Blinking Light Program

  4. When you are satisfied that your sketch works, choose File>Upload to compile and upload the new sketch to the UNO.
    Note that if you get an error message, you may need to choose Tools >Serial Port>/dev/tty/ACM0
    Or you may need to do some troubleshooting.

Exercise 4-Document Work
  1. Use the Snipping Tool to make a screen shot of the Arduino IDE.
    Make sure your name, class, assignment and date is visible in your Sketch.
  2. Open File Manager, navigate to the /home/pi directory and rename the screen shot IOTA01.png
  3. Your screen shot will look something like this:
    screen shot formatScreen Shot Format


Upload Screenshot

Upload a screen shot of your work to the appropriate D2L Assignment folder.

(70) 1. Use a web browser to login to D2L.
Upload your screenshot to the 'IOTA01' D2L Assignment Folder. Save the screen shot as "IOTA01" in your ' ' folder.

Screen Shot IOTA01


Exercise 5-Reflection

Based on your experience in this exercise and what you just learned, develop a brief statement about the value of microcontrollers as an automation tool for simple tasks in organizations.
Think about what type of problems these devices could solve, and would it be cost-effective?
Consider businesses that deploy IoT 'solutions', on the order of thousands or millions of devices-how can support of these devices be automated?

(20) 2. Reflections



Submit Assignment

When all tasks are completed press the Submit button.


(10) 3. Assignment submission