Arduino YUN webserver problem

Hello,

To learn how to work with the Arduino yun I found an earlier post from "tcmspark"

http://forum.arduino.cc/index.php?topic=263988.0

I slightly modified the sketch.(see under).
On pin 13,12,11 I placed LED's to confirm the program works when I push a button.

I Copied the Arduino sketch in mydocuments/Arduino/test.ino
I Copied the HTML file to mydocuments/Arduino/WWW/index.html
I copied the file jsHere.js mydocuments/Arduino/www/js/jsHere.js
I copied the file zepto.min.js mydocuments/Arduino/www/js/zepto.min.js

So,

The first problem I found is that the files in the WWW directory aren't send to the sd Card by uploading the sketch.
The sd card has already an Arduino/WWW directory on it, and Arduino IDE says there aren't problems with finding an directory such as sd/www/
I also tried another tutorial (babaawesome control input output using ajax)and it uploads the contents of the WWW folder correctly.

So after this i put the files myself on the sd card.
After that i can open the site with the pushbuttons but the leds aren't going to blink :frowning:

REST API is set to OPEN.

Whats wrong and/or missing and/or? :frowning: :frowning:

Kind regards,

Harmen

ARDUINO SKETCH

#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>
YunServer server;
String readString;
void setup() {
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);

Bridge.begin();
//digitalWrite(13, HIGH);

server.listenOnLocalhost();
server.begin();
}

void loop() {
YunClient client = server.accept();
if (client) {
String command = client.readString();
command.trim(); //kill whitespace
Serial.println(command);

if (command == "rolloutcarpet") {
digitalWrite(11, HIGH);
delay(1000);
digitalWrite(11, LOW);
delay(1000);
digitalWrite(11, HIGH);
delay(1000);
digitalWrite(11, LOW);
delay(1000);
}

if (command == "playfanfare") {
digitalWrite(12, HIGH);
delay(1000);
digitalWrite(12, LOW);
delay(1000);
digitalWrite(12, HIGH);
delay(1000);
digitalWrite(12, LOW);
delay(1000);
}

if (command == "stopfanfare") {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
client.stop();
}

delay(50);

}

HTML CODE (ORIGINAL)

Roll Out the Carpet      LED BLUE OFF

PLAY FANFARE
       STOP FANFARE

Please use code tags when putting code in a post. Click the </> button (first button on the tool ribbon) then paste the code between the tags. It makes it MUCH easier to read the code, and it preserves proper formatting.

Hint: You can still go back and edit your post to add the code tags.

I think the question about why the IDE didn't load the ancillary files might be easier to answer...

I Copied the Arduino sketch in mydocuments/Arduino/test.ino

That doesn't look right, normally the sketch file is in a sub-folder with the sketch name: (note the red addition)

mydocuments/Arduino/**test/**test.ino

Then, the ancillary files need to be in a www folder inside the sketch folder:

I Copied the HTML file to mydocuments/Arduino/**test/**WWW/index.html
I copied the file jsHere.js mydocuments/Arduino/**test/**www/js/jsHere.js
I copied the file zepto.min.js mydocuments/Arduino/**test/**www/js/zepto.min.js

Finally, you must select the Yuns network port in the Arduino IDE's Port menu - if you select the USB serial port, the sketch will load, but the other files will not be transferred.

The problem with the LEDs not being set is more problematical. You have a Serial.println() call that prints out any commands that are received. With the USB cable attached, and the USB port selected in the IDE's Port menu, what do you see on the Serial Monitor when you try to run the web interface?

Also, you can divide and conquer to help determine if the problem is in the sketch or the web page. Try manually typing the various URLs in a web browser and see if you get the expected result. If not, the problem is in the sketch or the Yun's setup; but if it works properly, the problem is in the web pages.