0% found this document useful (0 votes)
8 views

Arduino

This document discusses using Arduino microcontrollers in a classroom setting to teach students how to phrase effective science questions and answer them with original data collection. It describes a 1-credit university course where students define their own question, build a device to collect data, and answer the question. Key skills developed include defining curiosity-driven questions, designing measurement apparatuses, using hardware/software interfaces, and completing independent technical tasks. Example student questions and proposed course activities are provided. The goal is to give students an independent project experience and confidence in addressing new challenges through data-driven inquiry.

Uploaded by

jsdtrainer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Arduino

This document discusses using Arduino microcontrollers in a classroom setting to teach students how to phrase effective science questions and answer them with original data collection. It describes a 1-credit university course where students define their own question, build a device to collect data, and answer the question. Key skills developed include defining curiosity-driven questions, designing measurement apparatuses, using hardware/software interfaces, and completing independent technical tasks. Example student questions and proposed course activities are provided. The goal is to give students an independent project experience and confidence in addressing new challenges through data-driven inquiry.

Uploaded by

jsdtrainer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 33

Arduino microcontrollers in the classroom:

teaching how to phrase effective science questions


and how to answer them with original data

Science & Engineering Saturday Seminar


Tony Dinsmore, UMass Physics,
January 25, 2020

Discussion stems from a UMass course, Physics 192M, taught in spring 2018-2020.
All course materials are available; please email dinsmore@physics.umass.edu
Why design a new course?
Our Physics BS program provides a powerful skillset in problem solving, analytical thinking, model
building, quantitative analysis. (Also, writing, presenting, some computational skills.)

What’s missing? We would like students to graduate with…


