Controlling a servo using potentiometer via a website


i working on project need control servo using potentiometer via internet.

in details- potentiometer needs send reading website let ip address. analog reading shown on there. same ip address needs accessed laptop servo connected arduino uno , ethernet shield.

 in way servo can controlled via sensor remote place. same thing have tried using single laptop, worked.

but having problem doing on 2 laptops. how solve connectivity issue , how it? plz me out. :(  :( 


i leaving code have tried single laptop-

#include <spi.h>
#include <ethernet.h>
#include <servo.h>

byte mac[] = {0x90, 0xa2, 0xda, 0x0d, 0x1e, 0xf9};
byte ip[] = {192,168, 137, 25};

ipaddress gateway(152, 97, 100, 1);
ipaddress subnet(255, 255, 254, 0);

ethernetserver server(80);
servo myservo;

void setup() {
   
    serial.begin(9600);
    { myservo.attach(9);}
    // start ethernet connection:
    if (ethernet.begin(mac) == 0) {
        serial.println("failed configure ethernet using dhcp");
       
        ethernet.begin(mac, ip, gateway, subnet);
    }
    server.begin();
    serial.print("server @ ");
    serial.println(ethernet.localip());
}
void loop() {
   
    ethernetclient client = server.available();
    if (client) {
        serial.println("new client");
        boolean currentlineisblank = true;
        while (client.connected()) {
            if (client.available()) {
                char c = client.read();
                serial.write(c);
                if (c == '\n' && currentlineisblank) {
                    client.println("http/1.1 200 ok");
                    client.println("content-type: text/html");
                    client.println("connnection: close");
                    client.println();

                    client.println("<!doctype html>");
                    client.println("<html>");
                    client.println("<meta http-equiv=\"refresh\" content=\"5\">");
                    (int analogchannel = 0; analogchannel < 6; analogchannel++) {
                        int sensorreading = analogread(analogchannel);
                        int val = analogread(analogchannel);
                         val= map(val, 0, 1023, 0, 180);
                       
                       myservo.write(val);
                        client.print("analog input ");
                        client.print(analogchannel);
                        client.print(" ");
                        client.print(sensorreading);
                        client.println("<br />");
                    }
                    client.println("</html>");
                    break;

                }
                if (c == '\n') {
                    currentlineisblank = true;
                } else if (c != '\r') {
                    currentlineisblank = false;
                }
            }
        }
        delay(0);
        client.stop();
        serial.println("client disonnected");
    }
}

your sketch doesn't match description :-(

why read 7 analogue pins, instead of 1 connected potentiometer?

what's use of internet connection, when both potentiometer , servo connected same arduino?


Arduino Forum > Using Arduino > Project Guidance > Controlling a servo using potentiometer via a website


arduino

Comments