Mission Status Report
The emergency lights cast eerie shadows across the cramped command center as you float weightlessly in the ship's dim interior. Your breath fogs the helmet visor slightly as you review the overnight diagnostics on your tablet. The good news? Oxygen levels are steady, life support is functioning, and most importantly—the solar panels are working. Your makeshift battery monitoring system from yesterday is paying dividends.
But as you stare at the raw numbers streaming across your screen, a knot forms in your stomach. The photoresistor readings are just that—raw numbers. 150... 234... 89... What do they actually mean? How much power do you really have left? In the vast emptiness of space, every percentage point of battery power could mean the difference between powering the communication array to signal for help, or drifting silently into the cosmic void.
Today's mission is critical: transform those cryptic sensor readings into meaningful information. You need to create a proper battery percentage display—something that shows you exactly where you stand in this fight for survival. The ship's computer hums quietly around you, waiting for your commands. It's time to dig deeper into the HERO Board's language and craft the code that could save your life.
Outside your small porthole, distant stars twinkle against the absolute darkness. Each one represents hope—if only you can keep the power flowing long enough to reach one of them.
What You'll Learn
When you complete today's mission, you'll be able to:
- Transform raw sensor data into meaningful percentages that show your exact battery level
- Use the += operator to efficiently add values to variables over time
- Create your own custom functions to organize code and eliminate repetition
- Understand different data types like unsigned integers and why choosing the right one matters
- Build a realistic battery charging simulation that responds to light levels
- Prevent battery overcharging by capping values at maximum capacity
By the end of this lesson, your photoresistor won't just give you numbers—it'll give you hope. You'll know exactly how much power you have left for your escape.
Understanding Battery Monitoring Systems
Think about your smartphone's battery indicator. When it shows "47%", it's not just displaying a raw voltage reading—it's converting sensor data into meaningful information you can understand. That percentage tells you exactly how much power you have left and whether you need to find a charger soon.
Your stranded spacecraft faces the same challenge, but the stakes are much higher. Yesterday, your photoresistor gave you raw numbers like 150 or 300. But what does that actually mean for your survival? Is 300 good? Is 150 dangerously low? Without context, these numbers are as useful as a broken compass.
Real spacecraft use sophisticated power management systems. The International Space Station, for example, has massive solar arrays that charge batteries during the sunlit portions of its orbit. These batteries must power everything during the 45-minute periods when Earth blocks the sun. Mission control continuously monitors battery levels to ensure astronauts never lose life support.
Today, you'll build a similar system for your emergency situation. Your photoresistor will act like a simplified solar panel sensor, measuring available light for charging. But instead of displaying raw numbers, you'll create code that converts these readings into battery percentages—information you can actually use to make life-or-death decisions.
The key insight is that your microcontroller excels at mathematical calculations. While humans struggle with quickly converting 37,500 out of 50,000 into a percentage, your HERO Board does it instantly. You just need to teach it the formula: (current charge ÷ maximum capacity) × 100 = percentage.
Wiring - Using Yesterday's Circuit
Great news! Today's mission uses the exact same circuit you built yesterday. Your photoresistor setup is already perfect for battery monitoring.

Why this circuit works for battery simulation:
- Photoresistor (light sensor): Acts like your ship's solar panel sensor, detecting available light for charging
- 10kΩ resistor: Creates a voltage divider that gives us measurable values between 0-1023
- Analog pin A0: Reads the voltage level and converts it to a number your code can use
- 5V and GND connections:
This is lesson 8 of 31 in 30 Days Lost in Space — a professionally produced Arduino course taught by Dr. Greg Lyzenga (NASA JPL scientist, Harvey Mudd professor). Each lesson features cinematic-quality video produced with a 20-30 person professional crew.
All video lessons are free to watch. Get the kit at craftingtable.com — $100 with a 30-day money-back guarantee.