Coding

If circuits are the hardware side of a project, programming is the instruction side. You write steps, the board follows them, and the circuit does something because of it.

You do not need to know everything at once. The main ideas that come up over and over are:

Variables

A variable is a name that stores a value so you can use it later.

Examples:

A variable lets you stop repeating the same raw value everywhere.

Data types

A data type tells you what kind of value something is.

Common beginner data types are:

Integer

count = 5
lives = 3
int count = 5;
int lives = 3;

Float

temperature = 21.5
wait_time = 0.5
float temperature = 21.5;
float waitTime = 0.5;

Boolean

A boolean answers a yes-or-no question.

led_on = True
button_pressed = False
bool ledOn = true;
bool buttonPressed = false;

String

A string is text.

name = "FreedomSTEM"
message = "Ready to blink"
String name = "FreedomSTEM";
String message = "Ready to blink";

List or array

A list or array holds multiple values in order.

colors = ["red", "yellow", "green"]
pins = [0, 1, 2]
String colors[] = {"red", "yellow", "green"};
int pins[] = {0, 1, 2};

Dictionary or object-style data

This is useful when you want one thing to hold several named values.

player = {
    "name": "Person",
    "score": 12,
    "ready": True
}
struct Player {
  String name;
  int score;
  bool ready;
};

Player player = {"Person", 12, true};

Variables and naming

Good variable names make code much easier to read.

Better examples:

Harder-to-read examples:

Short names are not always wrong, but clear names help a lot when you come back later.

Scope

Scope means where a variable exists and where you are allowed to use it.

A variable made at the top level is available in more places. A variable made inside a function stays inside that function.

That matters because two variables can have the same name in different places, but they are not always the same variable.

count = 0
message = "ready"

def add_point():
    global count
    local_only = 1
    count = count + 1
    # local_only only exists inside this function
int count = 0;
String message = "ready";

void addPoint() {
  int localOnly = 1;
  count = count + 1;
  // localOnly only exists inside this function
}

Here is the main idea:

Scope matters because it helps you keep code organized. It also helps prevent one part of a program from accidentally changing something that belongs somewhere else.

Loops

A loop repeats instructions.

That is important in electronics because a board often needs to keep checking buttons, updating lights, and reacting over and over.

Infinite loop

while True:
    print("still running")
void loop() {
  Serial.println("still running");
}

Counted loop

for i in range(5):
    print(i)
for (int i = 0; i < 5; i++) {
  Serial.println(i);
}

Conditions

A condition lets the program choose what to do.

Examples:

if button_pressed:
    print("Go")
else:
    print("Wait")
if (buttonPressed) {
  Serial.println("Go");
} else {
  Serial.println("Wait");
}

Functions

A function is a named block of code that does one job.

Functions help because they:

def blink_once():
    print("blink")
void blinkOnce() {
  Serial.println("blink");
}

What GPIO means

GPIO stands for General Purpose Input/Output.

That means a pin can be used in a general way instead of doing only one fixed job.

A GPIO pin can be used as:

Examples:

HIGH and LOW

When a pin is being used as a digital output, it is set to one of two states:

For beginner projects, a good way to think about that is:

In many simple LED projects:

That depends on how the circuit is wired, but for this kit that is the main pattern you will see.

Input vs output pins

If a pin is set as an input, the board listens.

If a pin is set as an output, the board sends a signal.

That is why the same pin can do different jobs depending on the code.

from machine import Pin

led = Pin(0, Pin.OUT)
button = Pin(1, Pin.IN, Pin.PULL_UP)
void setup() {
  pinMode(0, OUTPUT);
  pinMode(1, INPUT_PULLUP);
}

Digital, analog, and PWM

These three words sound similar at first, but they describe different kinds of signals.

Digital

A digital signal uses clear states.

For the projects in this kit, that means:

Examples:

Analog

An analog value can change smoothly across a range instead of jumping between just two states.

Examples:

The RP2040 can read analog values on certain pins, but that is not the focus of this kit.

PWM

PWM stands for Pulse Width Modulation.

PWM uses a digital pin, but it switches that pin on and off so quickly that the result can feel more like an analog change.

That is why PWM is useful for things like:

So even though PWM is built from fast digital switching, it can create effects that look smooth.

Common extra jobs a GPIO pin can do

Many RP2040 pins can also do more specialized jobs, including:

For beginner projects, you will use pins as simple digital input or output pins.

That means:

Those extra systems are useful later when you connect more advanced parts, but simple input and output work fine with plain GPIO by itself.

For this kit, we will keep it simple:

RP2040-Zero pin guide

The RP2040 chip has many functions, but the RP2040-Zero board brings a smaller set of easy-to-reach pins out to the edges. The list below focuses on the pins most people will actually use on the board headers.

Power and ground pins

Pin What it is for Beginner use
5V / VBUS 5-volt power from USB or external 5V input Powering the board
3V3 regulated 3.3V power Powering 3.3V parts
GND ground reference The return path for almost every circuit

Digital GPIO pins

Pin What it can do Good beginner use
GP0 digital I/O, PWM, UART, I2C, SPI options LED, button, general output
GP1 digital I/O, PWM, UART, I2C, SPI options LED, button, general output
GP2 digital I/O, PWM, UART, I2C, SPI options LED, button, general output
GP3 digital I/O, PWM, UART, I2C, SPI options LED, button, general output
GP4 digital I/O, PWM, UART, I2C, SPI options LED, button, general output
GP5 digital I/O, PWM, UART, I2C, SPI options LED, button, general output
GP6 digital I/O, PWM, UART, I2C, SPI options LED, button, general output
GP7 digital I/O, PWM, UART, I2C, SPI options LED, button, general output
GP8 digital I/O, PWM, UART, I2C, SPI options LED, button, general output
GP9 digital I/O, PWM, UART, I2C, SPI options LED, button, general output
GP10 digital I/O, PWM, UART, I2C, SPI options LED, button, general output
GP11 digital I/O, PWM, UART, I2C, SPI options LED, button, general output
GP12 digital I/O, PWM, UART, I2C, SPI options LED, button, general output
GP13 digital I/O, PWM, UART, I2C, SPI options LED, button, general output
GP14 digital I/O, PWM, UART, I2C, SPI options LED, button, general output
GP15 digital I/O, PWM, UART, I2C, SPI options LED, button, general output

Analog-capable pins

Pin What it can do Good beginner use
GP26 / ADC0 digital I/O, analog input, PWM reading analog sensors later on
GP27 / ADC1 digital I/O, analog input, PWM reading analog sensors later on
GP28 / ADC2 digital I/O, analog input, PWM reading analog sensors later on
GP29 / ADC3 digital I/O, analog input, PWM advanced analog reading and extra GPIO use

A simple way to remember the pins

You do not need to memorize every special feature right now.

A good beginner way to think about the board is:

Good beginner habits with GPIO

Final takeaway

Programming and circuits fit together really well.

Once those ideas click, the projects in this kit start to make much more sense.