• a major independent accomplishment
(achieved without the direction of an instructor in a pre-set, weekly progression.*
• making an original object or conceptual model without an explicit, step-by-step recipe.*
• confidence to address new challenges using their analytical skillset.*
• practice conceiving and executing their own experiment, calculation, or project,
where they figure out what to learn, and then learn it.
*even if they don’t work with
Would similar goals apply to K-12 education? a faculty-led research group.

Can we do this in a classroom setting? We’re trying a 1-credit course for UMass freshmen. Optional.
• Provide these experiences in the context of science and exploring the unknown.
• Defining effective science questions is foundational in science research.
• Successful parts (if any) to be incorporated into lab-course curriculum.
• Long run: incorporate makerspaces into the curriculum to provide 4-year support.
Physics192M: Introduction to measurement using the Arduino
By the end of the course, students will have defined their own question, set up a device to collect data, and
answered the question. The course also provides a first experience (for many) in creating a logical sequence of
steps to carry out a task, in preparation for programming. No prior experience with computing or hardware is
needed.
Key skills to be developed:
(i) Defining a curiosity-driven question in a constructive way.
(ii) Designing, making, and trouble-shooting an apparatus to measure a physical quantity.
(iii) Facility with the hardware-software interface.
(iv) Confidence in completing a technical task independently.
Comments for potential instructors:
• 1 credit. One 2-h meeting plus 1-2 h homework/week.
• Pre-req: Intro-level mechanics; that’s it.
• 1 faculty instructor + 1 TA for up to 20 students.
• No textbook but each student should plan $20 for parts.
• Be ready to quietly help students with $$.
• This year, we bought 40 Arduinos and loaned them.
• Don’t be anxious about getting stumped on technical Qs.
www.adafruit.com
The pins of an Arduino (or Elegoo) Uno

The Elegoo Uno R3 is about $10-$15.


The Arduino Uno R3 is $22.

It’s quite powerful.


One limitation: it’s slow (~1kHz)
serious
The Arduino is a fun toy tool
Surface voltage of charged sand
Surface
1300
voltage Measured V(t)
Humidity probe 1200 Fit to stretched exponential + constant
Fit to empirical function, A(t/ + 1) + Vinf
(Adafruit, $5)

Voltage (V)
Dry, 1100
Mark
Lewis, charged 1000
BS 2017 sand Lower
900 humidity
800
Acquisition
700

101 102 103 104 105


Time (s)
Almost everyone has a powerful computer laptop.
We don’t need LabVIEW or special cards ($1k) for serious
data acquisition & control.
Courses using Arduinos for measurement rather than
control (e.g., robotics) are not common.
www.adafruit.com
Some inspiring, useful devices
RGB Color Sensor, $7.95
Motion sensor, $9.95
Ultrasonic distance sensor, $3.95, $6.95
Flex sensor, $7.95
Vibration sensors, $0.95+
Hall Effect sensor (magnetic field), $2.00
Microphone with amplifier, (MAX4466 or www.arduino.cc
MAX9814), $6.95-$7.95
Fluid-immersible temperature sensor, $9.95 Smart-phone interface/bluetooth
Soil moisture sensor, $7.95 Relays (Arduino can control a 115V line)
Temperature and humidity, $3.95, $9.95 Megapixel cameras
Door closing sensor, $3.95 WiFi
Touch sensor, $5.95 GPS
Rubber cord stretch sensor, $9.95 Motor controllers (stepper, servo)
Pressure sensor, $14.95 RFIDs
Luminosity sensor, $5.95 Solar panels
IR thermal camera ($39.95+) LED displays
Remote temperature sensors (IR), various Touch screens
Proposed schedule for today:
• Example questions/projects from my class.
• Divide into groups of ~4 for small-group discussion:
30 min • “What makes an “effective science question?”
• Report back, discuss among the whole group
• Get to know the Arduino
60 min • Essential components & steps
• Set up to measure temperature or light intensity
– 20-minute break –
40 min • Set up to measure light intensity or temperature
• Divide into groups according to interest or teaching level:
40 min • “How can we teach these skills in a classroom?”
(Which skills? What projects? What aspects to emphasize?)
• Report back, discuss among the whole group
10 min • Summary of what Tony does in his course.
30 min • Converge on some lesson plans?

(Several details added near the end – where to get help, saving/exporting data, some details on Tony’s class, etc)
Example questions from Phys192M
• How does GPS location on campus affect the connection strength of the eduroam wireless
network?
• How does ambient noise change based on what part of campus you are in?
• How loud does my ukulele have to be in order to hear it my suitemates’ room?
• How does the volume of my room when my neighbors aren't home compare to the volume of my
room when my neighbors are making noise?
• As I take a shower, how do temperature and humidity of the bathroom correlate as function of
time?
• How does the weather affect the amount of people that are signed into my residential hall?
• How long does it take for my plants to dry out to the point where they need another watering?
[Several plant-related!]
• What is the acceleration rate and top speed of my RC car?
• How much movement do I make in my sleep compared to when laying perfectly still in bed?
• What is my average maximum exhalation time for blowing a note into my flute, and does this
vary with pitch?
• How does the air quality of my room [CO2, VOCs] change over the course of the day?
• How long does my dog sleep on my bed while I am away?
Posing an effective science question
Feb 24 April 17
How does temperature affect the amount of people How does the weather affect the amount of people
who enter and exit residential buildings? that are signed into my residential hall?
How loud are my neighbors at night? How does the volume of my room when my
neighbors aren't home compare to the volume of
my room when my neighbors are making noise?
Is there a point in the day when the room is empty? For how long is my room empty of people?
How does the sound level in my room vary When is the best time in my room to study?
throughout the day?
How can I make an RC car move with a battery, what is the acceleration rate and top speed of my
electric motor, a remote, and an additional arduino RC car?
as the motor controller?

Questions about the habits of individual people other than the experimenter are not allowed.
8 + 20 min
(We can
What makes an “effective science question?” certainly take
more time if
desired.)

• Divide into groups of ~4.


• for 8 minutes, discuss “what makes an “effective science question?”
(How do you know? What’s not an effective question?)
• Choose a note-taker.
• Report back to the group as a whole What we discussed:
• Can be replicated by a peer
• Whole-group discussion • Measureable, testable, data output, not yes/no
• Different from a demonstration
• Open-ended
• Will involve or support background technical knowledge
• Legal, affordable, safe, and fitting within time constraints
• Relevant to students, provocative
• Leads to more Qs, not chasing rainbows
• Supports experiments with good controls
(my favorite) • Doesn’t need a clear hypothesis,
or could disprove the hypothesis
What makes an “effective science question?”

According to Tony, an effective science question…


• is specific enough to allow measurement of defined quantities.
• can be answered quantitatively.
• does not have a yes/no answer.
• could have more than one possible answer, including the unexpected.
• can be answered with a plot, ideally one with a well-defined independent
parameter.
• does not have to have broad interest.
• does not have to be “fundamental” or otherwise sciency.
• has an answer that will be interesting or informative, e.g., for situations other
than the specified one. (Sometimes interesting questions can’t yield
interesting/informative answers; these are not effective.)
Proposed schedule for today:
• Example questions/projects from my class.
• Divide into groups of ~4 for small-group discussion:
30 min • “What makes an “effective science question?”
• Report back, discuss among the whole group
• Get to know the Arduino
60 min • Essential components & steps
• Set up to measure temperature or light intensity
– 20-minute break –
40 min • Set up to measure light intensity or temperature
• Divide into groups according to interest or teaching level:
40 min • “How can we teach these skills in a classroom?”
(Which skills? What projects? What aspects to emphasize?)
• Report back, discuss among the whole group
10 min • Summary of what Tony does in his course.
30 min • Converge on some lesson plans?
The pins of an Arduino (or Elegoo) Uno

You might have the “Mega,”


which is a bit different.

You might have one made


by “Elegoo”
The pins of an Arduino (or Elegoo) Uno
Fortunately, devices that you buy have instructions available so you don’t have to know details. But an overview is helpful:

Plug for AC adapter

The USB cables are of type AB.


The microcontroller has a memory. You can
upload a program (“sketch”) from your laptop, Press this reset button to force your sketch to start again
then disconnect the laptop. The Arduino will from the top.
function by itself as long as it has power. These 3 LEDs tell you things:
“RX” is lit when Arduino receives data. ”TX”is
lit when it transmits data. “L” is controlled by
pin 13. “On” (near bottom) means that the
Arduino has power.
I/O = “in/out” This side of the board has the
3.3V and 5V pins out a constant voltage. Can be digital in/out (I/O) pins. As inputs,
used to power devices. Also useful as reference they read 0 if input<2.5V and 1 if
voltages for testing. input >2.5V.
As outputs, they are either 0 or 5V.

Some pins are marked ~, which


Measure voltage relative to ground (GND).
means PWM (pulse-wave
Range = 0-5V, converted to 10-bit value (0-
modulation). These pins output
1023). They have other specialized functions
rapid pulses of 0 or 5V such that
too.
the time-averaged V can range
from 0-5V. Good for LED control.

Most of these pins also have other


specialized functions.
Breadboard, wires, etc. can be useful

Jumper wires (get


male/male) plug
into breadboards.
$2 for 20.

Breadboards are for making circuits


without soldering. ($5) Multimeters are
Pins are connected along columns near the available for $20 and
center and along rows at the edges, as up. If you get one, be
shown. sure it can measure
Integrated circuit (IC) chips should be voltage, current, and
mounted on the groove at the center resistance.
First goal: use pin “A0” to measure a voltage, relative to ground.

(This
We’ll measure DV.

We’ll use the pre-installed program called “AnalogReadSerial.” (Details on next slides)
(We used AnalogReadSerial, but I think that it’s easier to start with ReadAnalogVoltage. The
reason is that the latter does a little calculation to make the reported value into a real voltage.
AnalogReadSerial gives an integer value on a linear scale from 0 1023.)
You are welcome to use a UMass laptop

Also free to borrow an Arduino, detectors, resistors, wires, breadboards, etc.

If you have your own laptop and want to install the Arduino software, go to:
https://www.arduino.cc/en/main/software (or Google “Arduino IDE”)
• The “web editor” works but is not ideal for repeated use.
• Download and install Arduino 1.8.10. (Windows, Mac or Linux)
• Don’t use the “Windows App” link for a laptop or desktop.
The Arduino IDE
The IDE converts your commands into machine
code- it’s an interface. The language is like C++,
but if you’ve never programmed you can get
started fairly quickly by copying example code.
There is a vast array of helpful resources online.
(or ReadAnalogVoltage; see slide 16)
Let’s get started: Run “Arduino.exe.” Menu: file…
Examples…01.Basics…AnalogReadSerial. It should
look like this (see at right):
Click on the arrow to compile your code and
upload it to the Arduino. If it fails:
(a) Click on the check button next to it. If you have
a syntax error, you’ll see orange text at the
bottom of the screen.
(b) If it compiles OK, you might have a “USB port”
error. The most common errors are fixed by
Menu: Tools…Board, or Tools…Port. You may
have to do this many times.

This message is good news: the code was compiled and uploaded.
Click here to open a window
that shows the data coming
You can add comments (notes to from the “Serial.println”
yourself) between “/*” and “*/” . Or, on command.
any line after “//”. Do yourself a favor
and write many detailed comments!

“void setup() {…}” runs just once and


has commands to get your board set
up. Your device instructions tell you
what to write here.

“Void” means a function that does not


return a value. “void() setup” has some
initialization steps.

Void loop() defines a function that just


runs and runs and runs… The function
does things (lights flash…beep…write
data….etc) but no data is passed to the
main program (hence “void”).
Try one of these:
(I recommend this one first if
Light intensity, phototransistor #2831,
you’re new to this) $0.95 from Adafruit
Temperature, TMP36 sensor; $1.50 from Adafruit
to A0
to 3.3 V or 5V pin to GND
Writing
side
up

pin A0

+5
R approx. 10 kW
Measuring temperature
Temperature, TMP36 sensor; $1.50 from Adafruit
to A0 The code:
to 3.3 V or 5V pin to GND Start with “AnalogReadSerial.” Converts
1) Find this line: “sensorValue” to a
calibrated voltage
Writing
side

int sensorValue = analogRead(A0);


up

2) Below it, add these lines:


