#include <SPI.h>
#include <Ethernet.h>
// Replace with your network settings
byte mac[] = {
0xDE,
0xAD,
0xAA,
0xEF,
0xFE,
0xED
};
IPAddress ip(192, 168, 100, 82);
IPAddress server(192, 168, 100, 66); // Replace with your server's IP
unsigned int serverPort = 7356;
EthernetClient client;
void setup() {
// Initialize serial communication for debugging
Serial.begin(9600);
// Initialize Ethernet interface
Ethernet.begin(mac, ip);
}
void loop() {
// Connect to the Telnet server
if (Serial.available() > 0) { // Check if there's incoming data
char incomingByte = Serial.read(); // Read the incoming byte
// Do something with the incoming byte
if (incomingByte == 'f') { //get current frequency
if (client.connect(server, serverPort)) {
Serial.println("connected");
delay(600);
client.println( incomingByte);
delay(600);
// Read and print the server's response
while (client.available()) {
char c = client.read();
Serial.print(c);
}
client.stop();
Serial.println("Disconnected from server");
} else {
Serial.println("Connection failed");
}
}
}
}