Electronic Circuits in Technology-Enabled Devices
Electronics inside an electric fan motor.
Electronics inside a Tesla Model 3 Motor.
Using Microprocessors
Our first few projects introduce the use of a microprocessor to con-
trol simple electronic devices.
Last Week: Focus on hardware.Control LED with pushbutton.
This Week: Focus on microprocessor.Control LED with a microcontroller.
Next Week: Focus on programming.Implement a simple electronic game.
Last Week
Build a circuit to control a two-color LED with push-button switches.
Pushing one button turns the LED red, pushing the other button
turns the LED green.
2.2 kΩ 10 kΩ
3.3 V
Advantage: simple circuit.
Disadvantage: functionality is fixed by the hardware.
This Week
Increase functionality with a microcontroller.
Modify your circuit so that the push-button switches provide input
to the microcontroller and the microcontroller turns the LEDs on.
2.2 kΩ 10 kΩTeensy 3.2
Microcontroller
Card→ →
The microprocessor can associate more complicated behaviors with
the switches: flashing, timing, visible metronome, ...
But first: connect the switches and LEDs to the microcontroller.
Teensy 3.2 Microcontroller Card
Four inputs: Hall A, Hall B, Hall C, and Hall D.
Four pairs of outputs: Coils A+/A–, B+/B–, C+/C–, and D+/D–.
These inputs and outputs plus power (3.3 V and ground) are available
using screw connectors at bottom of card.
Controlling the LEDs
Each ”Coil” connector can switch between +5 V and 0 V under pro-
gram control. Use Coil A+ and Coil A- to control a two-color LED.
2.2 kΩ 10 kΩ
Coil A–
Coil A+
gnd
Teensy 3.2
MicrocontrollerCard
If Coil A+ is +5 V , the LED will produce green light.
If Coil A– is +5 V , the LED will produce red light.
If Coil A+ and Coil A– are both 0 V , the LED will produce no light.
Controlling the Coil Outputs
To set Coil A+ to 5 V and Coil A– to 0 V :
digitalWrite(AIN1,HIGH);digitalWrite(AIN2,LOW);
To set Coil A– to 5 V and Coil A+ to 0 V :
digitalWrite(AIN1,LOW);digitalWrite(AIN2,HIGH);
To set Coil A+ and Coil A– to 0 V :
digitalWrite(AIN1,HIGH);digitalWrite(AIN2,HIGH);
Connecting the Push-Button Switches
We have finished the right, move on to the left.
2.2 kΩ 10 kΩTeensy 3.2
Microcontroller
Card→ →
Switches
Our switches are normally open (leads are electrically disconnected).
When pushed, they close (leads electrically connected).
Must convert switch closure to voltage for the microcontroller.
+3.3 V
gnd
output voltage
If the switch is open, there is no current through the resistor,
→ output voltage is 3.3 V .
If the switch is close, the output is connect to ground,
→ output voltage is 0 V .
Adding the Switches
Use ”Hall A” for switch 1 and ”Hall B” for switch 2.
10 kΩ
Hall B
10 kΩ
+3.3 V
gnd
Hall A 2.2 kΩ 10 kΩ
Coil A–
Coil A+
gnd
Now the microcontroller can sense when the buttons are pushed
HallA_voltage = analogRead(A0);HallB_voltage = analogRead(A1);
and use that information to change the behavior of the LEDs.
Breakout Groups
Work with your group members to modify your circuit from last
week so that the push buttons privde input to the microcontroller
and the microcontroller turns the LEDs on.
2.2 kΩ 10 kΩTeensy 3.2
Microcontroller
Card→ →
More details are provided under the week 2 lab tab:
http://mit.edu/6.a01
Homework: Upload a video to demonstrate this week’s project.