Hi there :D, im new on arduino and i did some projects by myself, but now im having some troubles on my new project.
Im trying to make a kennel with arduino, like im trying to make the handler job easier, if they press a push button they can open the food container and the food falls on to the dog bowl and if they push the other push button associated to the servo motor they close the container, and they can see the temperature and the humidity of the room on a 16x4 LCD.
Im using a arduino mega 2560, a DHT11 sensor, 2 LCD's 16x4, 4 push buttons and 2 servo motor HS-422.
I made the codes separated and then joined them, the codes were working fine alone, but then when i joined them the servo motors didnt work, i can ear the servo motor working, but if i push the button they dont move, i cant find the problem i searched the internet i cant find nothing.
My code:
#include <stdio.h>
#include <dht.h>
#include <LiquidCrystal.h>
#include<Servo.h>
#define DHTPIN A0
#define DHTPIN1 A1
int pos = 0;
Servo servo;
Servo servo2;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LiquidCrystal lcd2(12, 10, 5, 4, 3, 2);
dht DHT;
void setup(){
lcd.begin(20, 4);
lcd2.begin(16, 2);
pinMode(52, INPUT);
pinMode(50, INPUT);
pinMode(53, INPUT);
pinMode(51, INPUT);
servo.attach(22);
servo2.attach(24);
}
void loop()
{
DHT.read11(DHTPIN);
lcd.setCursor(0,0);
lcd.print("Temp= ");
lcd.print(DHT.temperature);
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("Hum= ");
lcd.print(DHT.humidity);
lcd.print("% ");
delay(2000);
DHT.read11(DHTPIN1);
lcd2.setCursor(0,0);
lcd2.print("Temp= ");
lcd2.print(DHT.temperature);
lcd2.print("C");
lcd2.setCursor(0,1);
lcd2.print("Hum= ");
lcd2.print(DHT.humidity);
lcd2.print("% ");
delay(2000);
if (digitalRead(52) == HIGH && pos < 180) {
pos++;
servo.write(pos);
delay(15);
}
if (digitalRead(50) == HIGH && pos > 0) {
pos--;
servo.write(pos);
delay(15);
}
if (digitalRead(53) == HIGH && pos < 180) {
pos++;
servo2.write(pos);
delay(15);
}
if (digitalRead(51) == HIGH && pos > 0) {
pos--;
servo2.write(pos);
delay(15);
}
}
I did the images on circuits.io and doesnt exist arduino mega so i have 1 image for the 2 LCD's and sensor and the other for the push buttons, on the second image the white lines represent the wires that will conect on the arduino ( first wire on the 52 pin, second wire on the 50 pin, third wire on the 53 pin and fourth wire on the 51 pin), two of the servo motors pins will conect on the GND and 5V, and the other will conect on the 22 pin, the other servo motor pin will not conect on 22 pin but on the 24 pin.
If someone could help me i would be very happy.