Hello, there is the code you see below, but when I click on the startbutton, temp_role does not open. Normally, when it is LOW, the relay should be activated, but when I click on the startbutton, the light that indicates the relay is working, but there is no "exit" sound coming from the relay, the light of the relay is dim. There is no problem with my connection. Can you help?
#include "max6675.h"
int relay1Pin = 2;
int relay2Pin = 3;
int relay3Pin = 4;
int relay4Pin = 5;
int sicaklik_role = 6;
int thermoDO = 7;
int thermoCS = 8;
int thermoCLK = 9;
const int isiticiac = 50;
const int isiticikapat = 40;
int stopButton = 10;
int startButton = 11;
bool isRunning = false; // Başlangıçta çalışmıyoruz
bool isStartButtonPressed = false; // Start düğmesine basılı tutulup tutulmadığını tutacak değişken
//state machine var
byte runState = 0;
//millis timer for states..
unsigned long lastChange = 0;
unsigned int intervalChange = 10000;
//millis timer for button debouncing..
unsigned long lastDebounce = 0;
int intervalDebounce = 50;
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
void setup() {
pinMode(stopButton, INPUT_PULLUP);
pinMode(startButton, INPUT_PULLUP);
pinMode(relay1Pin, OUTPUT);
pinMode(relay2Pin, OUTPUT);
pinMode(relay3Pin, OUTPUT);
pinMode(relay4Pin, OUTPUT);
pinMode(sicaklik_role, OUTPUT);
digitalWrite(sicaklik_role, HIGH);
digitalWrite(relay1Pin, HIGH);
digitalWrite(relay2Pin, HIGH);
digitalWrite(relay3Pin, HIGH);
digitalWrite(relay4Pin, HIGH);
Serial.begin(9600); // Seri portu başlat
}
void loop() {
double temperature = thermocouple.readCelsius();
if (digitalRead(startButton) == LOW) {
// Start düğmesine basıldığında sicaklik_role LOW durumunda
digitalWrite(sicaklik_role, LOW);
isStartButtonPressed = true;
} else if (digitalRead(startButton) == HIGH && isStartButtonPressed) {
// Start düğmesi bırakıldığında da sicaklik_role LOW durumunda kalır
digitalWrite(sicaklik_role, LOW);
}
if (isStartButtonPressed && temperature >= isiticiac) {
if (millis() - lastDebounce >= intervalDebounce) {
lastDebounce = millis();
if (!isRunning) {
isRunning = true;
//reset state machine
runState = 0;
Serial.println("Röleler çalıştırılıyor...");
}
}
} else if (temperature <= isiticikapat) {
digitalWrite(sicaklik_role, HIGH);
}
// Start düğmesine basıldığında röleleri çalıştır
if (isRunning) {
switch (runState) {
case 0:
digitalWrite(relay1Pin, LOW);
digitalWrite(relay2Pin, LOW);
runState = 1;
// Diğer durumları devam ettir...
break;
// Diğer durumları kontrol et...
}
}
}
When a different code is entered, that is, only the code that the relay should work with, the relay works. I do not draw the electricity of the relay through the arduino anyway.
At this point I believe an annotated schematic showing exactly how you have wired it, be sure it includes all connections, power, ground, power supplies, etc. Links with technical information for each piece of hardware. There are many units with the same name and description, that are actually different.
I am not sure I can help as I cannot see what is in front of you. Post an annotated schematic exactly as you have wired it showing all connections, power, ground, power supplies etc. As you are probably aware there are many items for the Arduino/Pi world that are labeled the same thing but are different. Therefore I ask you post links to technical information on all of the hardware devices in your circuit. Be sure these links have the proper technical information. Links to amazon and other market places generally do not have the information required. It is your problem, so save us a lot of time and post the requested information.
For example you push on a start button, is there just one or there hundreds or they part of a keyboard ..etc, we cannot see what you have.
Now let me explain, this code works like this; There are 2 buttons, one start button and one stop button. When I click the start button, 1 relay opens and that relay is connected to a heater. After that relay is turned on, the heater starts to work and the thermocouple starts to measure the temperature. After the temperature reaches a certain level, the code I wrote to the 4-relay module, that is, the code "Wait for the first two relays for 10 seconds, then wait 5 seconds, switch to the other two relays wait for 10 seconds, wait 5 seconds" works. After the heater reaches the temperature (50C) specified in the code, the relay that I manage the heater turns off, and after reaching the temperature (40C) I specified in the code again, the heater relay is activated again, so it stays at a certain temperature. This is something like a bread maker, in short, the logic is this; The first two relays indicate one direction of the motor, the other two relays the other direction of the motor. The heater, on the other hand, keeps the vat containing the dough at a certain temperature. When I press the stop button whenever I want, the whole process stops. This is what I want to do.
The parts I used in the circuit; 2 buttons, 4 relay modules, single relay module, k-type max6675 thermocouple, 1 arduino nano, 1 external power supply to power the relays
Word problems do not work for me, I will wait for the schematic or abandon the problem. Hardware interconnections etc are very important and will not work if not connected properly.
All of them are connected to the places where they should be, the problem is not the connection, when I press the button, the relay does not work properly, the light of the relay is on, but there is no sound from the relay.
if (isRunning) {
switch (runState) {
case 0:
digitalWrite(relay1Pin, LOW);
digitalWrite(relay2Pin, LOW);
runState = 1;
// Diğer durumları devam ettir...
break;
// Diğer durumları kontrol et...
}
}
What is the use of a switch() with a single case?
Why not use if()?
I see you are having multiple threads in pursuit of what seems like one goal.
Please consider sticking with one thread. Please consider asking the moderators to combine your thread and leave one in an appropriate forum. You can flag your own post and someone will help you do that.
it is wasteful of time to discover that you are that relay guy… and that other ppl have already told you or asked you or helped you or whatever.
I only state the truth when I say I am out until. Otherwise, good luck.
So your software is working, BUT your hardware is not.
SO PLEASE POST A SCHEMATIC.
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.
Can you please post some images of your project so we can see your component layout?
Also... I do not see your sketch going into this routine at any temperature...
if (isStartButtonPressed && temperature >= isiticiac) {
Serial.print("x"); // <-- THIS DOES NOT HAPPEN AT ANY TEMPERATURE
if (millis() - lastDebounce >= intervalDebounce) {
lastDebounce = millis();
if (!isRunning) {
isRunning = true;
//reset state machine
runState = 0;
Serial.println("Röleler çalıştırılıyor...");
}
}
Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.
Repeated cross-posting can result in a suspension from the forum.
In the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.
Let's do it like this, I played a little more on the code, the code works as it should, but let me explain the problem I'm experiencing with a video, you can understand it more easily.