// Convert the analog reading to voltage:
float voltage = sensorValue * (5.0 / 1023.0);
// convert to T using mfr’s formula:
float tempValueC = (1000.*voltage - 500.)/10.;
float tempValueF = (9./5.)*tempValueC + 32.;
3) Replace the existing “Serial.Print” line with this:
Serial.println(tempValueF);
4) Replace “delay(1);” with “delay(500);”
Hold the device with flat/printed side toward you. If 5) Compile, fix mistakes, repeat. Upload.
the device gets very hot, it’s in backward. 6) Open serial monitor
Breadboards are for making circuits w/o
soldering. Pins are connected along columns
near the center and along rows at the
edges, as shown in red.
Exporting data for analysis
How fast does the T sensor respond? If you heat up your temperature sensor with your fingers and let it go, what is
the function that describes the cooling-down process? Is it the same as the warming-up process?

Here is the simplest way to export data to answer a question like this: Open up the IDE serial window. When you are
ready to start collecting data, press the “Clear output” button on the serial monitor window. Turn off autoscroll.
When you’ve collected enough data, select all (crtl-a) and copy and paste into a spreadsheet such as Excel. Then you
can manipulate the data, plot it, etc.

For two-column data (such as temperature and time), you can print the data in each row with commas (see next
slide). For Excel: copy/paste the data into a .txt file, and then import it with Excel. Try this with test data first; you
might have to change the format to make it work. For Google sheets: copy/paste directly into a single column of a
GoogleSheets spreadsheet, look for the little clipboard icon, and select “Split text to columns.”

