BackSection Summary: LED Projects and Digital Input

Activities 2.4 – 2.7. Use this to review, or to fill in a definition you missed.
1. Sequencing Output
Several LEDs, each on its own pin, become a sequence once the code decides the order and the timing.
- Cumulative Sequence
- A sequence where each new step joins the ones before it, instead of replacing them.
2. Writing Your Own Functions
When the same few lines keep reappearing, give them a name. A parameter then lets that one definition handle every variation.
- Function
- A named, reusable block of code.
- def
- The keyword that starts a function definition.
- Parameter
- A placeholder variable in a function definition, filled in with a real value each time the function is called.
- Call
- Actually running a function by writing its name followed by parentheses.
3. Groups of LEDs
A list can hold objects, not just numbers. Putting your Pin objects in one list lets a single loop animate all of them.
- LED Array
- A row of LEDs treated as one group instead of as separate lights.
- List of Objects
- A list whose elements are objects rather than plain numbers or strings — here, one
Pin per LED. - Animation
- A pattern of on/off states separated by pauses, producing the illusion of movement.
4. Reading a Button
A pin can be read instead of driven. An unconnected input floats, so a pull-down holds it at 0 until the button says otherwise. A function that measures something should hand the number back with return.
- Digital Input
- A pin the board reads instead of drives, giving
0 or 1. - Pull-Down Resistor
- A resistor holding an input pin at 0 when nothing else is driving it. The board has one built in, switched on with
Pin.PULL_DOWN. - Return Value
- The value a function hands back to whoever called it, using
return. - False Start
- Pressing before the signal — an attempt that must not be counted as a reaction time.