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

1. Screen Basics

• In the **Properties** panel (right) for **Screen1**. • Set **Title** to "Physics Unit Pro". • Set **AlignHorizontal** to Center. • Set **BackgroundColor** to dark grey.

2

2. Input and Selector

• Drag a **TextBox** (User Interface). Rename to 'ValueInput'. • Set **Hint** to "Enter number" and check **NumbersOnly**. • Drag a **ListPicker**. Rename to 'UnitPicker'. • In Properties, set **ElementsFromString** to "Meter to KM, KM to Meter, Celsius to Kelvin".

3

3. Action Button

• Drag a **Button**. • Rename it to 'ConvertBtn'. • Set Text to "CONVERT NOW". • Change **BackgroundColor** to Green.

4

4. Result Display

• Drag a **Label** to the bottom. • Rename to 'ResultLbl'. • Set **FontSize** to 22 and **TextColor** to Cyan.

🧩Part B — Blocks View (Logic & Calculation)

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

1

1. Switch to Blocks

• Go to the top right of your screen. • Click the **Blocks** button to leave the Designer and start building logic.

2

2. Handling the Selection

• Click **ConvertBtn** in the list. Drag the gold 'when ConvertBtn.Click' block. • Go to the **Control** drawer (Orange). Drag an 'if...then' block and snap it inside. • Go to the **Logic** drawer (Green). Drag the '=' block. • [if] [UnitPicker.Selection] [=] ["Meter to KM"].

3

3. The Mathematical Formula

• To turn meters into KM, we divide by 1000. • Click **ResultLbl**. Drag the green 'set ResultLbl.Text to' block. • Go to the **Math** drawer (Blue). Drag out the '/' (division) block. • Connect: [set ResultLbl.Text] to [ValueInput.Text] / [1000].

4

4. Adding More Units

• Use the blue gear icon on the 'if' block to add an 'else if'. • Add logic for "Celsius to Kelvin" by using the Blue **Math** [+] block. • Formula: [ValueInput.Text] + [273.15].

5

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)

6

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

7

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.

8

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

9

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

10

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