You need to have an TinkerCAD Account. Go to https://www.tinkercad.com/join >> Click on "Create Personal Account" >> Sign in with Google.
Please Install Arduino IDE in your laptop. Go to https://www.arduino.cc/en/software to download and install the IDE.
You need to have an Arduino account to access the arduino cloud. To create account click here.
Download and install FreeCAD software. To download visit https://www.freecad.org/.
Install Bambu Studio. To download and install visit https://bambulab.com/en/download/studio.
Please make sure you have a USB Type A port in your laptop. If you dont have one please bring in a adapter eith USB A hub.
To build this project using block coding in Tinkercad, you need to use an If/Else logic block combined with a Mathematical Comparison block to evaluate the sensor readings.
The Logic Flow
Read: Look at the value coming from the sensor on analog pin A0.
Compare: Check if that number is less than (<) your threshold value (e.g., 500).
Act (If Dry): If the reading is less than 500, turn ON the LED on pin 13.
Act (Else/If Wet): If the reading is 500 or higher, turn OFF the LED on pin 13.
How to Build the Blocks in Tinkercad
1. Set Up the Condition (If/Else)
Go to the Control category (orange blocks).
Drag out the if / then / else block.
2. Add the Comparison
Go to the Math category (green blocks).
Drag the diamond-shaped comparison block [ 1 ] < [ 1 ] and drop it inside the if condition slot.
3. Read the Sensor
Go to the Input category (purple blocks).
Drag the read analog pin [A0] block.
Place it inside the first slot of your green comparison block.
Change the second slot number from 1 to 500 (your dry/wet threshold).
4. Control the LED
Go to the Output category (blue blocks).
Drag a set pin [13] to [HIGH] block and place it inside the then section (turns LED on if dry).
Drag another set pin [13] to [LOW] block and place it inside the else section (turns LED off if wet). [1]
What the Blocks Look Like (Visual Text)
text
if [ read analog pin A0 ] < [ 500 ] then
set pin 13 to HIGH
else
set pin 13 to LOW
end if
The value range represents how much moisture the sensor detects, mapped to a scale of 0 to 1023 because of the Arduino's internal hardware converter.
The 0 to 1023 Scale
The analog pin on an Arduino converts the sensor's voltage into a digital number between 0 and 1023.
0 to 200 (Very Dry): Represents low conductivity, meaning there is almost no water in the soil.
500 (The Threshold): Represents the midway point. It is a baseline choice to decide when soil crosses from "dry enough to need water" to "wet enough."
800 to 1023 (Very Wet): Represents high conductivity, meaning the sensor is fully submerged or in heavily saturated soil.
Tinkercad Simulator vs. Real Life
In Tinkercad, this number is a perfect digital simulation. In the real world, these numbers change based on your specific setup:
Soil Type / Condition Approximate Sensor Reading
Completely Dry Air / Bone Dry Soil Under 300
Ideal Moist Soil (Healthy Plant) 400 – 700
Pure Water / Muddy Saturated Soil Over 800
If you notice your LED turning on too early or too late, you can change that 500 threshold number in your code to fine-tune the system.
const int touchPin = 4; // GPIO4 (T0)
const int ledPin = 16; // GPIO16 for LED
const int threshold = 40; // Adjust based on serial readings
void setup() {
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
}
void loop() {
int touchValue = touchRead(touchPin);
Serial.println(touchValue);
if (touchValue < threshold) {
digitalWrite(ledPin, HIGH); // Turn LED on
} else {
digitalWrite(ledPin, LOW); // Turn LED off
}
delay(100);
}