Here’s how you could print data with each row having multiple data points separated by commas:
Serial.print(variableA);
Serial.print(",");
Serial.println(variableB);
Serial.print (without the ln) prints and remains on the same line.
Serial.println prints, and then makes a new line.
Try it. There’s also an example on next slide.
Adding time (not discussed during the workshop but some of you asked about it)
/*Modified by Tony Dinsmore, Jan. 2020, starting from ReadAnalogVoltage.
Lines were added to report the time as well as voltage in format appropriate for comma-delimited
data file. You can copy the serial window results and paste them into a Wordpad file and
save as "text.dat" and then import that file into Excel as 2 columns of data.
If you press the reset button on the board, you will see the program and the time start again.
*/
/*
ReadAnalogVoltage

Reads an analog input on pin 0, converts it to voltage, and prints the result to the Serial Monitor.
Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/ReadAnalogVoltage
*/
To collect measurements of two or more parameters, //First, define some variables. (This could also be done in loop())
unsigned long t; // Need this for time. Unsigned long can hold a large value, which is
it’s easiest to print them in a comma-delimited format //necessary because our program might run for a large # of milliseonds!
double ts; //We will use this for the time in seconds. Double precision is used so that the
using the Arduino. Then you can export to Excel or // number of seconds can be large.

Google sheets, etc. The following program will do // The setup routine runs once after uploading the program or after pressing the reset button:
void setup() {
this. From your IDE: file…New.. And them remove // initialize serial communication at 9600 bits per second:
Serial.begin(9600);
everything in the window, and then copy/paste the }
Serial.println("Time (seconds), Voltage (V)");

