Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
sxtuktaxl
Published

Flash Feed Fish

How to make a Flash Feed Fish.

IntermediateProtip1,189
Flash Feed Fish

Things used in this project

Story

Read more

Schematics

Schematics

Code

Untitled file

C/C++
#include <DS1302.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <Servo.h> 

#define I2C_ADDR 0x27
#define BACKLIGHT_PIN 3
LiquidCrystal_I2C lcd(0x3f,2,1,0,4,5,6,7);
DS1302 rtc(5, 6, 7);
Servo myservo;
Time t; 
int pos = 0;

void setup()
{
  Serial.begin(9600);
  myservo.attach(9);
{  
  rtc.halt(false);
  rtc.writeProtect(false);
}lcd.begin (16,2);
{
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home (); 
}

  
{

 
  rtc.setDOW(FRIDAY);        
  rtc.setTime(15, 00, 00);     
  rtc.setDate(13, 11, 2017);  
 delay(500);
}
 pinMode(2,OUTPUT); 
 pinMode(3,OUTPUT);
 pinMode(4,OUTPUT);
pinMode(10, OUTPUT);
pinMode (pos,OUTPUT);
{
lcd.setCursor(5,0);
lcd.print("Welcome");
lcd.setCursor(4, 1);
lcd.print("Fish Food");
delay(2000);
lcd.clear ();

}

}

void loop()
{
 
 t=rtc.getTime();  
{
lcd.setCursor(0, 0);
lcd.setCursor(0,0);
lcd.print("Time");
lcd.setCursor(5,0);
lcd.print(rtc.getTimeStr());
}
{
lcd.setCursor(0, 1);
lcd.print("Day");
lcd.setCursor(5,1);
lcd.print(rtc.getDateStr(FORMAT_SHORT));
delay (1000);
}



Serial.print("\n");
if(t.hour < 10){Serial.print(0);}
Serial.print(t.hour, DEC);
Serial.print(":");
if(t.min < 10){Serial.print(0);}
Serial.print(t.min, DEC);
Serial.print(":");
if(t.sec < 10){Serial.print(0);}
Serial.print(t.sec, DEC);
  
  Serial.println(rtc.getTimeStr());

  if ((t.hour == 15)&&(t.min == 00)&&(t.sec == 06))
{
digitalWrite(2,HIGH);
 {readservo();}
 {
 readservo();
 delay(1000);
  }
}
if ((t.hour == 16)&&(t.min == 00)&&(t.sec == 00))
{
digitalWrite(2, LOW);
digitalWrite(3,OUTPUT);
 
 {
 readservo();
 delay(4000);
  }
}

else if ((t.hour == 22)&&(t.min == 00)&&(t.sec == 00))
{
digitalWrite(3, LOW);
}
delay (10);
}

void readservo()
{
  for (pos = 0; pos <= 180; pos += 5) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 5) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);                       // waits 15ms for the servo to reach the position
  }
  
}

Credits

sxtuktaxl
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.