science_is_maths
Published © GPL3+

PGF(Programmable GoldFish Feeder)

This Goldfish Feeder can feed fish when you are not at home, and you can easily change the feeding frequency and feed amount.

BeginnerFull instructions provided187
PGF(Programmable GoldFish Feeder)

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Photo resistor
Photo resistor
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
LED (generic)
LED (generic)
×2
Resistor 221 ohm
Resistor 221 ohm
×3
LED Chain
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Breadboard (generic)
Breadboard (generic)
×1
Cut_In_Half Bottle
×1
Card
×1
USB-A to B Cable
USB-A to B Cable
×1
USB-To-Wall Adapter
×1
Any tape
×1
And... A Fish Tank and some Fishies!
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Scissors
Ruler

Story

Read more

Schematics

The Connections

Code

Code

Arduino
This is the code to the Arduino Uno R3
#include <Servo.h>
#define MOTOR 9
int time;
int sensorReading = 0;
int pos = 0;
/*
    The default time is 10800000, or 3 hours. 
    If you want to quickly calculate your time, multiply
    your time by 3,600,000 to get milliseconds.
*/
int noFeed = 9000000;
Servo servo_9;
void setup() {
  pinMode(6, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(2, OUTPUT);
  for (pos = 180; pos >= 0; pos -= 1) {
    servo_9.write(pos);
  }
  servo_9.attach(9, 500, 2500);
  int servo = 10;
   pinMode(A0, INPUT);
  Serial.begin(9600);

}

void loop() {
  digitalWrite(4, HIGH);
  analogWrite(6, 255);
  sensorReading = analogRead(A0);
  Serial.print("brightness---  ");
  Serial.println(sensorReading);
  Serial.print("time set is ====");
  Serial.println(noFeed);
  if (sensorReading <= 380) {
    analogWrite(6, 50);
    delay(7200000);
  }
  delay(noFeed);
  digitalWrite(4, LOW);
  digitalWrite(2, HIGH);

   for (pos = 0; pos <= 180; pos += 13) {
    if (sensorReading <= 380) {
      analogWrite(6, 50);
    delay(7200000);
  }
    servo_9.write(pos);
    delay(15);
    
  }
  for (pos = 180; pos >= 0; pos -= 1) {
    if (sensorReading <= 380) {
      analogWrite(6, 50);
    delay(7200000);
  }
    servo_9.write(pos);
  }
  digitalWrite(2, LOW);
  if (sensorReading <= 380) {
    analogWrite(6, 50);
    delay(7200000);
  }

}


//The End!\\

Credits

science_is_maths
0 projects • 0 followers

Comments