text below into it. // The loop routine runs over and over again forever:
void loop() {
// First, read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Note the time, measured from when the Arduino started running this program:
t = millis(); //The variable t was defined in setup()
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);
//Next, convert the time to seconds. The variable ts was defined in setup().
ts=t/1000.;

// print out the values of time , voltage:


Serial.print(ts); // removed "ln" from the print command to present line break
Serial.print(" , ");
Serial.println(voltage);
delay(1000);
}
breaktime
Proposed schedule for today:
• Example questions/projects from my class.
• Divide into groups of ~4 for small-group discussion:
30 min • “What makes an “effective science question?”
• Report back, discuss among the whole group
• Get to know the Arduino
60 min • Essential components & steps
• Set up to measure temperature or light intensity
– 20-minute break –
40 min • Set up to measure light intensity or temperature
• Divide into groups according to interest or teaching level:
40 min • “How can we teach these skills in a classroom?”
(Which skills? What projects? What aspects to emphasize?)
• Report back, discuss among the whole group
10 min • Summary of what Tony does in his course.
30 min • Converge on some lesson plans?
Measuring light intensity and responding to it:
Start with “AnalogReadSerial.”
1) Find this line:
Light intensity, phototransistor #2831,
$0.95 from Adafruit
int sensorValue = analogRead(A0);
2) Below it, add these lines:
// Convert the analog reading to voltage:
float voltage = sensorValue * (5.0 / 1023.0);
3) Replace the existing “Serial.Print” line with this:
Serial.println(voltage);
pin A0 if (voltage < 0.9){
Serial.println(“light low – turning on LED");
+5 analogWrite(10, 140); This line turns on an LED:
Connect an LED with long pin at #10
} and short pin at GND.
else{ (It’s better practice to insert a resistor
R approx. 10 kW
analogWrite(10, 0); between the LED and GND because
} sometimes LEDs will burn out if you
4) Compile, fix mistakes, repeat. don’t,
Upload. but many LEDs will be fine.)

5) Open serial monitor


Proposed schedule for today:
• Example questions/projects from my class.
• Divide into groups of ~4 for small-group discussion:
30 min • “What makes an “effective science question?”
• Report back, discuss among the whole group
• Get to know the Arduino
60 min • Essential components & steps
• Set up to measure temperature or light intensity
– 20-minute break –
40 min • Set up to measure light intensity or temperature
• Divide into groups according to interest or teaching level:
40 min • “How can we teach these skills in a classroom?”
(Which skills? What projects? What aspects to emphasize?)
• Report back, discuss among the whole group
10 min • Summary of what Tony does in his course.
30 min • Converge on some lesson plans?
15 + 25 min
(We can
How can we teach these skills in a classroom? certainly take
more time if
desired.)

