Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Arduino.h"
- #include <WiFi.h>
- #include "SSD1306.h"
- const char* ssid = "ezff";
- const char* password = "password";
- const char* host = "192.168.4.1";
- SSD1306 display(0x3c, 5, 4);
- void mylog(const char* message);
- void setup() {
- WiFi.begin(ssid, password);
- while (WiFi.status() != WL_CONNECTED) {
- delay(100);
- }
- display.init();
- display.setLogBuffer(5, 30);
- //display.flipScreenVertically();
- mylog(WiFi.localIP().toString().c_str());
- }
- void loop() {
- if (WiFi.status() != WL_CONNECTED) {
- WiFi.begin();
- }
- WiFiClient client;
- const int port = 10000;
- if (client.connect(host, port)) {
- mylog("connected");
- while (client.connected()) {
- client.print("LED(ON);");
- delay(1000);
- client.print("LED(OFF);");
- delay(1000);
- while (client.available()) {
- client.read();
- }
- }
- client.stop();
- } else {
- mylog("connection failed");
- delay(1000);
- }
- }
- void mylog(const char* message) {
- display.clear();
- display.setTextAlignment(TEXT_ALIGN_LEFT);
- display.setFont(ArialMT_Plain_10);
- display.println(message);
- display.drawLogBuffer(0, 0);
- display.display();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement