#include <WiFi.h>
#include <SPI.h>
const char *ssid = "BSNL5G";
const char *password = "KIMAYA0207";
int dataInPin = 13;
int loadPin = 14;
int clockPin = 27;
void sendByte(int data) {
for (int i = 0; i < 8; i++) {
digitalWrite(clockPin, LOW);
digitalWrite(dataInPin, (data & (1 << (7 - i))) > 0 ? HIGH : LOW);
digitalWrite(clockPin, HIGH);
}
}
void max7219_write(int address, int data) {
digitalWrite(loadPin, LOW);
sendByte(address);
sendByte(data);
digitalWrite(loadPin, HIGH);
digitalWrite(loadPin, LOW);
}
void setup() {
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
// Initialize the Max 7219
pinMode(dataInPin, OUTPUT);
pinMode(loadPin, OUTPUT);
pinMode(clockPin, OUTPUT);
max7219_write(0x0c, 0x01); // shutdown mode
max7219_write(0x0f, 0x00); // display test off
max7219_write(0x0b, 0x07); // decode mode on for all digits
max7219_write(0x0a, 0x01); // intensity to max
max7219_write(0x0c, 0x01); // wake up from shutdown mode
}
void loop() {
// Connect to a remote server and receive a message
WiFiClient client;
if (!client.connect("your_server_ip", 80)) {
Serial.println("Connection failed");
delay(1000);
return;
}
client.println("GET /message");
while (client.connected()) {
String line = client.readStringUntil('\n');
if (line == "\r") {
break;
}
}
// Display the message on the Max 7219 LED matrix
for (int i = 1; i <= 8; i++) {
int digit = link[i - 1] - '0';
max7219_write(i, digit);
}
client.stop();
}