Lab set Program-7

 7. Develop a program to read the pH value of a various substances like milk, lime and water.

Objective

To develop a program that reads and classifies the pH value of various substances such as milk, lime water, and pure water using Arduino.
(Simulated using a potentiometer in Tinkercad since the actual pH sensor is unavailable.)


Learning Outcomes

After completing this experiment, students will be able to:

  1. Understand how a pH sensor works and its output behavior.

  2. Simulate sensor readings in Tinkercad using analog components.

  3. Map analog readings to real-world pH ranges (acidic, neutral, basic).

  4. Write Arduino code for data classification and serial monitoring.


Components (from Tinkercad Palette)

  • Arduino Uno board

  • Potentiometer (as pH sensor)

  • 3 LEDs (Red = Acidic, Green = Neutral, Blue = Basic)

  • 220 Ω resistors × 3

  • Breadboard

  • Jumper wires


Circuit Wiring (Exact)

  1. Potentiometer (pH Sensor substitute)

    • One outer leg → 5 V

    • Other outer leg → GND

    • Middle pin → A0

  2. LEDs

    • Red LED → Pin 9 (through 220 Ω resistor to GND)

    • Green LED → Pin 10 (through 220 Ω resistor to GND)

    • Blue LED → Pin 11 (through 220 Ω resistor to GND)




Arduino Sketch

int phPin = A0; int redLED = 9; int greenLED = 10; int blueLED = 11; float phValue = 0.0; void setup() { pinMode(redLED, OUTPUT); pinMode(greenLED, OUTPUT); pinMode(blueLED, OUTPUT); Serial.begin(9600); } void loop() { int sensorValue = analogRead(phPin); // Convert analog (0–1023) to pH scale (0–14) phValue = map(sensorValue, 0, 1023, 0, 14); Serial.print("Analog Reading: "); Serial.print(sensorValue); Serial.print(" | pH Value: "); Serial.println(phValue); // Classification if (phValue < 6.5) { // Acidic digitalWrite(redLED, HIGH); digitalWrite(greenLED, LOW); digitalWrite(blueLED, LOW); } else if (phValue >= 6.5 && phValue <= 7.5) { // Neutral digitalWrite(redLED, LOW); digitalWrite(greenLED, HIGH); digitalWrite(blueLED, LOW); } else { // Basic digitalWrite(redLED, LOW); digitalWrite(greenLED, LOW); digitalWrite(blueLED, HIGH); } delay(500); }

How It Works

  1. The potentiometer simulates different pH levels:

    • Turning it left → low analog value → acidic.

    • Middle position → around neutral (7).

    • Turning right → high value → basic.

  2. Arduino reads analog values from A0 (0–1023) and maps them to pH 0–14.

  3. The corresponding LED lights up:

    • Red → Acidic (e.g., milk, lemon juice)

    • Green → Neutral (e.g., pure water)

    • Blue → Basic (e.g., lime water, soap solution)

  4. pH values are displayed on the Serial Monitor.


Common Mistakes & Quick Fixes

IssueCauseFix
LEDs not glowingMissing resistor or wrong pin mappingVerify wiring and resistors
pH readings unstableLoose breadboard connectionRe-insert jumper wires
Wrong LED lightingReversed LED polarityLonger leg → digital pin side

Viva / Check-Your-Understanding

  1. What is the pH range of acidic, neutral, and basic substances?

  2. What is the function of a pH sensor?

  3. How did we simulate the pH sensor in Tinkercad?

  4. What are typical pH values of milk, water, and lime water?


Extensions (Mini-Tasks)

  • Display the pH value on an LCD instead of Serial Monitor.

  • Use a buzzer to alert when the sample is too acidic or too basic.

  • Expand to detect more categories (strong acid, weak acid, etc.).


Lab Record (Suggested Headings)

  1. Title

  2. Objective

  3. Components Used

  4. Circuit Diagram (Tinkercad screenshot)

  5. Arduino Code

  6. Output / Simulation Result

  7. Viva Questions & Answers

  8. Extensions



Tinkercad Link

https://www.tinkercad.com/things/2EPEgTk14FZ-labset-prog-7

Comments

Popular posts from this blog