Build a vending machine lesson plan
Build a real vending machine piece by piece: a keypad, a screen, coins and change, spirals, a drop sensor and service mode.
Objectives and materials
By the end, students can
- A keypad to choose with and a screen that talks back.
- Take money, turn a spiral, and make sure the item really fell.
- Four slots, stock counts, change for every price and a service code.
Materials for the whole unit
- Arduino Uno R3
- Character LCD with I2C backpack
- Full-size breadboard
- Keypad, 4x4
- Limit switch, lever microswitch x 2
- Piezo speaker
- Vending machine cabinet
Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.
The front panel
A keypad to choose with and a screen that talks back.
| Lesson | Time | What students do |
|---|---|---|
| A keypad to choose withStart the vending machine with a 4x4 keypad: sixteen keys on eight pins, read by scanning rows and columns, and a selection like B2. | 50 min |
|
| A screen for pricesAdd a 16x2 LCD on an I2C backpack, so the machine can show prices, credit and messages with only two signal wires. | 50 min |
|
Materials
- Arduino Uno R3
- Character LCD with I2C backpack
- Full-size breadboard
- Keypad, 4x4
Check for understanding
Each student finishes "A screen for prices" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Clear, then print".
Selling
Take money, turn a spiral, and make sure the item really fell.
| Lesson | Time | What students do |
|---|---|---|
| Coins, bills and creditAdd a coin switch and a bill switch, count credit in whole cents, and give a refund on the star key. | 50 min |
|
| The first spiralTurn slot A1 with a continuous servo: pay, choose, and the spiral turns once and pushes the item off the end. | 50 min |
|
| Did it really dropAdd an infrared beam across the bin, so the machine only takes your money when it sees the item fall, and tries again when it does not. | 50 min |
|
Materials
- Arduino Uno R3
- Character LCD with I2C backpack
- Full-size breadboard
- Keypad, 4x4
- Limit switch, lever microswitch x 2
- Vending machine cabinet
Check for understanding
Each student finishes "Did it really drop" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Measure the outcome".
The finished machine
Four slots, stock counts, change for every price and a service code.
| Lesson | Time | What students do |
|---|---|---|
| Four slots and service modeFinish the machine with four spirals, a speaker, sold out counts, change for every price, and a code that opens service mode. | 50 min |
|
Materials
- Arduino Uno R3
- Character LCD with I2C backpack
- Full-size breadboard
- Keypad, 4x4
- Limit switch, lever microswitch x 2
- Piezo speaker
- Vending machine cabinet
Check for understanding
Each student finishes "Four slots and service mode" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Your machine".
Teach this unit as a class
Start a class from this course and its 6 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.
The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.