# Week 1 - Electrical / Software

## Overview

Welcome to the Electrical &amp; Software Onboarding for the 2026-2027 school year!

## Goals

- **Learning**
- What is a Schematic / How to read a Schematic
- How does a microcontroller control hardware?

- **Practical**
- Breadboarding a circuit
- Running and debugging Arduino/ C++ code
- Managing software dependencies and reading software documentation


## Circuit Breadboarding

**Reading a Circuit Schematic:**

A schematic is just a logical and visual representation of the circuit. Below are a bunch of circuit symbols you may see on your schematic:

![](https://wiki.soonerrobotics.org/uploads/images/gallery/2026-09/embedded-image-282jkw8y.png)

The schematic you'll be using to construct the project is found below:

[![image.png](https://wiki.soonerrobotics.org/uploads/images/gallery/2026-09/scaled-1680-/image.png)](https://wiki.soonerrobotics.org/uploads/images/gallery/2026-09/image.png)

Use the schematic to construct the circuit on your breadboard. Once completed, you should have something similar to below:

[![Finished Breadboard.jpg](https://wiki.soonerrobotics.org/uploads/images/gallery/2026-09/scaled-1680-/finished-breadboard.jpg)](https://wiki.soonerrobotics.org/uploads/images/gallery/2026-09/finished-breadboard.jpg)

Once you have your circuit constructed, you're now ready to install and upload your project's firmware.

## Downloads

**Arduino:**

Go [here](https://web.archive.org/web/20250912193054/https://www.arduino.cc/en/software/) and download the version of the arduino IDE for your operating system (Windows, OSX, linux).

![](https://wiki.soonerrobotics.org/uploads/images/gallery/2026-09/embedded-image-wojzykyi.png)

**Pico board support:**

We'll be using the **Elegoo Uno R3** for onboarding. <span style="background-color: rgb(251, 238, 184);">To develop on the uno, you need to add an additional board manager URL to the Arduino IDE.</span>

<span style="background-color: rgb(251, 238, 184);">Go [here](https://web.archive.org/web/20250912193054/https://github.com/earlephilhower/arduino-pico) and scroll to the installation section. Follow the short directions there.</span>

<span style="background-color: rgb(251, 238, 184);">In the boards manager tab, search for these two libraries and install them</span>

## Compilation

Select the Uno R3:

Use the Arduino IDE to select the Uno R3 as the compilation target.

<span style="background-color: rgb(251, 238, 184);">\[IMAGE\]</span>

Connect the Uno R3 to your computer using a micro-usb cable. You should see this drop down turn bold.

<span style="background-color: rgb(251, 238, 184);">\[IMAGE\]</span>

**Verifying Source Code:**

Copy this skeleton code into an arduino sketch file:

```c++
const int TRIG_PIN = 11;
const int ECHO_PIN = 12;
const int LED_PIN = 3;        // warning LED (on/off)
const int BRIGHT_LED_PIN = 6; // brightness LED (must be a ~ pin)
const int DISTANCE_THRESHOLD = 5;

float duration_us, distance_cm;
int brightness;

void setup() {
  Serial.begin(9600);
  pinMode(TRIG_PIN, OUTPUT);
  pinMode(ECHO_PIN, INPUT);
  // FIX ME #1
  pinMode(BRIGHT_LED_PIN, OUTPUT);
}

void loop() {
  // generate 10-microsecond pulse to TRIG pin
  digitalWrite(TRIG_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN, LOW);

  // measure duration of pulse from ECHO pin
  duration_us = pulseIn(ECHO_PIN, HIGH);
  distance_cm = 0.017 * duration_us;

  // warning LED
  if (distance_cm < DISTANCE_THRESHOLD)
    digitalWrite(LED_PIN, HIGH);
  else
    digitalWrite(LED_PIN, LOW);

  // brightness LED — gets brighter as object gets closer
 brightness = map(distance_cm, 2, 30, 255, 0);
 brightness = constrain(brightness, 0, 255);
  analogWrite(BRIGHT_LED_PIN, brightness);

  Serial.print("distance: ");
  Serial.print(distance_cm);
  Serial.print(" cm  |  brightness: ");
  Serial.println(brightness);

  delay(500);
}
```

This file contains `const` declarations

Edit the `setup()` function and replace line 14 with the following:

`pinMode(LED_PIN, OUTPUT);`

<span style="background-color: rgb(251, 238, 184);">Click the check mark at the top left of the IDE to check for compilation errors. If your program compiles correctly you should see this output.</span>

<span style="background-color: rgb(251, 238, 184);">\[Need to Test\] Flashing Pico 2:</span>

<span style="background-color: rgb(251, 238, 184);">Click the arrow at the top left of the IDE to flash the Pico 2. If flashing doesn't work, you may need to unplug the Pico 2 and hold the BOOTSEL button while reconnecting the micro-usb cable.</span>

<span style="background-color: rgb(251, 238, 184);">If your flash is successful, you should see this output, and LED1 should be turned on.</span>