News tickertape news feed on matrix display

Clone this repository:

git clone https://github.com/yourusername/arduino-uno-r4-wifi-news-scroller.git

            Open the project in the Arduino IDE.

Hi @michaelbusfield. I tried following your instructions and they don't work:

$ git clone https://github.com/yourusername/arduino-uno-r4-wifi-news-scroller.git

Cloning into 'arduino-uno-r4-wifi-news-scroller'...
remote: Repository not found.
fatal: repository 'https://github.com/yourusername/arduino-uno-r4-wifi-news-scroller.git/' not found

Is "arduino-uno-r4-wifi-news-scroller" your own project, or is this something you found on the Internet?

The "yourusername" GitHub username looks like a placeholder. There is a GitHub user of that name, but they don't have any repositories or any recent activity. I suspect this is a coincidence (any common username is already in use since there are over 100 million users on GitHub) rather than The "yourusername" user actually being the one who created the "arduino-uno-r4-wifi-news-scroller" project you are referring to.

this is not my project
sorry
try

then look in wfi news

I see:

@kd5vmf please fix this false information in your project.


@michaelbusfield the purpose of your post is not clear to me.

Were you hoping to get assistance with using this "Arduino UNO R4 WiFi News Scroller" project?

this program works fine - but gives US news

does anyone know how to modify to gat UK news tickertape?

Inside wifinews.h is this:

https://github.com/KD5VMF/Arduino-UNO-R4-Wifi/blob/921141159c9e7e81808abcb17fbf9173e5465058/Wifi-News/secrets.h

Inside secrets.h is this:

https://newsapi.org/

Which links to this:

https://newsapi.org/docs/endpoints/top-headlines

See "US" here... maybe you want "GB"

GET https://newsapi.org/v2/top-headlines?country=us&apiKey=API_KEY

Here is a version of the program that prints to a Max7219 display

#include <MD_Parola.h>
#include <MD_MAX72XX.h>
#include <SPI.h>
#include <WiFiS3.h>
#include "secrets.h" // Include the secrets file

// Define hardware type and pins
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4 // Number of cascaded 8x8 LED matrices (8x32 display)
#define CS_PIN 10 // CS pin for the LED matrix

MD_Parola matrix = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

WiFiClient client;

const char* server = "newsapi.org";
String apiEndpoint = "/v2/top-headlines?country=us&apiKey=" + String(NEWS_API_KEY);

void setup() {
Serial.begin(115200); // Start serial communication at 115200 baud rate
Serial.println("Serial started at 115200");

// Initialize the matrix
matrix.begin();
matrix.setIntensity(5); // Set brightness level (0-15)
Serial.println("Matrix initialized");

WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nConnected to WiFi!");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
}

void loop() {
if (WiFi.status() == WL_CONNECTED) {
Serial.println("Connecting to News API...");

if (client.connect(server, 80)) {
  Serial.println("Connected to News API server");

  // Send HTTP request to the server with User-Agent header
  client.print(String("GET ") + apiEndpoint + " HTTP/1.1\r\n" +
               "Host: " + server + "\r\n" +
               "User-Agent: Arduino/1.0\r\n" +
               "Connection: close\r\n\r\n");

  String response = "";
  while (client.connected() || client.available()) {
    if (client.available()) {
      char c = client.read();
      response += c;
    }
  }

  Serial.println("HTTP response received:");
  Serial.println(response);  // Print the full response for debugging

  // Find the start of the payload (after the HTTP headers)
  int payloadStart = response.indexOf("\r\n\r\n") + 4;
  String jsonResponse = response.substring(payloadStart);

  Serial.println("Extracted JSON payload:");
  Serial.println(jsonResponse);  // Print the payload for debugging

  // Extract and scroll headlines
  String headlines = extractHeadlines(jsonResponse);
  if (headlines.length() > 0) {
    Serial.println("Headlines extracted:");
    Serial.println(headlines);
    scrollText(headlines.c_str());  // Scroll the extracted headlines on the matrix
  } else {
    Serial.println("No headlines found in the response");
  }

  client.stop();  // Disconnect
} else {
  Serial.println("Failed to connect to News API server");
}

} else {
Serial.println("WiFi is not connected");
}

delay(60000); // Fetch news every 60 seconds
}

// Function to extract headlines from the JSON payload
String extractHeadlines(String json) {
String headlines = "";
int startIdx = 0;

// Parse the JSON to extract each headline
while ((startIdx = json.indexOf(""title":"", startIdx)) >= 0) {
startIdx += 9; // Move past the "title":" part
int endIdx = json.indexOf(""", startIdx);
if (endIdx >= 0) {
String headline = json.substring(startIdx, endIdx);
headlines += headline + " *** "; // Add separator between headlines
startIdx = endIdx + 1;
} else {
break;
}
}

return headlines;
}

// Function to scroll text on the LED matrix
void scrollText(const char* text) {
matrix.displayText(text, PA_CENTER, 100, 50, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
while (!matrix.displayAnimate()) {
// Wait until the scrolling is finished
}
}

Please, wrap that code in backticks... ``` code ```