Skip to content

Commit 147bd01

Browse files
finalise documentation
1 parent c220e56 commit 147bd01

9 files changed

Lines changed: 148 additions & 190 deletions

File tree

README.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,27 @@ This repository is a series of introduction tasks to teach students the basics o
44

55
Students will be recreating a model of the pedestrian crossing on Unwins Bridge Road out the front of Tempe High School.
66

7+
## Tutorials
8+
9+
| Tutorial | OOP/Pi Pico Concepts Covered |
10+
| --- | --- |
11+
| [Lecture0](tutorials\Lecture0.md) | • Introduction Projects<br>• Wokwi<br>• Wire your system |
12+
| [Lecture1](tutorials\Lecture1.md) | • Unit Testing<br>• UML Class Diagrams<br>• Generalisation<br>• Super/Sub Classes<br>• Instantiation |
13+
| [Lecture2](tutorials\Lecture2.md) | • Overriding Polymorphism<br>• DRY<br>• Encapsulation<br>• Setter and Getters<br>• Overloading Polymorphism |
14+
| [Lecture3](tutorials\Lecture3.md) | • Abstraction<br>• Non-Blocking |
15+
| [Lecture4](tutorials\Lecture4.md) | • Pull Down Button<br>• Interrupts |
16+
| [Lecture5](tutorials\Lecture5.md) | • PWM<br>• Stubs and Drivers |
17+
| [Lecture6](tutorials\Lecture6.md) | • Multiple Inheritance<br>• Association<br>• Facade pattern<br>• Subsystems |
18+
| [Lecture7](tutorials\Lecture7.md) | • Open & Closed Loop Control Systems<br>• State Machine |
19+
20+
<hr>
21+
722
## Introduction to Pi Pico & Common Mechatronic Commonents
823

