Hi,
I am using an Arduino Uno plus an ethernet shield v1.1 to make a website that when you click a button a certain number of times, a LED on the Arduino lights up or something. So basically I want to have a connection between a website variable and an Arduino Variable. This is my code:
//A webpage that will count how many times you clicked a button
#include "etherShield.h"
#include "ETHER_28J60.h"
static uint8_t mac[6] = {0x54, 0x55, 0x58, 0x10, 0x00, 0x24}; // this just needs to be unique for your network,
// so unless you have more than one of these boards
// connected, you should be fine with this value.
static uint8_t ip[4] = {192, 168, 2, xxx}; // the IP address for your board. Check your home hub
// to find an IP address not in use and pick that
// this or 10.0.0.15 are likely fofrmats for an address
// that will work.
static uint16_t port = 80; // Use port 80 - the standard for HTTP
ETHER_28J60 ethernet;
void setup()
{
ethernet.setup(mac, ip, port);
}
void loop()
{
if (ethernet.serviceRequest())
{
//Make a font in HTML code
ethernet.print("<style> H1{color:red; font-family:ubuntu; font-size:500%;</style>");
//Make the title in HTML code
ethernet.print("<H1>Click it!</H1>");
//Make a font in HTML code
ethernet.print("<style> H2{color:red; font-family:ubuntu; font-size:300%;</style>");
//Background in HTML
ethernet.print("<style> body {background-color:Cyan} </style>");
//Button on website and button press count(This time it is in Javascript and HTML)
ethernet.print("<script type='text/javascript'> var clicks = 0; function onClick() {clicks +=1; document.getElementById('clicks').innerHTML = clicks;}; </script> <button type='button' onClick='onClick()'>Click me</button> <H2>Clicks: <a id='clicks'>0</a></p>");
ethernet.respond();
}
delay(100);
}
Specifically I want to convert the variable "clicks" in the javascript part to another variable in the Arduino code. So how could I do this?