Explain what each project DOES, and introduce the components. Then have students look at the circuit diagram, and predict which pins will be INPUT and OUTPUT, as well as explain the function of different parts of the circuit. Try to get them to understand the logic of how the circuit is put together, and how the code will reflect that before even letting them see the code. Then, show the code and have them identify how each part corresponds to the physical circuit.
Encourage students to not EXACTLY follow the circuit diagrams for their breadboards, because sometimes the images are unrealistic and components don’t fit that way.
Show students the examples in the IDE and let them use them. BUT, give them quizzes on the code and expect them to actually know how it works. Have them: identify what something does in the example code, fix obvious errors, show new/alternative code and ask them to figure out what it does, show/explain new/alternative breadboard wirings and ask them to modify the code to work for that set up.
Featured Materials
LEDs, Resistors, Buttons, Breadboards
General Notes
While it’s good to introduce the Arduino board itself and all the basic features right at the beginning, it’s probably a good idea to keep revisiting the different parts of the board in each following lesson (such as TX/RX lights and pins, analog vs. digital, etc.).
Classroom Setting
I think it is best when I do the very general “introduction to circuits” by myself, independent of this lesson. But maybe AFTER doing that step by step with the kids, have them do the rest of this lesson (the buttons in series and parallel) on their own, then come back as a group to discuss it. I would then actively teach series vs. parallel, and make sure they understand what’s going on.
New Topics
● Circuits as loops, Ground
● Directionality of LEDs
● Need for resistors so LED doesn’t get full 5V load
● Series and Parallel circuits
● How Breadboards work
Modifications & Taking it Further
● Add more LEDs and just mess around with it
● Add differently colored LEDs and have buttons that only activate particular colors. Experiment with combinations of LEDs and buttons so that many LEDs are activated by just one button, but there are multiple button/LED groups.
LEDs, Buttons
This is sort of the first time for using code. However, I think doing a “Lesson 1.5” where I show them the Blink example code and have them mess around with that first is a good idea.
First explain what is going on, then show them the circuit diagram and walk them through what’s happening. Ask students to predict some aspects of the code, like which pins should be INPUT and which should be OUTPUT. Most importantly, HOW does the code “know” when the button is pressed or not?
● General aspects of the code: Setup & Loop, initializing Variables, Integers
● Using INPUT pins to receive data
● Have students swap/scramble what the LEDs do when the button is pressed
● Add more LEDs and expand the code. Example: One of each color LED, button press = cool colors on, not pressed = warm colors on.
Temperature Sensor
Don’t forget about needing to readjust the baseline temperature once you can test in the classroom. Printing to the serial monitor, don’t forget “SerialPrintln()” to start a new line. Make sure students are using the actual TMP and not the other transistors!
Ask for ideas about how to create a “digital” thermometer. What inputs and outputs would be needed? Explain how the TMP sensor works and how you convert its direct analog output to degrees Celsius (and show where/how that happens in the code).
● Introduces the use of the Serial Monitor, using the standard 9600 bps rate.
● Doing math/conversions in the code
● for() loop
● Constants (as opposed to Variables)
● float numbers
● if/else statements
● && “and” in a logical sense. “If this && that condition are both true…”
● Modify the rate at which the LEDs turn on as per the number of degrees that rise.
● Add more LEDs and make the overall “thermometer” more sensitive and have a wider range. Can you build one so sensitive that, if you know the baseline temperature, you can actually know exactly how hot it is by seeing which LED is lit up?
● Redesign the thermometer with decorated labels such that only one indicator LED lights up at a time, next to the corresponding sign that says what the temperature is.
Photoresistors, Multi-Color LED
Those damn gels are easy to lose. Maybe find some cheap cellophane or colored saran wrap?
Go over how the multi-color LED works and its four pins. May want to take this opportunity to teach a little bit about the science of color. In the code, point out that some variables are constant while others aren’t. *I’m not sure, but it seems like in order to simply initialize a variable that will end up taking on other values later, you just set it equal to 0 at the top of the code. Perhaps the Arduino code doesn’t let you just make up variables on the spot.*
● “The Arduino can’t vary the output voltage on its pins, it can only output 5V. Hence you’ll need to use a technique called Pulse Width Modulation (PWM) to fade LEDs. PWM rapidly turns the output pin high and low over a fixed period of time.” Note the 1023 to 255 conversion in the code. Relevance of 255? → “In order to use the values from the sensor for the LED, you need to do some math. The ADC provides a 10-bit number, but analogWrite() uses 8 bits. You'll want to divide your sensor readings by 4 to keep them in range of the output.
● Duty Cycle - percentage of time a pin is HIGH when undergoing PWM
● “\t” is like the tab button, when printing in the Serial Monitor
● What happens if you add buttons to interrupt the signal from the photoresistors? Would it give you more control over the color mixing?
● Skip the photo resistors entirely and massively rewrite the code so that you can turn on different colors just by button presses alone.
● Add more RGB LEDs to the mix for a fun visual array.
Servo motor, potentiometer, capacitor
The circuit diagram is BS - the potentiometer needs to go across the gap in the breadboard in order to fit right and still have access to other pins in the row. Watch out, the circuit diagram may have the servo’s colored wires in a different order.
The potentiometer sucks at staying in the breadboard. A loose connection will cause the servo to jump around all over the place. If you press down firmly on the potentiometer while using it, the servo should work more smoothly.
Explain how servos work, and demonstrate how to use the male header pins. Explain how potentiometers work. Before showing the circuit diagram, explain how the potentiometer will work as a control for the servo. Ask students to guess if we’d be connecting the potentiometer to an analog or digital pin, and why.
Why the capacitors? “When a servo motor starts to move, it draws more current than if it were already in motion. This will cause a dip in the voltage on your board. By placing a 100uf capacitor across power and ground right next to the male headers as shown in Fig. 1, you can smooth out any voltage changes that may occur. These are called decoupling capacitors because they reduce, or decouple, changes caused by the components from the rest of the circuit. Be very careful to make sure you are connecting the cathode to ground (that’s the side with a black stripe down the side) and the anode to power. If you put the capacitors in backwards, they can explode.”
● Importing libraries to code (servo uses a library)
● map() function to change the scale of values from an analog source
● Try using a different analog input sensor to control the servo
● Find a way to get the damn potentiometer to have a more solid connection
Piezo, photoresistor