XY-LJ02 how am i going to open programmes inside this relay?
i have arduino uno lcd keypad shield 8 channels of relay. İ need some codes for this XY-LJ02 thingy. Help would be appreciated.
Topic moved. Please do not post in "Uncategorized"; see the sticky topics in Uncategorized - Arduino Forum.
Please post manual and datasheet to that device. Then, hopefully, helpers can link You projects using it.
1.That sounds like it could be an interesting project that could be a lot of fun! However, please keep in mind that we are not a free design or code-writing service. We’re more than happy to help with your design or code, but we need you to make an initial attempt. Please design and write your code, then post it along with an explanation of what’s not working properly.*
- Show Your Work First: Before asking for assistance, make an attempt to design or write the code yourself. Share your work along with details about what isn’t working. Only you know what you want!
- Provide Clear Documentation: Since we can’t see your project, share an annotated schematic (best) or a clear drawing of your setup. Pictures are welcome, but avoid using Fritzing diagrams as they are wiring diagrams, not schematics, and are not ideal for troubleshooting.
- Include Technical Details: If there is specific hardware involved, include links to technical information. There are often many versions of similar components, so precise details are essential. What version of buttons buzzer and a stepper motor are we looking at.
- Reference Resources: For additional help, check out useful links and tutorials: Useful Links on Arduino Forum. Post links to your buttons buzzer and a stepper motor technical information.
- Obtain a copy: of the Arduino Cookbook and complete several of the projects. Many of them will help you achieve parts of your goals.
- Course Electronics For Beginners (eBook)
- Electronics For Beginners (eBook)
- Arduino Step-by-step Projects Course | Build 25 Projects
#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,4,5,6,7);
const int RELAY1 = 13;
const int RELAY2 = 12;
const int RELAY3 = 11;
const int RELAY4 = 3;
const int BUTTON1 = A0;
boolean lastButton1 = LOW;
boolean currentButton1 = LOW;
boolean relayOn1 = true;
boolean lastButton2 = LOW;
boolean currentButton2 = LOW;
boolean relayOn2 = true;
boolean lastButton3 = LOW;
boolean currentButton3 = LOW;
boolean relayOn3 = true;
boolean lastButton4 = LOW;
boolean currentButton4 = LOW;
boolean relayOn4 = true;
boolean b1Start = false;
int b1Stage = -1;
unsigned long b1P1WorkingMillis = 0;
boolean b2Start = false;
int b2Stage = -1;
unsigned long b2P1WorkingMillis = 0;
boolean b3Start = false;
int b3Stage = -1;
unsigned long b3P1WorkingMillis = 0;
boolean b4Start = false;
int b4Stage = -1;
unsigned long b4P1WorkingMillis = 0;
const long p1WorkingInterval = 3000;
void setup(){
Serial.begin(9600); // See the connection status in Serial Monitor
pinMode(RELAY1, OUTPUT);
pinMode(RELAY2, OUTPUT);
pinMode(RELAY3, OUTPUT);
pinMode(RELAY4, OUTPUT);
pinMode(BUTTON1, INPUT);
digitalWrite(RELAY1, true);
digitalWrite(RELAY2, true);
digitalWrite(RELAY3, true);
digitalWrite(RELAY4, true);
}
boolean debounce1(boolean last1) {
boolean current1 = digitalRead(BUTTON1);
if(last1 != current1) {
delay(7000);
current1 = digitalRead(BUTTON1);
}
return current1;
}
boolean debounce2(boolean last2) {
boolean current2 = digitalRead(BUTTON1);
if(last2 != current2) {
delay(3000);
current2 = digitalRead(BUTTON1);
}
return current2;
}
boolean debounce3(boolean last3) {
boolean current3 = digitalRead(BUTTON1);
if(last3 != current3) {
delay(3100);
current3 = digitalRead(BUTTON1);
}
return current3;
}
boolean debounce4(boolean last4) {
boolean current4 = digitalRead(BUTTON1);
if(last4 != current4) {
delay(4000);
current4 = digitalRead(BUTTON1);
}
return current4;
}
void loop()
{
B1Function();
B2Function();
B3Function();
B4Function();
}
void B1Function()
{
unsigned long nowMillis = 0;
currentButton1 = debounce1(lastButton1);
if(lastButton1 == LOW && currentButton1 == HIGH) {
if (!b1Start)
{
b1Start = true;
b1Stage = 0;
}
}
lastButton1 = currentButton1;
if (b1Start)
{
switch (b1Stage)
{
case 0:
b1Stage = 1;
digitalWrite(RELAY1, false);
lcd.setCursor(0,0);
lcd.print("1.Relay On");
Serial.println("1.Relay On");
b1P1WorkingMillis = millis();
break;
case 1:
nowMillis = millis();
if (nowMillis - b1P1WorkingMillis >= p1WorkingInterval)
{
b1Stage = -1;
b1Start = false;
Serial.println("1. Relay Off!");
digitalWrite(RELAY1, true);
}
}
}
}
void B2Function()
{
unsigned long nowMillis = 0;
currentButton2 = debounce2(lastButton2);
if(lastButton2 == LOW && currentButton2 == HIGH) {
if (!b2Start)
{
b2Start = true;
b2Stage = 0;
}
}
lastButton2 = currentButton2;
if (b2Start)
{
switch (b2Stage)
{
case 0:
b2Stage = 1;
digitalWrite(RELAY2, false);
lcd.setCursor(0,0);
lcd.print("2. Relay On");
Serial.println("2. RElay On");
b2P1WorkingMillis = millis();
break;
case 1:
nowMillis = millis();
if (nowMillis - b2P1WorkingMillis >= p1WorkingInterval)
{
b2Stage = -1;
b2Start = false;
lcd.setCursor(0,0);
lcd.print("2. Relay Off!");
Serial.println("2. Relay Off!");
digitalWrite(RELAY2, true);
}
}
}
}
void B3Function()
{
unsigned long nowMillis = 0;
currentButton3 = debounce3(lastButton3);
if(lastButton3 == LOW && currentButton3 == HIGH) {
if (!b3Start)
{
b3Start = true;
b3Stage = 0;
}
}
lastButton3 = currentButton3;
if (b3Start)
{
switch (b3Stage)
{
case 0:
b3Stage = 1;
digitalWrite(RELAY3, false);
lcd.setCursor(0,0);
lcd.print("3. Relay On");
Serial.println("3. Relay On");
b3P1WorkingMillis = millis();
break;
case 1:
nowMillis = millis();
if (nowMillis - b3P1WorkingMillis >= p1WorkingInterval)
{
b3Stage = -1;
b3Start = false;
lcd.setCursor(0,0);
lcd.print("3. Relay Off!");
Serial.println("3. Relay Off!");
digitalWrite(RELAY3, true);
}
}
}
}
void B4Function()
{
unsigned long nowMillis = 0;
currentButton4 = debounce4(lastButton4);
if(lastButton4 == LOW && currentButton4 == HIGH) {
if (!b4Start)
{
b4Start = true;
b4Stage = 0;
}
}
lastButton4 = currentButton4;
if (b4Start)
{
switch (b4Stage)
{
case 0:
b4Stage = 1;
digitalWrite(RELAY4, false);
lcd.setCursor(0,0);
lcd.print("4. Relay On");
Serial.println("4. Relay On");
b4P1WorkingMillis = millis();
break;
case 1:
nowMillis = millis();
if (nowMillis - b4P1WorkingMillis >= p1WorkingInterval)
{
b4Stage = -1;
b4Start = false;
lcd.setCursor(0,0);
lcd.print("4. Relay Off!");
Serial.println("4. Relay Off!");
digitalWrite(RELAY4, true);
}
}
}
}
What should i change in these programmes inside this XY-LJ02 relay? I need your ideas.
Maybe you should start posting the details as requested in post #3 by @Railroader. User manuals, datasheets and schematics can be very useful.
I did search for XY-LJ02 and I found single relay boards like https://mrelectrobot.com/wp-content/uploads/2022/08/XY-LJ02.pdf; I did not find a 8-channel version.
I have an 8 channel relay and I am trying to do that operation with Arduino Uno. I want to control 8 pneumatic valves with timing
Connected similar to this? Note that you need a separate power supply if you want to have multiple relays on at the same time.
(source: Relay module effecting Arduino)
Have you tested with some simple codes to control the relays. If you use the blink example, the relay connected to pin 13 should switch on/off every second.
The relay is turned on as soon as electricity is supplied, it works closed for a waiting period and then turns on again. I want to operate it in the form of cl op and loop, like in a time relay.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
