Please for the love of all things holy someone help me with this code. I have been working on this for 2 weeks and have tried using two other people's code and can get no luck so I tried writing my own with trying to follow their guidelines. I am very very new to this and apparently not so good. I am building an automatic chicken coop door that works off of a photocell. I am using an Arduino Mega 2560 with a L298N driver and a DHT11 temperature sensor because I would like to control a dc fan inside the coop as well.
I am getting the following error:
Arduino: 1.6.10 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
C:\Users\GERAR_~1\AppData\Local\Temp\ccuL4sTS.ltrans0.ltrans.o: In function `main':
ccuL4sTS.ltrans0.o:(.text.startup+0x5fc): undefined reference to `motordown()'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Thanks in advance!
#include <DHT.h>
#include <LiquidCrystal.h>
#define DHTPIN 10 //thermometer on pin 10
#define DHTTYPE DHT11 //DHT type 11
int photocell = A0; //photocell pin
int photocellReading; //analog reading from photocell
const int topSwitch = 35; //top reed switch
const int bottomSwitch = 37; //bottom reed switch
int openDoorLED = 46; //red door open LED
int closedDoorLED = 48; //green door closed LED
int enA = 9; //door direction
int in1 = 22; //door motor up
int in2 = 24; //door motor down
int SwitchState1 = 0;
int SwitchState2 = 0;
DHT dht (DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600); //start the print screen
dht.begin(); //start dht for temperature
//door switches pin modes
pinMode(topSwitch, INPUT); //top reed switch set as input
digitalWrite(topSwitch, HIGH); //activate internal pullup resistor
pinMode(bottomSwitch, INPUT); //bottom reed swithc set as input
digitalWrite(bottomSwitch, HIGH); //activate internal pullup resistor
pinMode(photocell, INPUT); //photocell analod input
// set the motor control pins as outputs. This means pins 7,8, 9 are outputs to the l298n motor controller.
pinMode(enA, OUTPUT); //pin 9 from arduino
pinMode(in1, OUTPUT); //pin 8 from arduino
pinMode(in2, OUTPUT); //pin 7 from arduino
//door LED pin modes
pinMode (openDoorLED, OUTPUT); //red LED output
pinMode (closedDoorLED, OUTPUT); //green LED output
// Switch State decleration
SwitchState1 = digitalRead(topSwitch);
SwitchState2 = digitalRead(bottomSwitch);
}
void loop() {
photocellReading = analogRead(photocell);
float f = dht.readTemperature(true);
Serial.print("Analog Reading = ");
Serial.println(photocellReading);
Serial.print("Top Switch = ");
Serial.println(digitalRead(topSwitch)); //display top switch current value
Serial.print("Bottom Swith = ");
Serial.println(digitalRead(bottomSwitch)); //display bottom switch current value
Serial.print("Temperature = ");
Serial.println(f);
delay(2000);
//led loop
void loop();{
if (digitalRead(topSwitch) == LOW){ //if top switch is connected
digitalWrite(openDoorLED, HIGH); //turn on red led
Serial.println("Door Open"); //print door open
}
else{
digitalWrite(openDoorLED, LOW);} //but if not turn the red led off
if (digitalRead(bottomSwitch) == LOW){ //if the bottom switch is connected
digitalWrite(closedDoorLED, HIGH); //turn on the green led
Serial.println("Door Closed"); //print doopr cloosed
}
else{
digitalWrite(closedDoorLED, LOW);} //but if not turn the green led off
}
void motorup();{
SwitchState1 = digitalRead(bottomSwitch);
SwitchState2 = digitalRead(topSwitch);
if (SwitchState1 = HIGH && photocellReading >200){
SwitchState1 = digitalRead(bottomSwitch);
SwitchState2 = digitalRead(topSwitch);
delay (2000);
while (SwitchState2 !=HIGH){
analogWrite(enA, 255);
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
SwitchState1 = digitalRead(bottomSwitch);
SwitchState2 = digitalRead(topSwitch);
}
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);}
}
void motordown();{
SwitchState1 = digitalRead(bottomSwitch);
SwitchState2 = digitalRead(topSwitch);
if (SwitchState2 = HIGH && photocellReading < 200)
delay (2000);
SwitchState1 = digitalRead(bottomSwitch);
SwitchState2 = digitalRead(topSwitch);
while (SwitchState1 !=HIGH){
analogWrite(enA, 255);
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
SwitchState1 = digitalRead(bottomSwitch);
SwitchState2 = digitalRead(topSwitch);
}
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
}
void loop();{
photocellReading = analogRead(photocell);
SwitchState1 = digitalRead(bottomSwitch);
SwitchState2 = digitalRead(topSwitch);
if(SwitchState2 = HIGH && photocellReading <200){
delay(2000);
motordown();
}
else if(SwitchState1 = HIGH && photocellReading >200){
delay(2000);
}
}
}