Tiny chips: ATtiny85 and CH32V003 lesson plan
The eight-pin ATtiny85 and the ten-cent CH32V003 RISC-V: six pins and their fuses, an 8 KB budget with no multiplier, sleep and the watchdog for coin-cell life, I2C bit-banged by hand, a race between the two chips, and a twinkling star ornament.
Objectives and materials
By the end, students can
- Why tiny, which pin does what, and what fits in 8 KB.
- Sleep for battery life, I2C by hand, and the RISC-V alternative.
- A coin-cell star ornament that twinkles and sleeps.
Materials for the whole unit
- ATtiny85
- Full-size breadboard
- I/O expander, PCF8574
- LED x 2
- Potentiometer
- Pushbutton
- Resistor x 2
- WCH CH32V003 (RISC-V, 16 KB)
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.
Life in eight pins
Why tiny, which pin does what, and what fits in 8 KB.
| Lesson | Time | What students do |
|---|---|---|
| Why tinyAn eight-pin ATtiny85 on a coin cell’s 3 V: six I/O pins, 8 KB of flash, 512 bytes of SRAM, 8 MHz from its own oscillator, a serial port it makes itself, and two lamps blinking for about a dollar. | 45 min |
|
| Pins and fusesSix pins doing four jobs: a knob on the ADC, two PWM lamps, a button on the pin-change interrupt and a software serial port, plus the fuses that set the clock and can turn the RESET pin into a seventh. | 55 min |
|
| 8 KB budgetsFlash, SRAM and time on a chip with no multiplier: a temperature conversion in fixed point fits in 3.4 KB and runs 100 times in 144 microseconds; the same in floating point needs 7.3 KB and 1872 microseconds. | 45 min |
|
Materials
- ATtiny85
- Full-size breadboard
- LED x 2
- Potentiometer
- Pushbutton
- Resistor x 2
Check for understanding
Each student finishes "8 KB budgets" 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: "Try floating point".
Tiny chip skills
Sleep for battery life, I2C by hand, and the RISC-V alternative.
| Lesson | Time | What students do |
|---|---|---|
| Sleep and wakeA coin cell lasts as long as the chip sleeps: the watchdog wakes the ATtiny85 every half second to flash a lamp, the button wakes it at once, and the datasheet’s currents say 63 days, or 669 at eight seconds. | 55 min |
|
| Bit-banged I2CI2C by hand on two ordinary pins: open drain by switching the pin direction, a START and a STOP, eight bits and an ACK, a scan that finds a PCF8574 at 0x20, and a byte written to its pins and read back. | 55 min |
|
| RISC-V for centsThe ten-cent CH32V003, a 32-bit RISC-V at 48 MHz, races the ATtiny85 on the same CRC-32: 6.4 ms against 131 ms, the same answer, and what 32 bits and six times the clock buy you. | 45 min |
|
Materials
- ATtiny85
- Full-size breadboard
- I/O expander, PCF8574
- LED x 2
- Pushbutton
- Resistor x 2
- WCH CH32V003 (RISC-V, 16 KB)
Check for understanding
Each student finishes "RISC-V for cents" 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: "Choosing between them".
Boss project
A coin-cell star ornament that twinkles and sleeps.
| Lesson | Time | What students do |
|---|---|---|
| Boss: a coin-cell star ornamentA twinkling star ornament on an ATtiny85: two lamps twinkle at random in PWM, the button steps through twinkle, steady and off, and off is a deep sleep that only the button ends, with the battery sums from the datasheet. | 65 min |
|
Materials
- ATtiny85
- Full-size breadboard
- LED x 2
- Pushbutton
- Resistor x 2
Check for understanding
Each student finishes "Boss: a coin-cell star ornament" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Make it yours".
Teach this unit as a class
Start a class from this course and its 7 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.