Hello Everyone. This is my first post, I hope anybody can help me through this.
Im trying to build a code to using Ethernet Shield with Arduino Uno to send API Function to PC.
I try to do with 2 buttons and its works fine, this is my codes :
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(192,168,1,3); //My PC IP Address
IPAddress ip(192,168,1,30); //Ethernet Shield IP Address
const int bt1 = 2; //My First Button
const int bt2 = 3; //My second button
;
boolean btstat = HIGH;
boolean pllbt = HIGH;
int led = 9;
EthernetClient client;
void setup() {
Serial.begin(9600);
while (!Serial) {
;
}
pinMode(bt1, INPUT);
digitalWrite(bt1, HIGH);
pinMode(bt2, INPUT);
digitalWrite(bt2, HIGH);
pinMode(led, OUTPUT);
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to get DHCP");
Ethernet.begin(mac, ip);
}
delay(1000);
Serial.println("connecting...");
if (client.connect(server, 80)) {
Serial.println("connected");
digitalWrite(led, HIGH);
}
else {
Serial.println("Failed to Connect");
}
}
void loop ()
{
pllbt=btstat;
btstat = digitalRead(bt1);
if (btstat != pllbt) {
if (btstat == LOW){
Serial.println("Select1");
client.connect(server, 80);
client.println("POST /API/?Function=Select1");
client.println();
client.stop();
}
}
pllbt=btstat;
btstat = digitalRead(bt2);
if (btstat != pllbt) {
if (btstat == LOW){
Serial.println("Select2");
client.connect(server, 80);
client.println("POST /API/?Function=Select2");
client.println();
client.stop();
}
}
}
my question is How to add Analog Potentiometer class to send a value ( 0 - 255) to my API software ?
Im totally new to arduino stuff, So help me please. And Thank you before