TerraSync.
technical implementation
TerraSync · Technical implementation

Circuit design and firmware

A closer look at the physical computing layer behind TerraSync, including the circuit architecture, resistor calculations, Arduino logic, and serial communication that connects the lamp to Unity.

Physical to digital

One synchronized feedback loop

The Arduino reads ambient light and button input, controls the lamp LEDs, and sends a compact serial message to Unity so the physical and digital environments remain in the same state.

Sense
Process
Light
Sync
01 · Components

A deliberately small hardware system.

TerraSync uses a minimal set of components: one sensor, one physical control, and three LEDs that work together to create a calm ambient response.

Arduino UnoHandles sensor reads, LED output, and serial communication with Unity.
Photoresistor (LDR)Analog input on A0. Reads ambient brightness from 0–1023.
Push buttonDigital input on pin 2 using INPUT_PULLUP. Controls focus-state changes.
White LEDPWM pin 9. Creates the primary diffused lamp glow.
Yellow LEDPWM pin 10. Adds a warm amber tone to the lamp.
Blue LEDPWM pin 11. Adds a cool undertone for balanced lighting.
220Ω resistors ×3Limits current for each LED and keeps the circuit within safe operating range.
10KΩ resistorCreates the voltage divider used for the photoresistor reading.
02 · Circuit design

The enclosure was built around a shared, compact circuit.

All components share one ground rail. The button relies on the Arduino’s built-in pull-up resistor, while the photoresistor uses a 10KΩ voltage divider and each LED has an independent current-limiting resistor.

TerraSync circuit schematic
Schematic overview. PWM pins 9, 10, and 11 support smooth LED brightness changes through analogWrite().
TerraSync breadboard circuit
Assembled circuit. Alligator clips extend the photoresistor and button outside the breadboard so both controls can sit flush with the enclosure.
03 · Resistor calculations

One standard resistor value simplified the build.

Using R = (Vs − Vf) / I, I calculated the safe resistance for each LED, then selected 220Ω as a shared standard value that kept every LED below its rated current.

LEDForward voltageTarget currentCalculated resistanceChosen resistance
White3.2 V20 mA~90 Ω220 Ω
Yellow2.0 V20 mA~150 Ω220 Ω
Blue3.2 V20 mA~90 Ω220 Ω

Why 220Ω? It is the nearest common resistor value that safely limits current for all three LED types. Using the same value also reduced wiring complexity without creating a meaningful loss in brightness.

Handwritten TerraSync resistor calculations
Handwritten Ohm’s law calculations, including a worked example for the photoresistor voltage divider at medium ambient brightness.
04 · Arduino firmware

The firmware translates room conditions into synchronized behavior.

Each loop reads the sensor and button state, maps ambient brightness to LED output, and sends a compact serial string that Unity can parse in real time.

TerraSync.inoArduino C++
/*
  Valentina Filizola
  TerraSync — HCDE 439 Final Project
*/

// Pin definitions
const int lightSensorPin = A0;
const int buttonPin = 2;

// LED pins
const int led1 = 9;
const int led2 = 10;
const int led3 = 11;

void setup() {
  Serial.begin(9600);
  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
}

void loop() {
  int lightValue = analogRead(lightSensorPin);
  int buttonState = digitalRead(buttonPin);

  int buttonPressed = (buttonState == LOW) ? 1 : 0;
  int constrainedLight = constrain(lightValue, 0, 600);

  // Invert the range so a darker room creates brighter LEDs
  int brightness = map(constrainedLight, 0, 600, 255, 0);

  analogWrite(led1, brightness);
  analogWrite(led2, brightness);
  analogWrite(led3, brightness);

  // Unity receives strings such as: "L:512,B:0"
  Serial.print("L:");
  Serial.print(lightValue);
  Serial.print(",B:");
  Serial.println(buttonPressed);

  delay(20);
}
05 · In operation

The complete sensing loop responds in real time.

Covering the photoresistor simulates a darker room, causing the LEDs to brighten while the Unity environment shifts into its night state. The button state is transmitted through the same serial stream.

TerraSync circuit and Unity scene operating together
The working prototype demonstrates sensing, ambient light response, focus-state control, and physical–digital synchronization.