30 Days Lost in Space: Week 1
I am going through the Inventr.io 30 Days Lost in Space challenge. I bought this kit a couple of years ago and it's been on my to-do list for quite some time, so now is that time. It's meant for kids to learn some coding and hardware/circuitry basics. Like I've done with some other courses that I've taken, I'll track my progress through the 30 days on this blog. The programming is done in the Arduino Language, which is built on top of C++. This programming language is new to me, though I suspect that a lot of the fundamental programming concepts will transfer over from JavaScript. Arduino compiles directly into the machine code that runs on the microcontroller.
Day 0: Prologue - 11/1/2025
Inventr.io provided a Google Doc with the various solutions for days 1 through 30, along with some general AI personality and knowledge files. I created these as a Gemini Gem. It's kinda funny for an AI companion, a little bit snarky, but also an interesting, modern digital companion that I can ask questions of along the way.
Day 1: Incoming Broadcast from InventrCorp - 11/1/2025
Some install required here - had to download the Arduino IDE and a driver for the Inventr.io Hero Arduino. Connected the Arduino to the computer via USB, selected the Arduino UNO board and the USB port. Ran the Blink basic example to test that everything is connected properly.
Here's the code from Blink.ino that we are running:
void setup() {pinMode(LED_BUILTIN, OUTPUT);}void loop() {digitalWrite(LED_BUILTIN, HIGH);delay(1000);digitalWrite(LED_BUILTIN, LOW);delay(1000);}
There's a button to compile the code in the IDE, which will warn if it finds any errors. There's also a button to upload the compiled code to the Arduino, which will run the compiled code.
setup() and pinMode()
The setup() function block runs once when the program first starts. It sets up variable definitions and initial tasks. In this case, the sole contents is: pinMode(LED_BUILTIN, OUTPUT).
The pinMode() assigns a mode to a pin. Every digital pin on the Arduino board must have its mode set within the setup() function block before we can use it.
LED_BUILTIN is the Pin Number that we are assigning a mode to. This one is a built-in LED that is connected to pin 13 on the Arduino UNO. In our case, pinMode(LED_BUILTIN, OUTPUT) is functionally the same as pinMode(13, OUTPUT). However, the built-in LED might be on a different pin on other Arduino boards. Hardcoding it to digital pin 13 might break, but using the LED_BUILTIN constant allows our program to run on different programs where the built-in LED is on a different pin number.
Lastly, OUTPUT in pinMode(LED_BUILTIN, OUTPUT) is the mode that we are setting the LED_BUILTIN pin to. There are three pin modes available on the Hero microcontroller: OUTPUT, INPUT, and INPUT_PULLUP. I think that these other modes will get explored throughout the 30 Days Lost in Space course, so I won't go into them here. In this case, by specifying that the LED_BUILTIN pin's mode is OUTPUT, we want that pin to send an electrical signal out. In this case, we want the microcontroller to control an external component, like an LED (turning it off and on).
loop(), digitalWrite(), and delay()
After setup() is run, the program jumps to loop(), which is run repeatedly as long as the board is powered on.
digitalWrite(LED_BUILTIN, HIGH); and digitalWrite(LED_BUILTIN, LOW); are setting the LED_BUILTIN PIN to specific states, HIGH and LOW. In this case, HIGH is 5 Volts and LOW is 0 Volts.
delay() tells the program to do nothing for a specified number of milliseconds. In the case of delay(1000), this is one second. Cool.
Day 2: It's Really Dark in Here - 11/2/2025
Breadboard
A Breadboard is a piece of hardware to experiment with circuit design without having to solder. This means you can reposition your circuit components without having to desolder and resolder them.
Some parts of the breadboard:
- terminal strip: the larger portion on the interior of the breadboard. The holes here are interconnected and where we can connect LEDs, resistors, and the Hero board.
- bus strips: used for power supply connections. The red line indicates a connection to the positive voltage, and the blue (sometimes black) line indicates a connection to the ground.
LEDs
An LED or light emitting diode is a type of diode that emits light when a current passes through it. In one direction, it allows the current to flow and emits light. In the other direction, it blocks the current.
- Two paths:
- one for current to flow
- one for current to be blocked.
- Di = two, ode = path, diode.
All diodes have a positive side, called the Anode and a negative side, called the Cathode. Usually the longer lead is the Anode and the shorter lead is the Cathode. The flat edge of the bulb on some LEDs also indicates the Cathode side.
LEDs are great for DIY electronics because of their low energy usage. However, we need to limit the amount of current flowing through the LEDs to help prevent them from burning out, and we do so using resistors.
Resistors
A Resistor resists the flow of electric current. Just like a narrow road slows down traffic, a resistor slows down the flow of electricity. The amount of resistance is measured in units called Ohms (Ω).
- The higher the Ohm Ω value, the more it resists the current.
Software
On the code side of things, today's lesson treads some of the same ground that yesterday's did, but also gives some brief definitions for things like code comments, variables, and integers. It digs into the #include "Arduino.h" line (which includes a lot of basic Arduino function definitions, like the pinMode and digitalWrite functions). Our program is updated to the following:
#include "Arduino.h"#define CABIN_LIGHTS_PIN 12void setup() {pinMode(CABIN_LIGHTS_PIN, OUTPUT);}void loop() {digitalWrite(CABIN_LIGHTS_PIN, HIGH);delay(1000);digitalWrite(CABIN_LIGHTS_PIN, LOW);delay(100);}
This is very similar to the code we saw on Day 1, except that instead of setting the mode and controlling the built-in LED pin, we are defining a new pin, pin 12, with the CABIN_LIGHTS_PIN variable. We then use digitalWrite() to turn CABIN_LIGHTS_PIN on and off, split up between one second and 100 milliseconds.
On its own, this doesn't do anything, this is just the software side of things. We need to handle the hardware as well.
Hardware
We utilize two male-to-male Jumper Wires to connect the Arduino to the breadboard. We use an orange jumper wire to run from pin 12 on the Arduino to pin A-14 on the breadboard. From there, the current passed through a 220 Ohm resistor before passing through the red LED. The Anode (+) of the LED is in pin J-14 and the Cathode (-) is in pin J-13. The second, black jumper wire runs from pin F-13 to the ground pin on the Arduino, completing the circuit.
Putting it together
So our code tells Arduino to send alternating 5 Volts and 0 Volts, separated by 1000 milliseconds and 100 milliseconds, out of pin 12 on the Arduino. This current passes through the 220 Ohm resistor, through the LED, activating and deactivating it, and then the current completes the circuit back to the ground pin on the Arduino. We are controlling hardware with software, and have achieved a blinking light.
Day 3: I'm worried about your battery levels - *11/3/2025
DIP switch, aka Dual In-line Package switch is a manual electric switch that is packaged in a group. The switches can be switched on or off. It's kind of like a tiny panel of lightswitches.
Each of the switches presents a binary - On / Off, High / Low, True / False, One / Zero, Yes / No, etc.
Hardware
- Ground or GND: zero voltage reference for all voltage sources in a circuit. Ground provides a path for electricity's return.
- Voltage or VCC: stands for Voltage at the Common Collector. This is the power supply source. It's the positive supply voltage.
- Pull-Down Resistor: makes sure the circuit behaves properly when the switch is off.
Inputs and Outputs
- Input: a message received by our Hero board. Could be from sensors, buttons, switches, etc.
- Output: signals sent out by the Hero board. Could be triggered by code conditions or other sensor readings.
Today, our DIP Switch is the input, telling the board whether the switch is On or Off. The LED is the output, responding by blinking or staying off.
Software
Concepts covered:
-
conditionals,
if,else/if,else -
=vs.== -
digitalRead()reads the digital signal off of a specific pin. If the DIP Switch is turned On, the digital signal should be a One / True / Yes; if the DIP Switch is turned Off, the digital signal should be a Zero / False / No.
How did it go?
Admittedly today's lesson was a bit of a struggle. The hardware portion of the video lesson doesn't quite match the provided diagram, and I'm not sure if that's contributing to the difficulty. I imagine the differences are minor, but to a total beginner with electrical circuits it's difficult for me to really know. They also kind of blew through the pull-down resistor explanation, so I will need to look that up further for a better explanation.
I did get the light working sort of. When I got it all wired together, the switch turns the light on and then off, but it doesn't always come back on after that. Reconnecting things does work, which I find a little bit odd. Again, I don't know enough about this stuff to diagnose. I just kind of have to trust that it's working well enough for me to continue with the rest of the course. A little bit discouraging, but I'll keep going.
Day 4: Cabin lighting - 11/4/2025
Basically adds two more lights, connects them to the other two switches on the DIP switch. Probably the most complex part of today's lesson is rewiring the breadboard. We use a common 5 volt bus for all three channels of the DIP switch, which then split off to each channel's Input pins and 10k resistors. And where we only had one Output pin / resistor / LED / ground cable, we now have 3 of them, all routed to the common ground bus.
For this exercise, I largely went about this on my own - copying the existing code and modifying it for the two new Inputs and Outputs, then following the diagram before watching the explainer video. I was a little more successful than I was yesterday! Still facing some issues with the original LED. Not sure if connections are just not as reliable on a breadboard as they would be if we soldered the circuit together.
Day 5: Creative day - 11/5/2025
Day 5 is the end of the first week, and is capped off with the first Creative Day. On Creative Days, there aren't a formal lessons, and instead we're encouraged to creatively expand on what we've learned so far and to implement it. There are a couple of suggested routes - one easy and one hard.
The suggested easy creative day idea is to add logic so that only one LED light can be lit up at a time.
The suggested hard creative day idea is to add three more lights, for a total of 6. Beyond completing the circuits for three more lights, this challenge also requires changing the DIP switch into a binary counter. This gives us eight options to play with:
0-0-0: all LEDs off
1-0-0: LED 1 on
1-1-0: LED 2 on
1-1-1: LED 3 on
0-1-0: LED 4 on
0-1-1: LED 5 on
0-0-1: LED 6 on
1-0-1: invalid input
The invalid input we can let fall through to the 0-0-0 case, turning all lights off. Or we can handle it some other way.
I didn't do either of these routes. Instead, I refactored the circuit to only have one blinking LED light, and the switches control how fast that LED light blinks:
1-0-0: 50ms
0-1-0: 100ms
0-0-1: 150ms
I then figured out all of the different combinations of these values:
0-0-0: LED off
1-0-0: 50ms
1-1-0: 150ms
1-1-1: 300ms
0-1-0: 100ms
0-1-1: 250ms
0-0-1: 150ms
1-0-1: 200ms
Here is my completed program:
#include "Arduino.h"// Define Light pinsconst byte STORAGE_LIGHTS_PIN = 11;// Define DIP Switch Pinsconst byte HALF_SWITCH_PIN = 2;const byte WHOLE_SWITCH_PIN = 3;const byte HALF_AND_WHOLE_SWITCH_PIN = 4;// Declare global variable to hold delay time// 'long' is a good data type for time in millisecondslong blinkDelay = 100;void setup() {// Configure LED Pins as OUTPUT PinspinMode(STORAGE_LIGHTS_PIN, OUTPUT);pinMode(HALF_SWITCH_PIN, INPUT);pinMode(WHOLE_SWITCH_PIN, INPUT);pinMode(HALF_AND_WHOLE_SWITCH_PIN, INPUT);}void loop() {if (digitalRead(HALF_AND_WHOLE_SWITCH_PIN) == HIGH && digitalRead(WHOLE_SWITCH_PIN) == HIGH && digitalRead(HALF_SWITCH_PIN) == HIGH) {blinkDelay = 300;} else if (digitalRead(HALF_AND_WHOLE_SWITCH_PIN) == HIGH && digitalRead(WHOLE_SWITCH_PIN) == HIGH) {blinkDelay = 250;} else if (digitalRead(HALF_AND_WHOLE_SWITCH_PIN) == HIGH && digitalRead(HALF_SWITCH_PIN) == HIGH) {blinkDelay = 200;} else if (digitalRead(WHOLE_SWITCH_PIN) == HIGH && digitalRead(HALF_SWITCH_PIN) == HIGH) {blinkDelay = 200;} else if (digitalRead(HALF_AND_WHOLE_SWITCH_PIN) == HIGH) {blinkDelay = 150;} else if (digitalRead(WHOLE_SWITCH_PIN) == HIGH) {blinkDelay = 100;} else if (digitalRead(HALF_SWITCH_PIN) == HIGH) {blinkDelay = 50;} else {blinkDelay = 0;}if (blinkDelay > 0) {digitalWrite(STORAGE_LIGHTS_PIN, HIGH);delay(blinkDelay);digitalWrite(STORAGE_LIGHTS_PIN, LOW);delay(blinkDelay);} else {digitalWrite(STORAGE_LIGHTS_PIN, LOW);}}
Day 6: Time to fix the battery - 11/6/2025
Photoresistors: when they receive light, their resistance decreases, allowing current to pass, raising signal levels. In darkness, resistance increases, choking current, lowering signal levels. We can use this to simulate a solar panel.
A photoresistor is also known as a light-dependent resistor (LDR). Made of high-resistance semiconductor materials. When light hits the device, it absorbs light photons; this absorption process provides energy to the electrons, making them jump from valence bands to conduction bands. A photoresistor allows us to detect light.
Analog vs. Digital Signals
- Analog signals are continuous signals, sort of like a constantly-running dimmer for a light. This dimmer can be high or low, but there's always some kind of value within a given range. Analog signals are prone to noise and interference, making them hard to work with.
- Digital signals are discrete, and can only be in one of two states, represented by 0s or 1s. Digital signals are not prone to noise and interference, making them easier to work with.
Photoresistors provide an analog signal.
A0 Pin on Hero board
A0 is an analog pin. Because the photoresistor provides an analog signal, we need to connect it to an analog pin.
Arduino Serial Monitor
With the Serial Monitor, we can send and receive data to and from the Hero board. It can also be used to examine the state of variables. It can also monitor the readings from our photoresistor.
To access the Serial Monitor, we need to:
- Establish a serial communication with code
- Go to Tools -> Serial Monitor in Arduino IDE
analogRead():
- allows Hero to read analog signals
- measures voltage between zero (0V) and 1023 (5V)
Reading vs. Writing
- Reading: taking data in
- In Arduino, reading is associated with sensors/inputs (like photoresistors)
- Write: sending data out
- In Arduino, writing is associated with actuators/outputs (LEDs, motors, etc.)
Today was another challenging day from the hardware side of things. The diagram was fairly straightforward, although it wasn't quite clear which resistor I should use. I asked the AI bot that had the instructional docs as context, and it suggested a 10k resistor. The instructional video mentioned a 220k resistor. Going with the 10k resistor, I couldn't really get the dynamic blinking LED. But switching to the 220k it worked much better. Admittedly there's a band code on the resistors that I could refer to but those things are just really hard for me to decipher, new as I am to all of this.
Oh, here was today's code:
#include "Arduino.h"const byte PHOTORESISTOR_PIN = A0;const unsigned int MIN_DELAY = 50;const unsigned int MAX_DELAY = 500;void setup() {pinMode(LED_BUILTIN, OUTPUT);pinMode(PHOTORESISTOR_PIN, INPUT);Serial.begin(9600);}void loop() {unsigned int light_value = analogRead(PHOTORESISTOR_PIN);Serial.print("Light value: ");Serial.print(light_value);static unsigned int darkest_light = light_value;static unsigned int brightest_light = light_value;if (light_value < darkest_light) {darkest_light = light_value;}if (light_value > brightest_light) {brightest_light = light_value;}unsigned int delay_value = map(light_value, darkest_light, brightest_light, MAX_DELAY, MIN_DELAY);Serial.print(", Delay value: ");Serial.println(delay_value);digitalWrite(LED_BUILTIN, HIGH);delay(delay_value);digitalWrite(LED_BUILTIN, LOW);delay(delay_value);}
Day 7: We still need to keep an eye on this - 11/7/2025
Today's lesson is more focused on software than hardware, specifically into how memory works in C++ and the Hero board. Some terminology:
- Bits:
- The smallest unit of data there is
- Binary (either
0or1) - Combine three digits for 8 unique integers
- Integers:
- Typical size of 16 bits
- Total range of + or - 32,768 bits
- Two integer types:
- Signed
- Unsigned
- Float:
- 32 bits
- Ex: "123.4567"
- Double:
- 64 bits
- Capable of 10^308
- Void:
- Used to define functions that don't give anything back
- Technically it returns void, but engineers decided they didn't need a return statement for emptiness
Today's mission is to write code logic to print the battery percentage using the Serial Monitor that we explored a bit yesterday. Here is today's code:
#include "Arduino.h"const byte PHOTORESISTOR_PIN = A0;const unsigned int BATTERY_CAPACITY = 50000;void setup() {pinMode(PHOTORESISTOR_PIN, INPUT);Serial.begin(9600);}unsigned int battery_level = 0;void loop() {if (battery_level < BATTERY_CAPACITY) {battery_level += analogRead(PHOTORESISTOR_PIN);if (battery_level > BATTERY_CAPACITY) {battery_level = BATTERY_CAPACITY;}}printBatteryChargeLevel();delay(100);}void printBatteryChargeLevel() {if (battery_level < BATTERY_CAPACITY) {Serial.print(((double)battery_level / (double)BATTERY_CAPACITY) * 100);Serial.println("%");} else {Serial.println("FULLY CHARGED");}}
Summary
So that's the first week or so of the 30 Days Lost in Space challenge. So far it's pretty fun. Looking forward to seeing where this goes and hopefully walking away with some confidence and inspiration to try out my own projects on the other end of the 30 days. The hardware stuff is a lot of fun when I can get it to work. Debugging it isn't as easy as software is though, and I'm not sure if the issues I run into are mistakes on my end (very likely) or the nature of working with a breadboard (as opposed to a PCB and soldering). I also like that they provided setup for an interactive AI companion. Other courses I've taken previously didn't have that (though the AI tech wasn't as developed or prevalent as it is now), and honestly it kind of sets a new bar for course polish for me. It's really nice to have something interactive that I can ask questions of (like I would an instructor or a TA in a real-life classroom) when I'm exploring new concepts and terminology.