automatic chicken feeder code
automatic chicken feeder code
// Variables:
const int switchPin = 13; // Declaration of variable with pin
const int motorPin = 10; // Declaration of variable with pin
int switchState = 0; // Declaration of variable starting at 0
unsigned long currentTime = 0; // Declaration of variable starting at 0
unsigned long feedTime = 0; // Declaration of variable starting at 0
unsigned long dayTime = 0; // Declaration of variable starting at 0
const int sensorPin = A0; // Declaration of variable with pin
const float baselineTemp = 17.0; // Set room temp. according to serial monitor
void setup() {
void loop() {
if (feedTime >= 19000) { // Variable for feed time (can be changed accordingly)
dayTime = currentTime; // Current time is equal to day time
digitalWrite(motorPin, HIGH); // Turn motor on
lcd.setCursor(1, 0); // Sets position on the LCD for the title
lcd.print(" Dispensing "); // prints title Dispensing to LCD
delay(9000); // Wait for 9 seconds (motor will be on for this much time)
digitalWrite(motorPin, LOW); // Turn motor off
}