Coding Arduino FYP2
Coding Arduino FYP2
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // LCD at address 0x27 with 16 columns and
2 rows
void setup() {
pinMode(trigPin, OUTPUT); // Set trigPin as an output
pinMode(echoPin, INPUT); // Set echoPin as an input
pinMode(relayPin, OUTPUT); // Set relayPin as an output
lcd.init(); // Initialize the LCD
lcd.print("Place Hand Near"); // Initial message
delay(2000); // Wait 2 seconds to give user time to read
message
}
void loop() {
// Generate an ultrasonic pulse
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
1. Arduino Uno
• Power Supply: Connect the solar power supply to the Arduino’s VIN or 5V pin
(ensure the solar output is appropriate for the Arduino).
3. Relay Module
• IN: Connect to digital pin 7 on the Arduino (this controls the relay).
• VCC: Connect to the Arduino's 5V pin.
• GND: Connect to the Arduino's GND pin.
6. Relay Connection
• Relay NO (Normally Open): Connect to the positive terminal of the UVC light.
• Relay COM (Common): Connect to the positive terminal of the 9V battery. The
relay will close (connect) when activated, allowing current to flow from the 9V
battery to the UVC light.