Arduino is at the same time a hardware at the software, and open hardware: you can copy it, change it for free and open source doftware in a Integrater Development Environment (IDE). You have access to everything all the data and hardware components and all the software components and the source code (codigo font) producing the software. Is the opposite propietary cody and propietary hardware.

Arduino software is considered a C++ derivative and at the same time a Processing related software.

Processing is and open source software previous to Arduino software and compatible with Arduino, containing many open source Processing libraries of computer vision or Arduino as examples:

This is the Arduino code corresponding to my humidity project in the general project of the agriculture robotics, in this case my objective is measure the humidity of a plant and depending on the soil moisture or humidity a red LED will be switch on (low humidity)

Next step will be to change LEDS and to use water pump, relays to water the plant

My code for the YL-69 soil moisture sensor and LED is the following:



/*int it means integer variable corresponding to a integer number A0, 6 and 7 are integer numbers, A0 is a special case. Double forward slash means comment in Arduino lenguage. 
rainPin, greenLED and redLED are names of the variable invented in order to identify the PINS (connectors of the Arduino). 
For variable names we follow the camel case that is the firts letter of the firts name in lower cases and the second name in the first letter will be upper cases.
(other types or other posibilities convention  for writing variables are used in other languages are snake case: "for-exemple-this" and in camel case is this: "forExempleThis". 
It is imposible to start a variable name with a number or with especial character coresponding to keywords used in instructions.*/
/*Other types of variables in Arduino are boolean (true/false), byte (0-255), char (character -128- +127), int (-32768- +32767), long (very long numbers) and float 
(floating point numbers, Boolean, byte and char are 8 bits long, 2^8=256 differents values. Integer is 16 bits (2^16=65536) in length,and finally, long and float 
are 32 bits (2^32=4294967296) length. There are signed and unsigned variables, if the variable is signed the value is divided by 2 (exemple: 2^16=65536/2=32768
integer variables will go from -32768 to +32767, one number is 0 this is why I am reducing the las number by 1 unit). I can declare a long variable 
for mesuring miliseconds or microseconds, signed or unsigned? What is correct? Unsigned long time; means always positive for time.*/ 

//When I declare a variable I creat a space in the computer's memory with a name.
//It is interesting to declare variables of the right size.
//If I add before int the word const it makes impossible to change.
conts int rainPin = A0;
/*In Arduino uno there are six analog inputs of ten bits (1024 levels) and in ESP-32 there are 20 analog inputs of 12 bits (4096 levels). We are going to calculate the resolutions of the sensors and analog inputs, taking into account that Arduino uno is at 5V microcontroller and ESP-32 is a 3.3V microcontroller.
3.3V / 4096= 0.00080566406 x 1000 = 0.806mV, 5V / 1024 = 0.0048828125 x 1000 = 4.88mV. 
Level 0 is 0V in Arduino, level 1 is 4.88 mV, level 2 is 9.76 mV, level 500 is 2441 mV = 2.4V, level 1023 is 5V. Can I mesure 6mV? No, the solution is a better
ADC (Analog digital converter of more bits) for example, ADS 1115 i a ADC of 16 bits (2^16 = 65536 levels) 5V / 65536 x 1000 =0.08mV. The advantatge is that we are capable to detect more values (more accuracy). Raspberry PI v4 doesn't have any ADC that is any analog input, connecting ADS 1115 when is avaliable.
conts int greenLED = 6;
conts int redLED = 7;
// you can adjust the threshold value.
int thresholdValue = 1400;
/*A variable can be a global variable if it is defined at the begining of the code or local if it is defined imside a funtion or void block. If I do not assign
a initial value to a variable it will bw 0 as a default value.*/

void setup(){
/*Setup is a block of code or funtion including the general settings, for example if the pin is an input or an output, the initial values of my circuit the green 
LED will be OFF or LOW. In the pinMode function we use the previous global variaebles with known names, for example pinMode(rainPin, INPUT); is the same as  pinMode(A0, INPUT); because it is easier to understand because we give this variable name to the A0 pin because is the first analog INPUT in the Arduino.*/
/*Analog INPUT in Arduino Uno is a 10-bit analoh to digital converter (ADC) that means 2^10=1024 values from 0-1023. In ESP-32 microcontroller there are 12-bit ADC that means 2^12=4096 values from o-4095, in ADS1115 is 16-bit ADC that means 2^16=65536 values from 0-65535.
  pinMode(rainPin, INPUT); 
  pinMode(greenLED, OUTPUT);
  pinMode(redLED, OUTPUT);
  digitalWrite(greenLED, LOW);
  digitalWrite(redLED, LOW);
  Serial.begin(9600);
   /* digitalWrite means to write a two state value (HIGH, LOW, and some time in 0 and 1) in digital inputs, we need to define first the pin mode as 
   an INPUT and OUTPUT, deppending on the features fo the pin, for example; if the pin is A0, i can not put un digital, just analgoic, because from A0-A5 
   pin are pins that only are inputs values of 10 bits (1024 values).*/
    */Arduino: 5volts, ESP-32: 3.3volts.
  */ESP-32: Has 12 bits and 2^12=4096 values.
  */Resulotion capacity of distinguixin differents values are bigger ESP-32; 3,3/4096mV, Arduino;5/1024mV
   /* Serial.begin means serial communications between devices (microcontroller and PC) and the number is the speed in bits per second or bouds, other
   common speeds are: 9600, 57600, and 115200.*/
}

void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(rainPin);
  Serial.print(sensorValue);
  if(sensorValue < thresholdValue){
    Serial.println(" - Doesn't need watering");
    digitalWrite(redLED, LOW);
    digitalWrite(greenLED, HIGH);
  }
  else {
    Serial.println(" - Time to water your plant");
    digitalWrite(redLED, HIGH);
    digitalWrite(greenLED, LOW);
  }
  delay(500);
}
int greenLED = 6;
int redLED = 7;
// you can adjust the threshold value
int thresholdValue = 1400;

void setup(){
  pinMode(rainPin, INPUT);
  pinMode(greenLED, OUTPUT);
  pinMode(redLED, OUTPUT);
  digitalWrite(greenLED, LOW);
  digitalWrite(redLED, LOW);
  Serial.begin(9600);
}

void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(rainPin);
  Serial.print(sensorValue);
  if(sensorValue < thresholdValue){
    Serial.println(" - Doesn't need watering");
    digitalWrite(redLED, LOW);
    digitalWrite(greenLED, HIGH);
  }
  else {
    Serial.println(" - Time to water your plant");
    digitalWrite(redLED, HIGH);
    digitalWrite(greenLED, LOW);
  }
  delay(500);
}

This is the image of the circuit: