Team 1

Unit Converter & Physics Constants

Build a universal unit converter app that converts between length, mass, temperature, speed, and time units. Also includes a searchable reference table of important physics constants.

🎯 Learning Goals

  • Master Sl unit system and dimensions
  • Understand Conversion factors and Base Units
  • Learn key physical constants (c, G, h, k)
  • Implement dropdown selection and conditional math logic

🌎 Why This Matters

Unit conversion is critical in real-world science. In 1999, NASA lost a $125 million Mars orbiter because one team used imperial units while another used metric! Precision in units is literally the difference between success and disaster.

📖Understanding Units & Measurement

Theory Masterclass
"

Physics is built on measurements. Every measurement has a number and a unit. Converting between units is one of the most fundamental skills in physics. SI Units (International System): • Length: meter (m) • Mass: kilogram (kg) • Time: second (s) • Temperature: Kelvin (K) • Current: Ampere (A) Common Conversions: Length: 1 km = 1000 m, 1 m = 100 cm, 1 mile = 1.609 km, 1 inch = 2.54 cm Mass: 1 kg = 1000 g, 1 pound = 0.4536 kg Temperature: °C to °F = (C × 9/5) + 32, °C to K = C + 273.15 Speed: 1 km/h = 0.2778 m/s, 1 mph = 1.609 km/h Important Constants: Speed of light: c = 3 × 10⁸ m/s Gravitational acceleration: g = 9.8 m/s² Planck's constant: h = 6.626 × 10⁻³⁴ J·s Boltzmann constant: k = 1.381 × 10⁻²³ J/K Avogadro's number: Nₐ = 6.022 × 10²³ mol⁻¹

Mathematical Foundation

fx°C to °F: F = (C × 9/5) + 32
fx°F to °C: C = (F - 32) × 5/9
fx°C to K: K = C + 273.15
fxkm/h to m/s: multiply by 5/18
fxm/s to km/h: multiply by 18/5

🎨Part A — Designer View (UI Design)

Open MIT App Inventor → Switch to Designer view. Follow each step below to build the interface.

1

Set up with category tabs

Title: "Unit Converter" Add HorizontalArrangement with category buttons: "Length", "Mass", "Temperature", "Speed", "Constants" Each shows its own panel.

2

Create the converter layout

For each category panel: - TextBox for input value - Spinner (dropdown) for "From Unit" - Spinner for "To Unit" - Button: "Convert" - ResultLabel showing the converted value For Spinners, use the ListPicker or Spinner component. Populate with unit options for each category.

3

Length units Spinner options

Add these options to the Length Spinner: "Meter", "Kilometer", "Centimeter", "Millimeter", "Mile", "Yard", "Foot", "Inch"

4

Mass units Spinner options

"Kilogram", "Gram", "Milligram", "Pound", "Ounce", "Ton"

5

Create Constants panel

Add a ListView named ConstantsList. Populate it with formatted constant entries. When a user taps a constant, show its full details in a Label below.

🧩Part B — Blocks View (Logic & Calculation)

Switch to Blocks view. Now add the logic that makes your app actually work.

1

Create master conversion logic

Strategy: Convert everything to a BASE UNIT first, then convert to the target unit. For Length: Base = Meter - If from Kilometer: value × 1000 → Meter - If from Centimeter: value / 100 → Meter - Then from Meter to target unit This way you only need to know each unit's relationship to ONE base unit.

2

Build Length converter

Create procedure "convertLength" with parameters: value, fromUnit, toUnit Step 1: Convert to meters (base unit) if fromUnit = "Kilometer" → meters = value × 1000 if fromUnit = "Centimeter" → meters = value / 100 if fromUnit = "Millimeter" → meters = value / 1000 if fromUnit = "Mile" → meters = value × 1609.34 if fromUnit = "Foot" → meters = value × 0.3048 if fromUnit = "Inch" → meters = value × 0.0254 if fromUnit = "Meter" → meters = value Step 2: Convert from meters to target if toUnit = "Kilometer" → result = meters / 1000 ... (reverse of above)

3

Build Temperature converter

Temperature is special — it's not just multiplication: °C to °F: result = (value × 9 / 5) + 32 °F to °C: result = (value - 32) × 5 / 9 °C to K: result = value + 273.15 K to °C: result = value - 273.15 °F to K: First convert to °C, then to K K to °F: First convert to °C, then to °F

4

Build Speed converter

Base unit: m/s km/h to m/s: × (5/18) mph to m/s: × 0.44704 knot to m/s: × 0.5144 Convert to m/s first, then to target unit.

5

Build Mass converter

Base unit: Kilogram Gram to kg: ÷ 1000 Milligram to kg: ÷ 1000000 Pound to kg: × 0.4536 Ounce to kg: × 0.02835 Ton to kg: × 1000

6

Populate Constants list

When Screen1.Initialize: Set ConstantsList elements to a list of strings: "Speed of Light: 3 × 10⁸ m/s" "Gravitational Acceleration: 9.8 m/s²" "Planck's Constant: 6.626 × 10⁻³⁴ J·s" "Boltzmann Constant: 1.381 × 10⁻²³ J/K" "Avogadro's Number: 6.022 × 10²³ mol⁻¹" "Charge of Electron: 1.6 × 10⁻¹⁹ C" "Universal Gas Constant: 8.314 J/(mol·K)" ... and more

7

Format the result nicely

Display: value + " " + fromUnit + " = " + result + " " + toUnit Round the result to 4 decimal places to avoid ugly floating point numbers. Use: round(result × 10000) / 10000

🧪Testing Your App

  • 1 km = 1000 m, 1 mile = 1.609 km
  • 100°C = 212°F = 373.15 K
  • 0°C = 32°F = 273.15 K
  • Speed of light: 3×10⁸ m/s = 1.08×10⁹ km/h
  • 1 pound = 0.4536 kg

🚀Bonus Challenges

Extra credit — impress your instructor

  • Add a 'Favorite Constants' feature using TinyDB for quick access
  • Add area and volume unit conversion
  • Add a search/filter for the constants list
  • Show conversion formulas alongside the result