• What groups shall we form? (By grade level? By type of science? By…?)
• Divide into groups
• For 3 minutes, discuss “How can we teach these skills in a classroom?”
(Which skills? What projects? What aspects to emphasize?)
• Choose a note-taker.
• Report back to the group as a whole.
How can we teach these skills in a classroom?
Tony’s week-by-week schedule, 2019
W01: Get started with the Arduino. Measure voltage, measure temperature.
W02: Go further with temperature. “What happens to the temperature in my room when I am asleep?”
Sketching imaginary data. (symbols; never curves); arithmetic in the code; “millis()”, exporting data to spreadsheets for
plotting. HW: measure and plot T(t) and discuss.
W03: Measuring light intensity with the phototransistor. Coding logic-based decisions. Control LEDs. Voltage, current, and
Ohm’s Law. HW: set up the device, plot the data.
W04: Loops. Mean, standard deviation, standard error of the mean. HW: write a code to do this.
W05: Start working on final project. More loops; libraries. HW: write two questions, list necessary devices.
W06: Coding tips and pitfalls: matching data types, arrays, “=“ as assignment operator, functions, memory capacity of the
Arduino. HW: choose one question and refine it; sketch imaginary data; refine design.
W07: More on coding tips & memory. HW: refine the question and parts list.
W08: Correlations in data. HW: show preliminary data and write down two conclusions from it. If data not available, sketch
imaginary data and discuss.
W09: Schematic diagrams and wiring diagrams. HW assignment: make one of each.
W10: “What makes a science question effective?” HW10: refine question, continue working on project. List 1-2 technical
hurdles remaining.
W11: In class: work on project. Review hurdles with instructor. Leave early to collect data if approved.
W12: “ “ “
W13: In-class presentation
Finally, a written document.
Things done well & not so well in P192M
Things done well, mostly after learning from first time teaching:
• Students like designing their own project.
• Students like learning skills they think will be useful outside the class.
• The tone in class is constructive and stimulating. Students help one another.
• In class, when instructors review work that students posted for assignment, it is always constructive.
• Timing has improved:
• We get started with data acquisition and plotting fast.
• A staged sequence of mini-projects (temp, light…could use one more?)
• A staged sequence of specific coding skills across a few weeks. ← response to student comments
• Handouts with distilled programming tips are useful. There’s too much info online, not all of it relevant.
• Schematic and wiring diagrams are a good and surprisingly challenging exercise. Could be done earlier.
• 2-hour in-class period much better than 1.25-hour, which is far too short! ← response to student comments
• As many as 20 students in a section is OK with a good teaching assistant; 7 is a bit small.

The course “allowed [a student] to go above and beyond what I was capable of doing, and FAIL. Failing and
switching the basis of my project without an extreme impact to my grade was beyond valuable to me. “
Schematic diagram Wiring diagram
Computer
Arduino Uno
Phototransistor
Voltage USB to (Adafruit #2831)
detector computer
Power Anolog in
+5 V 5V GND A0
Resistor, 10 kW

Light
sensor
10 kW

What are the main parts and their What wire goes where?
function? (Not technical specs or names.) What are the names and (maybe) technical specs?
How does the information or current flow? It might be harder to see how the information or
Don’t forget the computer. current flows.
Things to be improved

For this semester:


• Compel students to write things down on paper – daily sketches, diagrams, record of things done…
• Adopt a more focused approach to designing a good question. Do this later in the semester, after students have
prelim data.
• Don’t let students squeak by with little work in the beginning; it affects their final project.
• Give more explicit feedback on HWs. This varied. Sometimes we gave extensive feedback in class, sometimes not.
(If this were a 2-credit class, I’d have them revise assignments)
• Upgrades to the handouts always need to be made as I learn things (usually from the students).
• Seating locations: Pairing students at workbenches is good; too spread across the class is not.
Where to get help

Organized, structured help or tutorials:


There are many books about Arduinos but I don’t know any one well enough to specifically recommend it.
Arduino website: a tour through built-in examples: https://www.arduino.cc/en/Tutorial/BuiltInExamples
(When you go to file…Examples… you find many built-in programs. These are very good for getting to know
the capabilities.
Arduino website: Education resources, https://www.arduino.cc/education

Ad-hoc, on-the-fly help:


• A list of functions (computer commands): https://www.arduino.cc/reference/en/#functions . This page lists
many useful things, and each is a link.
• Searching for commands or functions: same URL as above, using the search function at the top of the page. For
example, if you type “time,” it will bring you to “millis()”
• Google. Type the name of your sensor. If that gives too many options, try adding “Arduino” to your search terms.
• Adafruit: For example, search for “sensors” and take a look.

You might also like