I'm completely new to arduino. This is my first project, and I'm trying to make a display board that looks to a php page and scrolls the text on it.
I've gotten half way by very badly ripping bits of code from here and there.
I can get it to connect to my php page and grab the text, even output it via serial. So I know it's there.
But what I'm having trouble with is displaying the variable on the dmd with the dmd.drawMarquee command.
I can get it to display a set message, but when I try to use the variable it says "error: 'displaytext' was not declared in this scope"
I know that I just don't understand enough about this language, and I've read many codes that do a similar thing, but can't get my head around it.
Please help...
Code: Select all
#include <SPI.h>
#include <Ethernet.h>
#include <DMD.h>
#include <TimerOne.h>
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
//Fire up the DMD library as dmd
#define DISPLAYS_ACROSS 1
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(27,124,113,129);
EthernetClient client;
void ScanDMD()
{
dmd.scanDisplayBySPI();
}
void setup() {
//initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
Timer1.initialize( 5000 ); //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
Timer1.attachInterrupt( ScanDMD ); //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI()
//clear/init the DMD pixels held in RAM
dmd.clearScreen( true ); //true is normal (all pixels off), false is negative (all pixels on)
Serial.begin(9600);
while (!Serial) {
;
}
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
for(;;)
;
}
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /~williams/arduino/display.php");
client.println();
}
else {Serial.println("connection failed");}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char displaytext = client.read();
Serial.print(displaytext);
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
dmd.clearScreen( true );
dmd.selectFont(Arial_Black_16);
dmd.drawMarquee(displaytext,14,(32*DISPLAYS_ACROSS)-1,0);
long start=millis();
long timer=start;
boolean ret=false;
while(!ret){
if ((timer+30) < millis()) {
ret=dmd.stepMarquee(-1,0);
timer=millis();
}
}
delay(60000);
setup();
}
}