Naya Lee
Published

A Smart Stray Cat Food Station

A project by a team of students from the Hebei University of Technology

IntermediateShowcase (no instructions)9 hours5
A Smart Stray Cat Food Station

Things used in this project

Story

Read more

Code

Code

C/C++
#include <Wire.h>
#include <rgb_lcd.h>
#include <Wire.h>
#include <DS1307.h>
#include <Servo.h>

#include <GroveChSpeaker.h>

#include <Ultrasonic.h>
#include <Adafruit_NeoPixel.h>

rgb_lcd lcd;
DS1307 clock;
Servo servo_9;

String GetYMDTime()
{
  String year, month, day, ymd;
  clock.getTime();
  year = String(clock.year+2000);
  month = String(clock.month);
  day = String(clock.dayOfMonth);
  ymd = year + "/" + month  + "/" + day;
  return ymd;
}

String GetHMMTime()
{
    clock.getTime();
    String hour, minute, second, hmm;
    clock.getTime();
    hour = String(clock.hour);
    minute = String(clock.minute);
    second = String(clock.second);
    hmm = hour + ":" + minute  + ":" + second;
    return hmm;
}

GroveChSpeaker groveChSpeaker6(6);

Ultrasonic ult7(7);
Adafruit_NeoPixel pixels_4 = Adafruit_NeoPixel(250, 4, NEO_GRB + NEO_KHZ800);
String _E6_97_B6_E9_97_B4;

void ledStripLightAll(const Adafruit_NeoPixel &pixels, const uint8_t &r,const uint8_t &g,const uint8_t &b)
{
    for(int i=0;i<250;i++){
        pixels.setPixelColor(i, pixels.Color(r,g,b));
        pixels.show();
    }
}

void setup(){
lcd.begin(16, 2);
servo_9.attach(9);

pinMode(2, INPUT);
  pixels_4.setBrightness(255);
  pixels_4.begin();

  Serial.begin(9600);
  lcd.display();
  clock.begin();
  clock.fillByYMD(2022, 8, 15);
  clock.fillByHMS(12, 0, 0);
  clock.setTime();
  servo_9.write(0);
  delay(0);

}



void loop(){

  lcd.setCursor(1-1, 1-1);
  lcd.print("Time");
  lcd.setCursor(5-1, 1-1);
  lcd.print(GetYMDTime());
  lcd.setCursor(2-1, 2-1);
  lcd.print(GetHMMTime());
  _E6_97_B6_E9_97_B4 = GetHMMTime();
  if  ((((((_E6_97_B6_E9_97_B4 == "12:0:0")) || ((_E6_97_B6_E9_97_B4 == "14:0:0")))) || ((((_E6_97_B6_E9_97_B4 == "16:0:0")) || ((((_E6_97_B6_E9_97_B4 == "18:0:0")) || ((((_E6_97_B6_E9_97_B4 == "20:0:0")) || ((((_E6_97_B6_E9_97_B4 == "22:0:0")) || ((((_E6_97_B6_E9_97_B4 == "2:0:0")) || ((((_E6_97_B6_E9_97_B4 == "4:0:0")) || ((((_E6_97_B6_E9_97_B4 == "6:0:0")) || ((((_E6_97_B6_E9_97_B4 == "8:0:0")) || ((_E6_97_B6_E9_97_B4 == "10:0:0")))))))))))))))))))){
    groveChSpeaker6.playNote(10,1/2);
    groveChSpeaker6.playNote(10,1/2);
    groveChSpeaker6.playNote(9,1/2);
    groveChSpeaker6.playNote(9,1/2);
    groveChSpeaker6.playNote(8,1/2);
    groveChSpeaker6.playNote(8,1/2);
    groveChSpeaker6.playNote(7,1/2);
    servo_9.write(80);
    delay(0);
    delay(2000);
    servo_9.write(0);
    delay(0);
    
  }
  else if (digitalRead(2)) {
    groveChSpeaker6.playNote(10,1/2);
    groveChSpeaker6.playNote(10,1/2);
    groveChSpeaker6.playNote(9,1/2);
    groveChSpeaker6.playNote(9,1/2);
    groveChSpeaker6.playNote(8,1/2);
    groveChSpeaker6.playNote(8,1/2);
    groveChSpeaker6.playNote(7,1/2);
    servo_9.write(80);
    delay(0);
    delay(2000);
    servo_9.write(0);
    delay(0);
  }
}

Credits

Yin Meiyi, Bi Hanbo, Zeng Yuanxin, Zhang Tongfang

Posted by Naya Lee

Comments