Cool Practical Applications of ino in Arduino

Cool Practical Applications of ino in Arduino

Hi, friends! We already know that ino is a great helper for operating Arduino, and now I will tell you more interesting practical applications.

1. Smart Pet Feeder

Imagine you have a small pet, but sometimes you get busy and forget to feed it. At this time, we can use Arduino and ino to create a smart pet feeder.

We can connect a small motor to the Arduino board, which is used to control the opening of the feeder so that food can drop out. In the code, we can set the feeding time and amount.

// Import the library to control the motor, assuming it's the Servo library
#include <Servo.h>
// Create a servo object
Servo myservo;
// Define the pin for controlling the servo
int servoPin = 9;
// Define the angle for each feeding (adjust according to your feeder's mechanical structure)
int feedAngle = 90;
// Initialize the servo in the setup function
void setup() {
  myservo.attach(servoPin);
}
// Set feeding time in the loop function
void loop() {
  // Assume feeding at 8 AM and 8 PM every day
  if (hour() == 8 || hour() == 20) {
    myservo.write(feedAngle);
    delay(5000);  // Give food enough time to drop
    myservo.write(0);
  }
  delay(60000);  // Check the time every minute
}

By using ino, we compile and upload this code to the Arduino board. This way, your little pet can eat on time, isn’t that thoughtful?

Tip: When making it, be sure that the motor or servo has enough power to push the feeder’s opening, and adjust the angle properly, otherwise the food might spill everywhere.

2. Automatic Watering System

For those who love to keep flowers but often forget to water them, making an automatic watering system with Arduino and ino is a great idea.

We can insert a moisture sensor into the soil of the flower pot to detect the soil moisture. Then connect a small water pump to the Arduino board. When the moisture is below a certain level, the water pump is activated to water the plants.

// Import the moisture sensor library (assuming it's a suitable library)
#include <MoistureSensor.h>
// Define the pin for the moisture sensor
int moisturePin = A0;
// Define the pin for the water pump
int pumpPin = 7;
// Set pin modes in the setup function
void setup() {
  pinMode(pumpPin, OUTPUT);
}
// Read moisture and control the water pump in the loop function
void loop() {
  int moistureValue = analogRead(moisturePin);
  // Assume that if the moisture value is below 500, it needs watering
  if (moistureValue < 500) {
    digitalWrite(pumpPin, HIGH);
    delay(5000);  // Water for 5 seconds, adjust according to actual situation
    digitalWrite(pumpPin, LOW);
  }
  delay(60000);  // Check moisture every minute
}

After uploading this code with ino to the Arduino board, your flowers can “drink water” by themselves.

Precautions: Be aware of the accuracy and insertion depth of the moisture sensor; if inserted too shallow, it may not accurately detect soil moisture. Also, the power of the water pump should not be too high, otherwise it may damage the flowers or cause flooding.

3. Simple Electronic Password Lock

If you want to add an electronic password lock to your small box or drawer, Arduino and ino can also do it.

We can connect a small keypad to the Arduino board for entering the password, and connect a servo to control the lock.

#include <Keypad.h>
// Define the pins and layout for the keypad
const byte ROWS = 4;
const byte COLS = 3;
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
byte rowPins[ROWS] = {5, 4, 3, 2};
byte colPins[COLS] = {8, 7, 6};
// Create a keypad object
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
// Define the pin for the servo
int servoPin = 9;
// Define the correct password
String correctPassword = "1234";
// Create a servo object
Servo myservo;
// Initialize the servo and serial communication in the setup function
void setup() {
  myservo.attach(servoPin);
  Serial.begin(9600);
}
// Read keypad input and validate password in the loop function
void loop() {
  char key = keypad.getKey();
  static String inputPassword = "";
  if (key) {
    inputPassword += key;
    Serial.println(inputPassword);
    if (inputPassword.length() == correctPassword.length()) {
      if (inputPassword == correctPassword) {
        myservo.write(90);  // Unlock
        delay(5000);
        myservo.write(0);  // Lock
        inputPassword = "";
      } else {
        Serial.println("Wrong password!");
        inputPassword = "";
      }
    }
  }
}

After uploading this code with ino, you can unlock it by entering the password on the keypad.

Tip: It’s best not to set the password too simple, otherwise others can easily guess it. Also, when connecting the keypad and servo, be careful not to connect the wires incorrectly, otherwise it may not work properly.

Leave a Comment

×