During the last few studios we’ve built a basic HTML/CSS+JavaScript UI for a desk lamp and even created a JavaScript object that allows us to model the behavior of the lamp. Now it’s time to start building the embedded system (the lamp itself).
The objectives of today’s Studio are:
As usual, today’s studio will require groups of four.
Each role has some specific responsibilities for the work, but everyone is expected to contribute to discussions and exploration of concepts.
Please take your role seriously. When you get your role, review the responsibilities and make sure you follow through on them.
Groups of three will be allowed if:
In groups of three the Manager must also take on the responsibilities of the Spokesperson.
process/Roles.md
)README.md
process/SessionNotes.md
):
process/Debrief.md
As in the previous studios, all group members will need to be in a GitHub group (and repository)
The link for this studio is: https://classroom.github.com/g/MQAaSAac
Today both the Recorder and Technician will want to be able to work with the repository (i.e., it should be on at least two computers). The Technician will be working with the Photon (C++).
The Recorder should update process/Roles.md
to record everyone’s roles for this studio (use full names). In addition, the Recorder should take notes about the interaction of the overall session.
Manager: you should discuss the safety guidelines in process/SafetyAgreement.md
. It’s your job to ensure everyone understands and agrees to the safety precautions for the course. Feel free to ask TAs/Instructors any questions regarding safety or problems that arise during your discussion.
Ensure that each person types their name into the given table themselves (using the Recorder’s computer).
The Technician should read the questions in process/Debrief.md
to the group and the group should come to a consensus for each.
Although the Photons will be connected to your computer, they are not programmed directly from your computer. We will be writing code that will be compiled via Particle’s could service, which then also deploys it to your Photon via Wi-Fi. There are a few implications of this approach:
Today we will go through the process of configuring Photons to work with the campus network (wustl-2.0), which also requires associating them with an account. Consequently, the owner of the Photons should be logged into their accounts. It would be best to use the Technicians Photons today (If the Technician doesn’t have a Photon, but will, it would be possible to register devices to the Technician today and trade as needed). Each Photon can be configured to work with five (5) different Wi-Fi networks, but they can only be associated with a single user account.
SETUP
button down for 3s (after it is plugged into power via the USB cable)Particle
menu in Particle Dev and select Log in to Particle Cloud...
then enter the e-mail and password used for their Particle.io account.Particle
menu and Complete README.md
Q1.Serial Monitor
window, select the port corresponding to your Photon, and hit the Connect
button.
Serial Monitor
in the Particle Desktop app, but it does not work reliably on all platforms. You can also use the Arduino IDE’s Serial Monitor
window for all these operations if needed.Serial Monitor
, 3) Note the list, 4) Reconnect the USB cable to the Photon, 5) Put it back in Listening Mode, 6) Hit the refresh button again and identify and select the newly listed port. m
in the Enter a string
field.i
and hit enter. This will reveal your Photon’s unique ID number. You will need it in a minute, so type it someplace where you will be able to copy/paste. (Spokesperson: Verify that it’s copied correctly). It should look something like: wwustl-2.0
NOTE THE TWO w
s. The first w
is the command to configure the Wi-Fi SSID. The remainder of the line (the wustl-2.0
) is the SSID of the WUSTL network. If successful, you should see:0
(and enter) to indicate no security is needed to connect to the network (the form you filled out earlier will allow the specific device to connect without additional authorization).Particle
menu and select Claim Device
. Paste in the long ID number from step 9.Rename...
from the Particle
menu.Select Device
option from the Particle
menu. If you have many devices (multiple Photons claimed by one account), this allows you to select the one you will currently be programming. It should look something like this if you have more than one device:Complete README.md
Q2
If you need to connect your Photon to another network (ex: for off-campus work), there are a variety of ways to configure it. See Particle’s Connect Your Photon
Some students have reported connectivity issues. Although we don’t have conclusive proof, it appears that using an external antenna may help overcome some problems. The Maker Kit comes with one external antenna:
In order to use it you have to:
STARTUP(WiFi.selectAntenna(ANT_AUTO)); // continually switches at high speed between antennas
void setup() {
...
}
The “Hello, World!” is an inside joke in computer science. Some of the earliest resources for learning to program always started with an example that printed “Hello, World!”. Often when a programmer learns a new language one of their first example programs is a variation on “Hello, World!”. (The Hello World Collection has a vast list of examples of “Hello, World!”)
When working with microcontrollers the equivalent program is “Blinky”. That is, people almost always start by making an LED blink. We won’t break with that tradition here.
The Photon just uses the Arduino sketch conventions that you should have already seen in CSE132 (i.e., a setup()
function, a loop()
function, delay()
, pinMode()
, etc.)
The Photon has an LED on output pin D7
. Write a sketch that makes it blink with a frequency of 0.33 Hz (on for 2s and off for 1s). (Delay timing is fine)
blinky
and verify that it will be within your studio05
folder (and then be pushed to GitHub).Pulse Width Modulation can be used to control the brightness of LEDs. Review SparkFun’s Pulse Width Modulation Tutorial.
Complete README.md
Q3
The analogWrite()
performs PWM, but it only works on certain pins. Review the analogWrite()
documentation for the Photon and identify which pins it works on.
Connect an LED and resistor to an appropriate pin. Create a new sketch called pulsing
and try to recreate the pulsing you see with on the Photon’s central LED. The Particle Dev Desktop doesn’t support projects nested in a folder well, so you may need to:
studio05
) and select Remove Project Folder
. This doesn’t remove it from the disk, but it does remove it from the IDE.Start a New Project
button and create the new project within the GitHub repo directory (i.e., in studio05
)Particle
menu, choose Select Device...
, and pick your Photon.Create a new project/sketch called RGBTest
in your studio folder.
The color of the RGB lamp can be controlled by controlling the colors of each LED using PWM. Review Particle’s Documentation on the RGB LED in the Maker Kit (as well as the datasheet linked from Particle).
Wire one LED of the three colors to the Photon. Everyone should review the wiring.
Try to replicate the on/off cycle from before with just one of the three colors (I.e., on for 2s, off for 1s).
Complete README.md
Q4
Finally, complete wiring of the other two LEDs. Update the sketch so that it repeatedly cycles through a variety of colors. Try producing a reasonable set of all colors possible within a reasonable time.
Commit your work to GitHub:
Complete any unfinished work and commit it to your repo by 11:59pm Sunday, Sept. . 30th.