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:
boolean sendMyPage(char* URL) {
if (strcmp(URL, "/ffire") == 0){
fullFire = !fullFire;
digitalWrite(relayPin, fullFire);
WiServer.print("<html>");
WiServer.print("<b>FIRE!!!!!</b>
");
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>
");
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>
");
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>
");
WiServer.print(" <a href=/fire>SINGLE FIRE</a>
");
WiServer.print(" <a href=/3fire>3 ROUND BURST</a>
");
WiServer.print(" <a href=/ffire>FULL AUTO</a>
");
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("
The arduino has been running for: ");
WiServer.print(millis()/1000);
WiServer.print(" seconds
");
WiServer.print("</html>");
// URL was recognized
return true;
}
// URL not found
return false;
}