Hello!
I have a question. I have completed this project, and below is the wiring diagram of the project. I would like to know why, when I power up the board and the power shield on the breadboard, all the connected elements turn on. I should mention that the 6 buttons were declared as high, and each button controls a different circuit.
I see no diagram. Or code.
Welcome to the forum
No, that is a bad picture of a bunch of anonymous cables and components. Can you see which pins are connected to which. I can't.
Please draw a proper schematic of your project, hand drawn and photographed is good enough, and upload it here
What happens when you power up the project depends on the circuit and the code that is running
Please post your sketch, using < CODE > tags when you do and explain what should happen
Hello. Sorry it is my first time using this forum.
#include <LiquidCrystal_I2C.h> #include <Servo.h>
Servo servo1,servo2;
int angle = 0;
LiquidCrystal_I2C lcd(0x27,16,2); //Declararea pinilor folositi in hardware: const int buzzer = A0;
const int button1 = 40;
const int button2 = 42;
const int button3 = 44;
const int button4 = 46;
const int button5 = 48;
const int button6 = 50;
const int relay_IN1 = 14;
const int relay_IN2 = 15;
const int relay_IN3 = 16;
const int servo_1 = 10;
const int servo_2 = 11;
const int prox_sensor_trigg = 12; const int prox_sensor_echo = 13; //Declararea butoanelor si releelor bool button1State = HIGH;
bool button2State = HIGH; bool button3State = HIGH; bool button4State = HIGH; bool button5State = HIGH; bool button6State = HIGH; bool relay1State = LOW; bool relay2State = LOW; bool relay3State = LOW; void setup() {
//Baudrate-ul standard pt arduino
Serial.begin(9600);
// Setarea pinMode-urile
pinMode(button1, INPUT_PULLUP); pinMode(button2, INPUT_PULLUP); pinMode(button3, INPUT_PULLUP); pinMode(button4, INPUT_PULLUP); pinMode(button5, INPUT_PULLUP); pinMode(button6, INPUT_PULLUP);
69
pinMode(prox_sensor_trigg, OUTPUT); pinMode(prox_sensor_echo, INPUT); pinMode(buzzer, OUTPUT); pinMode(relay_IN1, OUTPUT); pinMode(relay_IN2, OUTPUT); pinMode(relay_IN3, OUTPUT);
//Servomotoare
servo1.attach(servo_1); servo2.attach(servo_2);
//LCD
lcd.init();
lcd.backlight();
lcd.home(); }
void loop() {
//Variabilele care salveaza starea anterioara a butonului
bool button1_StatePrev = HIGH ;
bool button2_StatePrev = HIGH ;
bool button3_StatePrev = HIGH ;
bool button4_StatePrev = HIGH ;
bool button5_StatePrev = HIGH ;
bool button6_StatePrev = HIGH ;
//Variabile care citesc de pe placa starea butonului (LOW/HIGH - APASAT/LIBER)
bool button1State = digitalRead(button1); bool button2State = digitalRead(button2); bool button3State = digitalRead(button3); bool button4State = digitalRead(button4); bool button5State = digitalRead(button5); bool button6State = digitalRead(button6);
//CIRCUIT AUTOMATIZARE PORTI
if (button1State != button1_StatePrev ) { if (button1State == LOW) {
lcd.clear();
angle = (angle == 0) ? 90 : 0; if(angle == 90){ lcd.print("Garaj deschis!"); servo1.write(angle); delay(200);
}if(angle == 0){ lcd.print("Garaj inchis!"); servo1.write(angle); delay(200);
70
} }
}
if (button2State != button2_StatePrev) {
if (button2State == LOW) { lcd.clear();
angle = (angle == 0) ? 90 : 0; if(angle == 90){ lcd.print("Poarta deschisa!"); servo2.write(angle); delay(200);
}if(angle == 0){ lcd.print("Poarta inchisa!"); servo2.write(angle); delay(200);
} }
}
// CIRCUIT DE SECURITATE
long duration, distance; digitalWrite(prox_sensor_trigg, LOW); delayMicroseconds(2); digitalWrite(prox_sensor_trigg, HIGH); delayMicroseconds(10); digitalWrite(prox_sensor_trigg, LOW); duration = pulseIn(prox_sensor_echo, HIGH); distance = duration * 0.034 / 2;
if (distance < 10 ) {
lcd.clear();
digitalWrite(buzzer, LOW); lcd.print("ALARMA PORNITA!");
}
if (button6State == LOW) {
lcd.clear();
digitalWrite(buzzer, HIGH); lcd.print("ALARMA OPRITA!");
}
delay(100);
// CIRCUITE DE ILUMINAT
if (button3State != button3_StatePrev) { if (button3State == LOW) {
lcd.clear();
71
relay1State = !relay1State;
if (relay1State == HIGH) { lcd.print("Lumina alee ON!");
} else {
lcd.print("Lumina alee OFF!");
}
digitalWrite(relay_IN1, relay1State); delay(200);
}
}
if (button4State != button4_StatePrev) {
if (button4State == LOW) { lcd.clear();
relay2State = !relay2State;
if (relay2State == HIGH) { lcd.print("Lumina casa ON!"); } else {
lcd.print("Lumina casa OFF!");
}
digitalWrite(relay_IN2, relay2State); delay(200);
} }
if (button5State != button5_StatePrev) { if (button5State == LOW) {
lcd.clear();
relay3State = !relay3State;
if (relay3State == HIGH) { lcd.print("Lumina curte ON!");
} else {
lcd.print("Lumina curte OFF!");
}
digitalWrite(relay_IN3, relay3State);
delay(200); }
} }
I want to make an automatization house system with buttons. A circuit for security with HC SR04 and a buzzer controller by a button, 2 servomotors controlled by 2 buttons and 3 circuits of illuminate controlled by 3 buttons but when in power the mega2560 and the shield power of arduino all starts to work.
That's the expected behavior when power is supplied. If you mean something different, unexpected, by "work" or "turn on" then please specify better what you mean.
What are those funny squares with green dots inside in your circuit diagram? I suspect connectors but these deserve no such symbols in a circuit diagram. If you mean buttons (switches) then you probably don't understand how to use buttons.
For absolute safety put in a relay in the power line to the servos, motors, lasers, HV, etc. so the power to the devices must be explicitly commanded ON. This allows the sw to initialize all IO's to a known state before allowing anything to so much as twitch. This circuitry is part of your E-stop. Putting a manual mushroom switch in series allows both E-stop and controlled startup. If you're going to design real-world gear, you'll need this type of HW safety circuit.
PS: If you have access to a 3D printer, here is a link to free .STL
files for assorted Arduino mounting blocks and hardware. It'll clean up the cobwebs in a shoebox you have now.
- Remove all connections.
- Connect one device and test until it works as you want.
- GOTO 2.
p.s. I don't think the relays or servos will work as drawn.
The leds wonât work as drawn either - you need a resistor for each led , as you have it , slight differences in the forward voltage of the leds will mean some will be dim or off .
The âschematicâ shows servos powered off the Arduino pins - you canât use an Arduino as a power supply for servos , or the relays or lots of leds
Do you mean all the LEDs light, the servos start moving back and forth all the relays close and LCD displays whatever it's supposed to?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.