Theory
7. Programming the sensors using Arduino ✨
Gear Motor with Arduino
🛠 Materials:
- 🎛 Arduino board
- ⚙️ Gear motor
- 🔌 Jumper wires
https://www.tinkercad.com/things/5Z8eGEdYjUJ-venu-arduino-hobby-gearmotor
📝 Explanation:
- In this experiment, we utilize the 🎛 Arduino board to control a ⚙️ gear motor attached to digital pin 2. The code programmed into the board designates pin 2 as an output, employing the “digital Write” function to toggle the motor on and off, introducing a delay of 2 seconds between each state alteration.
- Through this practical learning experience, you’re guided on how to program an Arduino board to manage the operations of a gear motor utilizing a transistor, offering a foundational insight into the application of transistors as switches for directing motors and other apparatuses.
Potentiometer with Arduino
🛠 Materials:
- 🎛 Arduino board
- 🎚 Potentiometer
- 🔌 Jumper wires
https://www.tinkercad.com/things/1No0vXsF4ob-arduionread-analog-voltage
📝 Explanation:
- This experiment involves the use of an 🎛 Arduino board to discern the analog value from a 🎚 potentiometer linked to analog pin A0. The uploaded code initiates serial communication with the computer and harnesses the “analogRead” function for gauging the potentiometer’s value.
- The potentiometer acts as a tunable resistor, its adjustment facilitated by the turning of its knob. It features three pins: the center pin serves as the output, while the two flanking pins connect to the input and ground. Establishing a connection of the potentiometer’s middle pin to analog pin A0 and the outer pins to 5V and GND crafts a voltage divider circuit, altering the output voltage in accordance with the knob’s position.
- This experiment imparts the method of employing an Arduino board to read the analog value of a potentiometer connected to analog pin A0, furnishing a rudimentary comprehension of potentiometer functionality and their utility as input mechanisms for modulating electronic circuit behavior.
🤖 Servo Motor with Arduino
📦 Materials:
- 🛠 Arduino board
- 🔄 Servo motor
- 🔌 Jumper wires
https://www.tinkercad.com/things/539PXV9PWQF-arduinoservo
📝 Explanation:
This experiment involves using an Arduino board to control a servo motor connected to digital pin 9. The Arduino code sets up the servo, attaches it to pin 9, and uses the “write” function to adjust the motor’s angle. Servo motors, equipped with three wires (power, ground, and signal), rotate to precise angles based on input signals. This project offers insight into servo motor operation and their applications in robotics and automation.
Moisture sensor with Arduino
Introduction: Moisture sensors are used to detect the amount of moisture in the soil. In this experiment, we will use an Arduino and a moisture sensor to read the moisture level of the soil and display it on the serial monitor.
📦 Materials:
- 🛠 Arduino board
- 💦 Moisture sensor
- 🔌 Jumper wires
https://www.tinkercad.com/things/0iQ4OoqaeTT-venu-arduino-soil-moisture-sensor
Results: As the moisture level of the soil changes, the value displayed on the serial monitor will change. The value will be higher if the soil is moist and lower if the soil is dry.
Conclusion: In this experiment, we learned how to use an Arduino and a moisture sensor to read the moisture level of the soil. This can be useful for gardeners and farmers to ensure their plants are getting the proper amount of water
Ultrasonic distance with Arduino
Introduction: Ultrasonic distance sensors use sound waves to measure the distance between an object and the sensor. In this experiment, we will use an Arduino and an ultrasonic distance sensor to measure the distance between the sensor and an object and display it on the serial monitor.
📦 Materials:
- 🛠 Arduino board
- 🔊 Ultrasonic distance sensor
- 🔌 Jumper wires
📝 Instructions:
- 🔗 Connect the ultrasonic sensor to the breadboard.
- 🔋 Attach VCC pin to the Arduino’s 5V.
- ⚫ Connect GND pin to Arduino’s GND.
- 📤 Link trigger pin to digital pin 12.
- 📥 Attach echo pin to digital pin 11.
- 💻 Open Arduino IDE and start a new sketch.
- 📚 Include the sensor’s library.
- 🚀 Initialize serial monitor at 9600 baud.
- 🔄 Trigger the sensor and calculate distance.
- 🖨 Print distance on the serial monitor.
- ⬆️ Upload the sketch and observe results.
https://www.tinkercad.com/things/bF9QqFIekKE-copy-of-ultrasonic
Results: As the ultrasonic distance sensor is moved closer or farther away from an object, the distance displayed on the serial monitor will change. The value displayed will be in centimeters.
Conclusion: In this experiment, we learned how to use an Arduino and an ultrasonic distance sensor to measure the distance between the sensor and an object. This can be useful for a variety of applications, such as detecting the presence of objects or measuring the height of water in a tank.
PIR motion sensor with Arduino
🛠 Materials:
- 🖥 Arduino board
- 🚶♂️ PIR motion sensor
- 💡 LED
- 🔌 Resistor
- 🧲 Jumper wires
📋 Instructions:
🔌➡️🖥 Connect the VCC pin of the PIR motion sensor to the 5V pin on the Arduino.
🔌➡️🖥 Connect the GND pin of the PIR motion sensor to the GND pin on the Arduino.
🔌➡️🖥 Connect the OUT pin of the PIR motion sensor to digital pin 2 on the Arduino.
💡🔌➡️🖥 Connect the long leg (positive) of the LED to digital pin 13 on the Arduino via a resistor.
💡🔌➡️🖥 Connect the short leg (negative) of the LED to the GND pin on the Arduino.
💻 Upload the following code to the Arduino:
💻 Open the Serial Monitor in the Arduino IDE to see the output.
👋 Move your hand in front of the PIR motion sensor to detect motion and observe the LED turning on and off accordingly.
🎉 Congratulations! You have successfully created an Arduino project that detects motion using a PIR sensor and controls an LED.
https://www.tinkercad.com/things/1VSIvVfGx0H-copy-of-pir-motion-sensor-with-arduino-blocks
Force sensor with Arduino
🛠 Materials Required:
- 🧠 Arduino Board
- 🔘 Force Sensor
- 💡 LED
- 🚥 Resistor (220 ohm)
- 🌈 Jumper Wires
📝 Instructions:
- 🔗 Connect the force sensor to the breadboard.
- ➕ Connect the positive terminal of the LED to digital pin 11 and the negative terminal to the ground with a resistor.
- 🔌 Connect the analog output pin of the force sensor to analog pin A0 on the Arduino board.
- 💻 Open the serial monitor in the Arduino IDE (Tools > Serial Monitor) to see the output of the force sensor.
- 🤏 Apply force to the sensor and observe the change in LED intensity and force values in the serial monitor.
🔍 Explanation:
- In this experiment, we are using a force sensor to control the intensity of an LED connected to the Arduino board.
- The force sensor measures the resistance change caused by the application of force.
- This resistance change is converted to an analog voltage that is read by the Arduino using analog pin A0.
- The map () function scales the force values from 0 to 1023 to LED intensity values from 0 to 255.
- The LED is controlled using digital pin 11 and a resistor to limit the current flowing through it.
- The Serial.println() function prints the force values in the serial monitor, allowing observation of the changes in force applied to the sensor.
https://www.tinkercad.com/things/lfSKRzIGYcQ-force-sensor
LDR with Arduino
📝 Introduction
- 🧪 In this experiment, we’ll be utilizing:
- 🖥️ An Arduino board
- 💡 An LED
- 🔗 A resistor
- 🌞 An LDR sensor
- 🎚️ The goal is to control the LED’s brightness based on the light intensity detected by the LDR.
🛠️ Materials Required
- 🖥️ Arduino board
- 💡 LED
- 🔗 220-ohm resistor
- 🌞 LDR sensor
- 🚪 Jumper wires
🔌 Circuit Diagram
- 🌞 Connect the LDR sensor to analog pin A0 on the Arduino.
- 💡➕ Connect the positive leg of the LED to digital pin 11 on the Arduino through a 220-ohm resistor.
- 💡➖ Connect the negative leg of the LED to the ground pin (GND) on the Arduino.
👩🔬 Procedure
- 🛠️ Set up the circuit as described, using a breadboard, Arduino board, LED, resistor, and LDR sensor.
- 💻 Open the Arduino IDE on your computer.
- ✨ Create a new sketch and input the provided code.
- 📤 Verify and upload the code to the Arduino board.
- 🖥️ Open the Serial Monitor to observe the sensor values.
- 🤚 Cover the LDR sensor to reduce light intensity and notice the LED getting brighter. Removing your hand dims the LED.
- 💡🔄 Experiment with different distances of a light source to see changes in LED brightness.
📊 Observations
- 📉 Light intensity inversely affects LED brightness: less light = brighter LED, and vice versa.
📚 Conclusion
- ✅ Successfully controlled LED brightness with an LDR sensor and an Arduino board.
- 💡 The experiment demonstrates a direct relationship between light intensity and LED brightness, paving the way for applications in automatic lighting systems.
https://www.tinkercad.com/things/byfB28c0a2C-ldr-sensor
Gas sensor with Arduino
📦 Materials Needed:
- 🖥️ Arduino board
- 🌬️ Gas sensor module (such as MQ-2)
- 🔊 Buzzer
- 🚀 Jumper wires
- 🌈 Resistor
📝 Instructions:
- 🔌 Connect the gas sensor module to the Arduino board.
- Connect the VCC pin to the 5V pin on the board
- Connect the GND pin to the GND pin on the board
- Connect the analog output pin to analog pin A0 on the board
- 🔊 Connect the buzzer to the Arduino board.
- Connect the positive pin of the buzzer to digital pin 11 on the board
- Connect the negative pin to the GND pin on the board
- 💾 Upload the following code to the Arduino board.
- 🔍 Open the Serial Monitor in the Arduino IDE (by clicking on the magnifying glass icon in the top right corner).
- ⚡ Power on the Arduino board and the gas sensor module.
- 💡 The LED on the gas sensor module should light up, indicating that the sensor is detecting gas.
- 🔔 The buzzer will sound if the gas reading is greater than 100.
- You can adjust the threshold value by changing the number in the if (gasReading > 100) line of the code.
- 🖐️ Cover the gas sensor module with your hand to see the gas reading increase on the Serial Monitor and hear the buzzer sound.
📖 Explanation: The gas sensor module detects the presence of certain gases in the air and produces an analog voltage output that is proportional to the concentration of the gas. The Arduino board reads this analog voltage using analog pin A0 and converts it into a digital value using the analog Read () function. The code then checks if the gas reading is greater than 100, and if so, it turns on the buzzer using the digital Write () function. The gas reading is also printed to the Serial Monitor using the Serial. print () function, so you can see the gas concentration value in real-time.
https://www.tinkercad.com/things/klj2N4bOa7l-epic-esboo
The buzzer will make sound if the Gas reading is greater than 100
Vibrator with Arduino
📦 Materials:
- 🧠 Arduino board
- 📳 Vibrator motor
- 🔌 Jumper wires
🔌 Circuit:
- 1️⃣ Connect the positive wire of the vibrator motor to digital pin 3 of the Arduino board.
- 2️⃣ Connect the negative wire of the vibrator motor to the ground (GND) pin of the Arduino board.
📖 Explanation: The code configures digital pin 3 as an output. It then utilizes the digital Write () function to activate the vibrator motor for 1 second, followed by a 1-second pause. This on-off pattern continues indefinitely, creating a consistent vibration cycle.
📝 Instructions:
1️. Assemble the circuit as outlined.
2️. Upload the necessary code to the Arduino board via the Arduino IDE.
3️. Power on the Arduino board.
4️. Watch the vibrator motorcycle through its vibration pattern: on for 1 second, then off for 1 second, continuously.
⚠️ Note: Ensure the vibrator motor’s voltage requirements align with the output capabilities of the Arduino board’s digital pin. Should the motor necessitate a higher voltage, incorporating a motor driver circuit is advisable to safeguard the Arduino board from potential damage.