TDD a lamp microcontroller

This learning hour follows on from the one about TDD in a finite state machine. This time we work on the same problem but instead of working on states and transitions, we focus on the lamp microcontroller logic.

Learning Objectives

Session Outline

Connect - bit operations

Given this list of bit operations

And these desired outcomes

Match them together

You could put these on sticky notes on a whiteboard for example. The idea is to remind people that they know how to do bit manipulation, which will be useful in this exercise.

Concept - using the fake hardware

We continue to work on a finite state machine simulating a Lift Button but this time the focus is on turning the lamp on and off. In the production code this will be achieved using some bit operations on a port. In the test we need to use a different port memory address, one that we control. This is a kind of fake.

Use the starting code for a Lift Button on the branch ‘starting_point_applied_tdd_2’. Demonstrate how to set up the fake port and write the first (failing) test for switching the lamp on.

Concrete - using TDD with the fake address

Split up and work in pairs implementing the lamp functionality.

Conclusions - using fake hardware

Ask people if they experienced any challenges or difficulties using the faked hardware. Also if they had any trouble with TDD. Ask people to think about whether TDD is a good approach for embedded development.