In this assignment, you’ll learn the basics of Arduino hardware and programming.


Learning objectives

The goal of this assignment is to get started being comfortable with simple electronics. We’ll hook up some parts to our microcontroller and get an idea of how it all works.

Deliverables

See the notes below for details on each deliverable, including how to turn them in, as well as for grading criteria.

  1. A working circuit that takes input and creates output according to the below instructions
  2. A video, with your full name written on a piece of paper visible in the beginning of the video, of your working circuit
  3. A top-down photo of your working circuit with the parts clearly labeled
  4. The code you used in your circuit
  5. A textual description (in a Slack Post) of your circuit and how it works, as well as a list of resources you used in formulating your solution

Advice/Warning

For this project, be extra careful about what you use from internet resources. Pleae ensure that you thoroughly understand what it is that you are doing. We’ll be continuing to use our Photons throughout the semester, so getting familiar and understanding the principles is a must! It can be tempting to copy some useful code without completly understanding how it works, but this will cause you problems later on. As usual, the warning on the syllabus regarding academic integrity, cheating, and attribution applies.

What to do

Your overall goal is to use the parts in your Maker Kit to construct a circuit and a simple Photon program that take some input from the world and produces some output.

Setting up the Photon

The Particle Photon is an amazing little board with incredible wireless capabilities that we’ll be using throughout the course. To start with, though, we’re going to disable that WiFi functionality and learn some basics of microcontrollers.

First, visit build.particle.io and create an account. We won’t use this page again for a while, but you’ll need your password.

Next, we’ll need to be able to talk to the Photon through USB ports.

If you use Windows, follow the instructions in Connecting your Device over USB.

If you use MacOS, life will be a lot easier if you install Homebrew. Go here and follow the instructions to install. Next, at the command prompt, do brew install npm dfu-util.

Finally, for both Windows and Mac, do npm install -g particle-cli and then particle login, logging in with the username/password you created above.

Compiling and flashing code

Here’s a quick intro to getting code onto your Photon; you’ll learn more about this in detail with the readings below.

On the command line, type particle project create. Give your project a name and note where it got saved. Now, open up that directory, look inside src, and, using your favorite text editor1, open up the .ino file. Replace the contents of that file with the following:

SYSTEM_MODE(MANUAL);

void setup()
{
  pinMode(D7, OUTPUT);
}

void loop()
{
  digitalWrite(D7, HIGH);
  delay(500);
  digitalWrite(D7, LOW);
  delay(500);
}

Now, back in the console, change to the directory that your project folder is located in. Type particle compile photon <your_project_name_here>. It will do some stuff, then will output a filename something like photon_firmware_1505237346558.bin.

Finally, let’s flash this to your Photon. Put your Photon into DFU Mode and then type particle flash --usb photon_firmware_<number>.bin. If all goes well, your Photon should restart and start flashing a blue light.

Learning

Read the following Photon resources:

Read the following circuitry resources:

Check the following out for reference purposes:

Assignment

Your Maker Kit has several components that can serve as input devices: photoresistors, a potentiometer, temperature sensors, buttons, switches, and a PIR sensor. It also has a number of output devices: a piezo buzzer, LEDs, an RGB LED, a vibration motor, a servo, and an OLED display.

Your goal for this assignment is to use two or more of the input devices to get some properties about the world into your Photon, process them somehow, and then display those properties with the output devices.

Your basic assignment is to use the light sensor and four LEDs to display the light level from 0–100%, and use the potentiometer to change the light threshold at which the vibration motor will vibrate.

Once you have that going, you can start switching out components if you like, or changing how the system’s code operates.

Turning in

You’ll show your final output object in class on the due date. You should turn in your photographs and files via direct message to me in Slack by 1:59 pm on the due date.

Your video file should clearly illustrate your circuit working. Get a friend to hold your phone or put it on a tripod so you can use both hands to demonstrate. You should write your full name on a piece of paper and have that at least at the beginning of the video.

Turn in a top-down photo of your circuit with the parts labeled.

Turn in your code that you used for your project.

Finally, compose a Slack Post with details about how your circuit works. Also include a list of resources you used: major places you found help, examples, and so forth (for example, the AdaFruit tutorials linked above include many helpful items relevant to this project).

Please name your files arduino_basics-<yourname>.<ext>, replacing <yourname> with your name and <ext> with your file extension. For example, arduino_basics-dan.jpg. If you have more than one file of a type, please add a number, as in arduino_basics-dan01.jpg.

Grading

See the syllabus for how much this assignment contributes to your final grade. The grade for this assignment is determined as follows:

  • Circuit works as instructed (60%)
  • Code compiles without errors (20%)
  • Video is clear and includes your name (5%)
  • Photo is clear and labeled (5%)
  • Documentation is clear and describes circuit (10%)

Bonus points

You will get 1 extra point on your final grade if you do all of the above—including documentation—and then change your circuit significantly to include at least one different input, one different output, and a different functionality.

Footnotes


  1. If you don’t have one, some people like Sublime Text. Be careful using things like Windows Notepad or Mac OS TextEdit because they may not treat plain text correctly or might add odd extensions to the filename.