Pages: [1]   Go Down
Author Topic: Help controlling a Adruino Uno w/ WiShield through Wifi, using JavaScript/HTML  (Read 1069 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So my current project is controlling an rc car with a nerf vulcan cannon on top, all being controlled through the Arduino.
So far I have the gun and camera working. I have the gun being controlled through a relay, works fantastic. I then have an Axis 207-w set to run, throwing its video to its IP address through Wi-Fi. So what ive done is compiled an HTML page, in real time, through the WiServer app that is running on the WiShield. This page contains links to fire the gun, as the Arduino is able to respond based on the url of the page. This however causes problems because you have to reload the page every time you want to fire the gun, making the video stutter an not be consistent enough for realtime use.
So Im wondering if there is a way to use Javascript, creating a function that will use the onClick to somehow trigger the guns circuit, firing is pseudo real-time. Any help would be greatly appreciated!

Ive also attached the current code with the HTML code creating part of the server:
Code:
boolean sendMyPage(char* URL) {
    if (strcmp(URL, "/ffire") == 0){
      fullFire = !fullFire;
      digitalWrite(relayPin, fullFire);
      WiServer.print("<html>");
        WiServer.print("<b>FIRE!!!!!</b><br><br>");
          WiServer.print(" <a href=/>Back to Main</a>");
        WiServer.print("</html>");
      URL = "";
      return true;
    }else if (strcmp(URL, "/fire") == 0){
      digitalWrite(relayPin, HIGH);
      delay(450);
      digitalWrite(relayPin, LOW);
      WiServer.print("<html>");
        WiServer.print("<b>FIRE!!!!!</b><br><br>");
          WiServer.print(" <a href=/>Back to Main</a>");
        WiServer.print("</html>");
      URL = "";
      return true;
    }else if (strcmp(URL, "/3fire") == 0){
      digitalWrite(relayPin, HIGH);
      delay(1100);
      digitalWrite(relayPin, LOW);
      WiServer.print("<html>");
        WiServer.print("<b>FIRE!!!!!</b><br><br>");
          WiServer.print(" <a href=/>Back to Main</a>");
        WiServer.print("</html>");
      URL = "";
      return true;
    }
   
    //digitalWrite(relayPin, redState);
    // Check if the requested URL matches "/"
    else if (strcmp(URL, "/") == 0) {
       fullFire = 0;
       digitalWrite(relayPin, fullFire);
        // Use WiServer’s print and println functions to write out the page content
        WiServer.print("<html>");
        WiServer.print("<b>GUN CONTROL</b><br><br>");
          WiServer.print(" <a href=/fire>SINGLE FIRE</a><br>");
          WiServer.print(" <a href=/3fire>3 ROUND BURST</a><br>");
          WiServer.print(" <a href=/ffire>FULL AUTO</a><br>");
          WiServer.print("<IMG SRC='http://10.104.0.233/axis-cgi/mjpg/video.cgi?resolution=320x240' HEIGHT='240' WIDTH='320' ALT='Camera Image'>");
        WiServer.print("<br>The arduino has been running for: ");
        WiServer.print(millis()/1000);
        WiServer.print(" seconds<br>");
        WiServer.print("</html>");
        // URL was recognized
        return true;
    }
    // URL not found
    return false;
}
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9560
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can look at the page source of the below page to see a javascript setup.

http://web.comporium.net/~shb/wc2000-PT-script.htm
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Pages: [1]   Go Up
Jump to: