Domain-specific Skill Building
Assignment structure for each week (we do the same pattern twice):
- Before Wednesday select a topic from the list below that you want to pursue. Plan to spend about 10 hours total on all of this learning and documentation (including ~3 hours in class).
- Note that if you want to do a “Choose your own adventure” assignment, you’ll need to submit your proposed “Technical training sequence” and “Creative/exploratory output” for Zach’s approval before beginning work on it.
- Submit a proposal for your selected topic via the “Proposal” assignment on Canvas. This is due at the start of class on Wednesday.
- Begin by following the specified “Technical training sequence” for your selected topic. Document your process and endpoint.
- Once you’ve completed the “Technical training sequence,” submit video of that completed thing working to the “Technical training sequence” Canvas assignment.
- Begin work on your “Creative/exploratory output,” taking process images as you proceed. You will demo your final work on Monday in the latter part of class, whether it’s working or not!
- Complete documentation through our class Google Site page by the start of Wednesday’s class, and submit that URL to the Canvas “Documentation” assignment.
Topic quick links
- Topic: Stepper motors
- Topic: Novel computer input device (keyboard/mouse)
- Topic: Sound output
- Topic: LED strip
- Topic: Linear actuator
- Topic: Pixel display
- Topic: Accelerometer
- Topic: DC motor
- Topic: Thermal receipt printer
- Topic: Serial communication between two Arduinos
- Topic: Radio communication between two Arduinos
- Topic: Choose your own adventure
Topic: Stepper motors
Technical training sequence
- Read entire “stepper motors” tutorial page on course site
- Run sample code from there, or just straight off of AccelStepper library
- Either use A4988 driver with NEMA 17 or 23 or another motor, or ULN2803 driver with 28BYJ-48
- If you are using the A4988 driver, adjust the current limiting potentiometer to match your motor’s rating; a good tutorial on how to do that is here: <https://www.circuitist.com/how-to-set-driver-current-a4988-drv8825-tmc2208-tmc2209/>
- Either use A4988 driver with NEMA 17 or 23 or another motor, or ULN2803 driver with 28BYJ-48
- Adjust sample code to confirm number of steps per revolution for your motor (this varies)
- Deliverable: affix tape flag to motor output shaft and submit video of this spinning action: once clockwise, twice counterclockwise, then once more clockwise to return to start position. Can be with or without acceleration.
Creative/exploratory output ideas
- Read a continuous input and drive a linear motion to a corresponding position
- Ok to simply dangle a string with a weight off of a surface
- Better to drive a belt if possible
- Drive a preprogrammed series of movements that do something specific and intentional
- Example: raise and lower a pen/marker while a paper is drawn laterally across that pen/marker’s path so as to form a particular figure/pattern
- Combine multiple motors to make a more complex driver
- Example: Polargraph <https://www.instructables.com/Polargraph-Drawing-Machine/>
- Build a live-updating data-visualization machine of some sort
Topic: Novel computer input device (keyboard/mouse)
Technical training sequence
- For this topic, use an Arduino Pro Micro since that board can imitate a USB “human input device” (HID) mouse and/or keyboard to the computer. (An Uno, no matter what library is running on it, can’t do this.)
- Important note: be sure to include a physical failsafe switch that can turn off all HID output. Without that, you can get stuck with a device that only mashes on keys or messes with the mouse as soon as it’s plugged in to your computer. The recommended practice is to pick an unused digital pin, put it into
INPUT_PULLUP
mode, and only send keyboard/mouse events to the computer if that pin isLOW
(e.g. if a wire is running from that pin toground
). Here is a small simple mockup of this software move:
/*
Basic "keyboard" code demonstrating use of a wire connection to prevent
sending keystrokes when you don't want it to
Wiring: connect pin 3 to ground with a jumper; Arduino will only send
keystrokes to the connected computer while that connection is in place
*/
#include "Keyboard.h"
const int KEYBOARD_BAILOUT_PIN = 3;
void setup() {
pinMode(KEYBOARD_BAILOUT_PIN, INPUT_PULLUP);
Keyboard.begin();
}
void loop() {
// input pullup mode, so bailoutState will be HIGH if pin 3 is
// disconnected from ground
int bailoutState = digitalRead(KEYBOARD_BAILOUT_PIN);
if (bailoutState == LOW){ // pin 3 is connected to ground
Keyboard.println("I'm going to keep typing this once per second unless you disconnect the jumper going to pin 3.");
delay(1000);
}
}
- Here is the reference page for the “Keyboard” library: <https://docs.arduino.cc/language-reference/en/functions/usb/Keyboard/>
- Here is an example to try, “Keyboard Message”: <https://docs.arduino.cc/built-in-examples/usb/KeyboardMessage/>
- Deliverable: modify “Keyboard Message” so it includes the bailout wiring described above, and show that functioning.
Creative/exploratory output ideas
- A series of breadboarded buttons each of which types out a sequence of characters (e.g. a big button that writes the first paragraph of the Declaration of Independence; some buttons with handwritten labels that each type a foreign-language character or other glyph; a potentiometer that sets the number of characters to write, and then buttons to choose which character will be written that number of times)
- A square-drawing machine that clicks and holds the mouse and drags over, down, left, and back up then releases. Can therefore draw this in any application that supports click-drag drawing.
- Data logger: reads a sensor and types the observed value, followed by a line break, every interval of time.
Topic: Sound output
Technical training sequence
- Either use a DFPlayer Mini (manufacturer’s wiki page: https://wiki.dfrobot.com/DFPlayer_Mini_SKU_DFR0299)
- Or use an Adafruit Music Maker (Adafruit product page: https://www.adafruit.com/product/1788; Adafruit tutorial page: https://learn.adafruit.com/adafruit-music-maker-shield-vs1053-mp3-wav-wave-ogg-vorbis-player)
- In either case, you will also need a micro SD card to store the music/sound file, and a USB adapter to connect that card to your computer to load the files onto it
- Use any speaker from the lab to generate sound
- Caveat: the order in which you load
mp3
files onto your SD card can matter, frustratingly. Be careful about this and prepare to have to format your card and reload the files repeatedly! - Deliverable: video of Arduino-attached button press triggering an audible sound playing
Creative/exploratory output ideas
- At least three buttons, and when any button is pressed, it triggers a specific sound/song to play back. Volume is adjusted by a potentiometer.
- Your computer sends Serial strings to the Arduino. Sending a “1” starts playback of
0001.mp3
, likewise “2” plays0002.mp3
and “3” plays0003.mp3
. Sending a “p” will pause or unpause playback.
Topic: LED strip
Technical training sequence
- Read through “LED strip” tutorial on course website
- Use any LED string of at least 8 LEDs to get sample code running (linear, flexible tape, ring, etc.)
- This will usually require soldering legs onto that component
- Deliverable: adjust code so that not all LEDs are the same color at the same time, show repeating playback sequence.
Creative/exploratory output ideas
- Use an LED string as a live-varying display of a sensor value (e.g. potentiometer values going from 0–1023 lights 0 through 16 of your LEDs). Should have minimal delay.
- Build a low-resolution display by making a two-dimensional matrix of LED strips. Display different static or moving images.
- Output multiple data streams to one string. For instance, a string of 16 LEDs has one bar graph going from left to right, and another from right to left; the left bar graph is red, the right bar is blue, and if LEDs are double-selected because the bars overlap, they are yellow.
Topic: Linear actuator
This topic isn’t fleshed out yet. If you want to pursue this topic, treat it as a “Choose your own adventure” topic.
Topic: Pixel display
Technical training sequence
- Using a 64 x 128 I²C display, follow the Adafruit monochrome LED display tutorial: https://learn.adafruit.com/monochrome-oled-breakouts (note that I’m currently unsure if our lab parts are SSD 1306 or 1305 so watch out for that distinction)
- Deliverable: modify the sample code so that the device displays your text at least three different sizes, and also shows a custom original bitmap image of your choosing. (No need to show text and the bitmap simultaneously.)
Creative/exploratory output ideas
- Read your computer keystrokes via serial communication and use the small screen as a tiny text output display
- Show different pictures on the screen based on a sensor value (e.g. a thermistor input leads to a picture of an iceberg or a fire)
Topic: Accelerometer
Technical training sequence
- Wire up ADXL335 and run super-simple sample code on the course “ADXL335 accelerometer” page
- Use Serial Plotter to show x, y, z axes as you continuously tumble the accelerometer through all of its axes. You should see the three graph lines going up and down sequentially.
- Deliverable: write a sketch that reads the x, y, and z data to decide whether the accelerometer is “right side up” or “upside down.” Print the appropriate text to the serial monitor every 500 milliseconds.
Creative/exploratory output ideas
- Build a pedometer that sends the text like
step #83
(substituting the correct number) to the serial monitor every time a step is sensed. Use a potentiometer to adjust sensitivity. - Build a vibration sensor that reports a 0 to 10 “vibration level” score.
- Build a device to score a driver’s starts, stops, and swerves from 0 (stationary) to 10 (terrible driver, very jerky).
Topic: DC motor
This topic isn’t fleshed out yet. If you want to pursue this topic, treat it as a “Choose your own adventure” topic.
Topic: Thermal receipt printer
Technical training sequence
- Wire up the thermal printer (ioRef part #1452, located in the Special Parts Cabinet) to your Arduino, and use a 9V power supply for the thermal printer’s VCC pin. (This should be an actual power supply, not a 9V battery, as the thermal printer will chew through a battery pretty quickly.)
- Use the “Adafruit Thermal Printer” library: https://learn.adafruit.com/mini-thermal-receipt-printer/microcontroller
- Deliverable: wire up two buttons to your Arduino. Make it so that when one button is pressed, the printer prints out a haiku about how much it enjoys being a thermal printer, and when the other button is pressed, the printer prints a small picture of a house.
Creative/exploratory output ideas
- Printer as data log: have the printer write a line once or twice per second showing the current
millis()
value and ananalogRead
value from some input sensor (such as a potentiometer, etc.). Add a switch to turn the printing/logging process on and off. (Note that the switch is not a power switch for the whole system; it just turns the print function on and off so you don’t waste a bunch of paper.) - Interactive story: the printer writes out a scenario and gives you a choice, which you select using one of two buttons. For instance, the start can be:
You enter a cave. There is a torch on the wall. Do you A pick it up, or B keep walking?
After answering the question, the story branches from that point, with more questions.
- Use the printer to print out a message for your roommate, which is triggered by a motion detector or break-beam sensor.
Topic: Serial communication between two Arduinos
Technical training sequence
- Get two Arduino Unos from the lab. Put them on your table side by side, and label one “transmit” and one “receive” by writing on the table or labeling them with tape. This will help you keep track of their roles!
- Connect the TX line (pin 1) from the transmitter to the RX line (pin 0) of the receiver. Connect the grounds together. Connect the 5V lines together so that whichever is connected to your computer can power the other one.
- On the transmitter, run simple code to count up sequentially:
/*
* Simple serial transmit counter
*/
int counter = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println(counter);
delay(1000);
counter++;
}
- On the receiver, run simple code to indicate if it’s receiving an even or odd number:
/*
Simple serial reciever
Turns on built-in LED if latest received
value is even, otherwise turns off the LED.
*/
const int LEDPIN = 13;
void setup() {
Serial.begin(9600);
pinMode(LEDPIN, OUTPUT);
}
void loop() {
// when there is serial data waiting to be read
while (Serial.available()) {
int inVal = Serial.parseInt(); // read the value as an integer
if (inVal % 2 == 0) { // if even value
digitalWrite(LEDPIN, HIGH);
} else {
digitalWrite(LEDPIN, LOW);
}
}
}
- If the LED blinks alternatingly on the receiver side, it’s successfully receiving and interpreting the data coming from the transmitter.
- Deliverable: wire a potentiometer to your transmitter Arduino, and use it to dim an LED wired to your receiver Arduino.
Creative/exploratory output ideas
- Implement two-way communication (each Arduino’s
TX
connects to the other’sRX
). What will your Arduinos talk about?! How will you make sure they don’t try to talk at the same time? - Connect more than two Arduinos. Make one the leader and the others the followers. Make each follower interpret the instructions differently.
Topic: Data logging to an SD card
Technical training sequence
- Using the SD card library <https://docs.arduino.cc/libraries/sd/> run the Data Logger example <https://www.arduino.cc/en/Tutorial/LibraryExamples/Datalogger/>
- Note that this example assumes your Arduino has a built-in SD card reader, but you can run the same code using an external SD module, so long as all of its pins are plugged in to the right places. We have SD modules as well as SD cards available in the lab.
- Deliverable: modify the “Data Logger” example to log data from a potentiometer. The output file should have a legend at the top (explaining what is being recorded and at what rate), and then the data should appear as one record per line in a
.txt
file. Submit a screenshot (or screen recording) of your text file. Sample output file:
Data log of potentiometer wired to pin A0 Sampling: every 150 milliseconds millis() timestamp analogRead value ------ START OF DATA ------ 164 1023 314 1023 445 1022 596 983 (etc., etc., etc.)
Creative/exploratory output ideas
- Build a battery-powered device that can log data from at least two different sensors to an SD card. It should have a toggle switch that can switch logging on or off, and a momentary pushbutton that when pressed will insert a line saying “MARKER” into the log.
Topic: Radio communication between two Arduinos
Technical training sequence
- Get two nRF24L01 radio modules (ioRef part #0650) and two Arduinos
- Wire each module to its own Arduino, and run the sample code described on this tutorial site: https://howtomechatronics.com/tutorials/arduino/arduino-wireless-communication-nrf24l01-tutorial
- This example relies on the “RF24” library which you can read about here: https://nrf24.github.io/RF24/index.html
- I recommend labeling one Arduino “transmitter” and the other “receiver” using a piece of tape, writing on the table, etc., to reduce confusion as you upload different code to them.
- Both Arduinos will need to be powered to work, and you can do that by interconnecting their
5V
andgnd
pins so that if either one is plugged into your computer, it will share its power with the other. - Take a walk around the room and see if anybody else is also using the same radio modules; if so, please coordinate with them to change your
const byte address[6]
to a different value so that your radios don’t have crosstalk!
- Deliverable: modify the sample code so that one Arduino transmits an
analogRead
value from a potentiometer and the receiver reads that value to vary the brightness of an attached LED.- Note: you will want to transmit an
int
rather than achar
array in order to achieve this. From the transmitter side, the loop would contain something like:int sendVal = analogRead(POTPIN); radio.write(&sendVal, sizeof(sendVal));
and then on the receiver side, you would similarly modify the code so it’s expecting to receive an
int
.
- Note: you will want to transmit an
Creative/exploratory output ideas
- Remote switch flipper: Wire a two buttons to a transmitter Arduino, and use them to command a remote servo motor to go up or down (and notionally flip a light switch on/off but you don’t have to build that part).
- Motion alarm: Wire a motion detector or break beam sensor to the transmitter Arduino, and if it detects motion or sees a broken beam, make an LED blink and a speaker beep on the receiver side.
- Remote temperature and humidity sensor: Wire a DHT-11 or DHT-22 temperature and humidity sensor to the transmitter Arduino, and print the received data onto the serial monitor via the receiver Arduino. You can transmit multiple values by packing them together into a
struct
of twofloat
s, or you can also structure your data in a fixed way as text, e.g. sendingt68.6h58.3
to mean that the temperature is 68.6ºF and the humidity is 58.3%, and then the receiver side would need to decode those two numbers.
Topic: Choose your own adventure
Is there a piece of electronics or mechanics you’re interested in exploring?
I’m open to you doing something that’s not listed in the menu of learning experiences. In order to do your own thing, you’ll need to include the following information in your Canvas “proposal” assignment:
- What is the thing/technique/etc. that you want to learn?
- What will you use as a technical training sequence? Be specific and provide a URL if it’s relevant.
- What do you want to aim for as a creative/exploratory output?