24+
Students will follow text-based instructions to build simple Pi Pico circuits and implement straightforward procedural programs to test their functionality. These activities will help students understand basic hardware connections and programming concepts while reinforcing their debugging skills.
25+
26+
All projects can be physically wired and tested (see [components list](#components-required)) or simulated and programmed in the IDE of [Wokwi](https://wokwi.com/).
27+
928
### Projects
1029

1130
1. [Connect and control a LED](introduction_projects/1.blink_led.md)
@@ -16,7 +35,7 @@ Students will be recreating a model of the pedestrian crossing on Unwins Bridge
1635
6. [Connect and read a ultrasonic sensor use it to control the servo motor](introduction_projects/6.ultrasonic_sensor.md)
1736
7. [Connect and control a I2C 16x2 LCD Display](introduction_projects/7.I2C_module.md)
1837

19-
### Components
38+
### Components Required
2039

2140
> [!Note]
2241
> Students can build using physical components or prototype using this [Template Wokwi Project](https://wokwi.com/projects/433242006092880897).
@@ -51,8 +70,16 @@ Students will be recreating a model of the pedestrian crossing on Unwins Bridge
5170
| 3V3 | 3V Power |
5271
| VBUS | 5V Power |
5372

73+
<hr>
74+
5475
## OOP Mini Project
5576

77+
Students will follow text and video-based lectures to develop a pedestrian and traffic controller system using the Pi Pico. Through this system, they will learn a range of Object-Oriented Programming (OOP) concepts and practices, including encapsulation, inheritance, polymorphism, and abstraction. Additionally, students will explore hardware integration concepts such as GPIO pin control, PWM signals, and interrupt handling.
78+
79+
The lectures will guide them through building subsystems like traffic lights and pedestrian signals, implementing state machines, and understanding open-loop and closed-loop control systems. By the end of the course, students will have gained practical experience in designing, testing, and debugging both software and hardware components.
80+
81+
All projects can be physically wired and tested (see [components list](#components)) or simulated and programmed in the IDE of [Wokwi](https://wokwi.com/).
82+
5683
![A street view image of the system we will be modeling](/images/real_world_situation.png "The traffic lights, pedestrian warning lights, pedestrian button and control system.")
5784

5885
### Final Product
@@ -199,16 +226,12 @@ classDiagram
199226
PedestrianSubsystem --o Controller : Contains
200227
```
201228

202-
> [!Note]
203-
> Inheritance and association labels are note required in a UML diagram but have been added for understanding.
204-
205229
## Script Versions Provided
206230

207231
| Version | Notes |
208232
| ------- | ------------------------------------------------------------------------------------------------------------------------- |
209233
| v01.py | Basic "Blink" Program (the Hello World of mechatronics) for Unit Testing the Microcontroller. |
210234
| v02.py | Unit Test for wiring and use basic methods from Super `Pin` and `PWM` . |
211-
| v03.py | A blank python script. |
212235

213236
##
214237

examples/v99.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Completed system ready for System Testing
33
"""
44

5-
from project.py_scripts.LL_unit_Test import Led_Light
5+
from led_light import Led_Light
66
from pedestrian_button import Pedestrian_Button
77
from audio_notification import Audio_Notification
88
from controller import Controller

tutorials/Lecture1.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22

33
## Lecture 1 Concepts
44

5-
- [Lecture 1](#lecture-1)
6-
- [Lecture 1 Concepts](#lecture-1-concepts)
7-
- [Unit Testing](#unit-testing)
8-
- [Wokwi Unit Testing](#wokwi-unit-testing)
9-
- [Physical Unit Testing](#physical-unit-testing)
10-
- [UML Class Diagrams](#uml-class-diagrams)
11-
- [Mermaid Markdown UML Class Diagram Example](#mermaid-markdown-uml-class-diagram-example)
12-
- [Generalisation](#generalisation)
13-
- [Super/Sub Classes](#supersub-classes)
14-
- [Pin Library](#pin-library)
15-
- [PWM Library](#pwm-library)
16-
- [Instantiation](#instantiation)
5+
- [Unit Testing](#unit-testing)
6+
- [Wokwi Unit Testing](#wokwi-unit-testing)
7+
- [Physical Unit Testing](#physical-unit-testing)
8+
- [UML Class Diagrams](#uml-class-diagrams)
9+
- [Mermaid Markdown UML Class Diagram Example](#mermaid-markdown-uml-class-diagram-example)
10+
- [Generalisation](#generalisation)
11+
- [Super/Sub Classes](#supersub-classes)
12+
- [Pin Library](#pin-library)
13+
- [PWM Library](#pwm-library)
14+
- [Instantiation](#instantiation)
1715

1816

1917
## Unit Testing

tutorials/Lecture2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- [Why Use DRY?](#why-use-dry)
88
- [Encapsulation](#encapsulation)
99
- [Benefits of Encapsulation](#benefits-of-encapsulation)
10-
- [Setters & Getters](#setters--getters)
10+
- [Setters and Getters](#setters-and-getters)
1111
- [State Attribute](#state-attribute)
1212
- [Getter](#getter)
1313
- [Setter](#setter)
@@ -143,7 +143,7 @@ while True:
143143
> [!Note]
144144
> In Python, identifiers (variable or method names) that start with double underscores (e.g., `__my_var`) are not truly private in the sense of other languages like C# or C++. Instead, Python uses a mechanism called name mangling. When you define a variable with double underscores, Python changes its name internally to `_ClassName__my_var`. This means it is harder (but not impossible) to access it from outside the class.
145145
146-
## Setters & Getters
146+
## Setters and Getters
147147

148148
Setters and getters are special methods used in object-oriented programming to access (get) or modify (set) the values of private or protected attributes of a class. They help encapsulate the internal state of an object, providing controlled access.
149149

tutorials/Lecture4.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22

33
## Lecture 4 Concepts
44

5-
- [Class Overview](#class-overview)
6-
- [Create Files](#create-files)
7-
- [Imports and Constructor](#imports-and-constructor)
8-
- [Implement an Interrupt](#implement-an-interrupt)
9-
- [Getter and Setter](#getter-and-setter)
10-
- [Create a Callback Method for the Interrupt Trigger](#create-a-callback-method-for-the-interrupt-trigger)
5+
- [Pedestrian_Button Class](#pedestrian_button-class)
6+
- [Create Files](#create-files)
7+
- [Imports and Constructor](#imports-and-constructor)
8+
- [Implement an Interrupt](#implement-an-interrupt)
9+
- [Getter and Setter](#getter-and-setter)
10+
- [Create a Callback Method for the Interrupt Trigger](#create-a-callback-method-for-the-interrupt-trigger)
1111

12-
## Class Overview
12+
## Pedestrian_Button Class
1313

1414
The Pedestrian_Button class extends the Pin class to provide a debounced button interface specifically designed for pedestrian crossing systems. It uses interrupt-based detection and software debouncing to reliably capture button presses. It also provides optional debug output.
1515

16-
## Create Files
16+
### Create Files
1717

1818
1. Create a Python file in `project\lib` called `pedestrian_button.py`
1919
2. Create a Python file in `project\py_scripts` called `v05.py`
2020

21-
## Imports and Constructor
21+
### Imports and Constructor
2222

2323
In your `pedestrian_button.py` include your imports, define the class and configure the initialiser with the parameters pin and debug. Add the required parameters to store time and hold state if the button has been pressed.
2424

@@ -41,7 +41,7 @@ class Pedestrian_Button(Pin):
4141
) # Set up interrupt on rising edge
4242
```
4343

44-
## Implement an Interrupt
44+
### Implement an Interrupt
4545

4646
An interrupt is a signal to the processor that an event needs immediate attention. Instead of constantly checking (polling) if something has happened, interrupts allow the system to be notified immediately when an event occurs.
4747

@@ -60,7 +60,7 @@ class Pedestrian_Button(Pin):
6060
) # Set up interrupt on rising edge
6161
```
6262

63-
## Getter and Setter
63+
### Getter and Setter
6464

6565
Our system has a design requirement that the button state is stored until the walk lights have been displayed. So, because we are not setting or getting the current state of the button as we did with the LED_Light Class, we will use an ad hoc method that updates the `__pedestrian_waiting` attribute.
6666

@@ -86,7 +86,7 @@ Our system has a design requirement that the button state is stored until the wa
8686
)
8787
```
8888

89-
## Create a Callback Method for the Interrupt Trigger
89+
### Create a Callback Method for the Interrupt Trigger
9090

9191
This `callback()` was configured in the attributes and will be executed in response to an interrupt call.
9292

tutorials/Lecture5.md

Lines changed: 81 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,94 @@
11
# Lecture 5
22

33
## Lecture 5 Concepts
4-
- [Class Overview](#class-overview)
5-
- [Create Files](#create-files)
6-
- [Imports and Constructor](#imports-and-constructor)
7-
- [Create a Single Beep](#create-a-single-beep)
8-
- [Implement a Non-Blocking Audio Notification](#implement-a-non-blocking-audio-notification)
9-
- [Turn Audio Notification Off](#turn-audio-notification-off)
104

11-
## Class Overview
5+
- [Audio_Notification Class](#audio_notification-class)
6+
- [Create Files](#create-files)
7+
- [What Are Stubs and Drivers?](#what-are-stubs-and-drivers)
8+
- [Why Use Stubs and Drivers?](#why-use-stubs-and-drivers)
9+
- [Stub Example](#stub-example)
10+
- [Driver Example](#driver-example)
11+
- [Implement the Audio_Notification Class](#implement-the-audio_notification-class)
12+
- [Imports and Constructor](#imports-and-constructor)
13+
- [Create a Single Beep](#create-a-single-beep)
14+
- [Implement a Non-Blocking Audio Notification](#implement-a-non-blocking-audio-notification)
15+
- [Turn Audio Notification Off](#turn-audio-notification-off)
16+
17+
## Audio_Notification Class
1218

1319
The Audio_Notification extends the machine.PWM to provide an interface for controlling a piezo buzzer or speaker, with optional debug output. It supports warning beeps and custom tones.
1420

15-
## Create Files
21+
### Create Files
1622

1723
1. Create a Python file in `project\lib` called `audio_notification.py`
1824
2. Create a Python file in `project\py_scripts` called `v06.py`
1925

26+
## What Are Stubs and Drivers?
27+
28+
Imagine you're building a puzzle:
29+
- A **stub** is a fake puzzle piece you use temporarily
30+
- A **driver** is a simple tool to check if your real pieces fit together
31+
32+
Definitions
33+
A **stub** is a simplified version that replaces a real lower component so it doesn't need to be full implemented.
34+
A **driver** is a simple program in a higher system that tests a lower component without fully implementing the higher system.
35+
36+
### Why Use Stubs and Drivers?
37+
38+
1. **Test in parts**: Check each piece of your code separately
39+
2. **No dependencies**: Test without needing everything to be finished
40+
3. **Controlled testing**: Create specific test scenarios easily
41+
4. **Faster development**: Don't need to wait for other parts to be done
42+
43+
This simple approach helps you build and test your code without needing to complete your system!
44+
45+
### Stub Example
46+
47+
Remember a **stub** is a simplified version that replaces a real lower component so it doesn't need to be full implemented. We are going to implement the Audio_Notification Class as a Stub so we can test the components that we will later use in a PedestrianSubSystem before fully implementing the Audio_Notification Class.
48+
49+
```python
50+
# audio_notification.py Stub Implementation
51+
class Audio_Notification:
52+
def __init__(self, pin):
53+
self.__pin = pin
54+
55+
def warning_on(self):
56+
# Just pretend to Beep
57+
print("Beep")
58+
```
59+
60+
### Driver Example
61+
62+
Remember a **driver** is a simple program in a higher system that tests a lower component without fully implementing the higher system.
63+
64+
```python
65+
# v05.py Driver Implementation
66+
67+
# Import the real component we want to test
68+
from audio_notification import Audio_Notification
69+
from led_light import Led_Light
70+
71+
def PedestrianSubsystem_driver():
72+
print("Testing Traffic Light...")
73+
74+
# Create the walk light
75+
led_pedestrian_green = Led_Light(17, True, True)
76+
77+
# Create the Audio Notification
78+
audio_stub = Audio_Notification(27, False)
79+
80+
# Test walk state
81+
led_pedestrian_green.on()
82+
audio_stub.warning_on()
83+
84+
print("Test complete!")
85+
86+
# Run the test
87+
test_traffic_light()
88+
```
89+
90+
## Implement the Audio_Notification Class
91+
2092
## Imports and Constructor
2193

2294
In your `audio_notification.py`, include your imports, define the class, and configure the initialiser with the parameters' pin' and' debug'. Add the required parameters to store time and set the duty cycle.
@@ -62,5 +134,4 @@ class Audio_Notification(PWM):
62134
if self.__debug:
63135
print("Warning off")
64136
self.duty_u16(0) # Turn off sound
65-
```
66-
137+
```

tutorials/Lecture6.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# Lecture 6
22

33
## Lecture 6 Concepts
4+
45
- [Multiple Inheritance](#multiple-inheritance)
56
- [Association](#association)
6-
- [Facade pattern](#facade-pattern)
7+
- [Facade Pattern](#facade-pattern)
78
- [Implement the Subsystems](#implement-the-subsystems)
89
- [Create Files](#create-files)
910
- [Imports](#imports)
1011
- [Define the TrafficLightSubsystem](#define-the-trafficlightsubsystem)
12+
- [Implement the TrafficLightSubsystem States](#define-the-trafficlightsubsystem-states)
13+
- [Define the PedestrianSubsystem](#define-the-pedestriansubsystem)
14+
- [Implement the PedestrianSubsystem States](#define-the-pedestriansubsystem-states)
1115

1216
## Multiple Inheritance
1317
Multiple Inheritance is used to inherit the properties of multiple classes. However, Python does not allow multiple inheritance from classes that have incompatible memory layouts at the C level, which is common with hardware in MicroPython.
@@ -134,12 +138,12 @@ classDiagram
134138
Pedestrian_Button --> PedestrianSubsystem : Association
135139
```
136140

137-
### Facade pattern
141+
## Facade pattern
138142
The Facade Pattern provides a simplified interface to a complex subsystem, shielding clients from the complexity of its components. Subsystems help manage complexity, improve modularity, and make systems more maintainable, testable, and understandable.
139143

140144
Continuing our 'Bottom-Up' approach, we will create two subsystems, one for traffic and one for pedestrians.
141145

142-
## Implement The Subsystems
146+
## Implement the Subsystems
143147

144148
### Create Files
145149

@@ -168,7 +172,7 @@ class TrafficLightSubsystem:
168172
self.__debug = debug
169173
```
170174

171-
### Define the TrafficLightSubsystem
175+
### Implement the TrafficLightSubsystem
172176

173177
```python
174178
def show_red(self):
@@ -205,7 +209,7 @@ class TrafficLightSubsystem:
205209
self.__debug = debug
206210
```
207211

208-
### Define the PedestrianSubsystem States
212+
### Implement the PedestrianSubsystem States
209213

210214
```python
211215
def show_stop(self):

tutorials/Lecture7.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
## Lecture 7 concepts
44

5-
- [Open & Closed Loop Control Systems](#open-and-closed-loop-control-systems)
5+
- [Open and Closed Loop Control Systems](#open-and-closed-loop-control-systems)
66
- [Open-Loop](#open-loop)
77
- [Closed-Loop](#closed-loop)
88
- [State Machine](#state-machine)
9+
- [Implement an Open Loop State Machine](#implement-an-open-loop-state-machine)
10+
- [Define the Controller Class and Initialiser](#define-the-controller-class-and-initialiser)
11+
- [Define the States](#define-the-states)
12+
- [Implement the State Machine](#implement-the-state-machine)
913

1014
## Open and Closed Loop Control Systems
1115

@@ -174,4 +178,3 @@ The system cycles through the following states:
174178
self.set_error_state()
175179
sleep(1)
176180
```
177-

0 commit comments

Comments
 (0)