Hi there !
First of all i have to mention that english isn't my favorite language.
But i hope you can understand me or even help me a little with the problem i'm facing.
I got this code :
#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>
int statusled = 13;
int klingl = 2;
int s1on = 3;
int s1off = 4;
int s2on = 5;
int s2off = 6;
int s3on = 7;
int s3off = 8;
int s4on = 9;
int s4off = 10;
YunServer server;
void setup() {
pinMode(statusled, OUTPUT);
pinMode(klingl, OUTPUT);
pinMode(s1on, OUTPUT);
pinMode(s1off, OUTPUT);
pinMode(s2on, OUTPUT);
pinMode(s2off, OUTPUT);
pinMode(s3on, OUTPUT);
pinMode(s3off, OUTPUT);
pinMode(s4on, OUTPUT);
pinMode(s4off, OUTPUT);
digitalWrite(statusled,HIGH);
Bridge.begin();
Console.begin();
server.begin();
digitalWrite(statusled,LOW);
}
void loop() {
YunClient client = server.accept();
if (client) {
String command = client.readStringUntil('/');
command.trim();
Console.println("Command : " + command);
if (command == "klingl") {
Console.println("Schalte klingl");
digitalWrite(statusled,HIGH);
digitalWrite(klingl,HIGH);
delay(3000);
digitalWrite(klingl,LOW);
}
if (command == "hzgan") {
schalte(s2on);
}
if (command == "hzgaus") {
schalte(s2off);
}
if (command == "stereoa") {
schalte(s1on);
}
if (command == "stereoo") {
schalte(s1off);
}
if (command == "ban") {
schalte(s3on);
}
if (command = "baus") {
schalte(s3off);
}
}
}
void schalte(int whatto) {
Console.println("Schalte " + whatto);
digitalWrite(statusled,HIGH);
digitalWrite(s3off,HIGH);
delay(300);
digitalWrite(s3off,LOW);
digitalWrite(statusled,LOW);
}
It triggers a Button on a remote control for sockets (jacks - the thing the current (230~) comes out).
If i try the programm with just one or two commands all work fine but if i use all commands
in the void loop (inside the if (client)) the programm stops working and i get some strange debug values.
Command : klingl
Schalte klinglCommand : klingl
Schalte klinglCommand : hzgan
teCommand : hzgaus
eCommand : hzgaus
eCommand : hzgan
teCommand : stereoa
alteCommand : hzgaus
e
As you can see the function schalte isnt working correctly and aborting while running the.
The digitalWrite command isn't triggert and the switches doesn't work at all.
(As you can see in the first part of the debugging all is running as usual.
This was the test with only 2 commands)
I have no idea what im doing wrong and im in programming since 2009.
Is there a known bug ?
Is the microcontroller to slow ?
I have no idea... i hope i'm right here and someone knows the answer...
Thank you for reading (and maybe even understanding) !
Nachid