Monday, July 31, 2017

P10 tampilkan text simpan di eeprom

#include <SPI.h>
#include <DMD.h>
#include <TimerOne.h>
#include <EEPROM.h>
#include <Arial_black_16.h>

#define maxChar 500
#define dmdPanjang 2
#define dmdLebar 1
DMD dmd(dmdPanjang,dmdLebar);

char runningText[maxChar];
char rChar;
byte index;
int i;

void ScanDMD() {
dmd.scanDisplayBySPI();
}

void setup(void) {
Timer1.initialize( 5000 );
Timer1.attachInterrupt( ScanDMD );
dmd.clearScreen( true );
Serial.begin(9600);
}

void loop(void) {
if(Serial.available() > 0 ){
for(i=0; i < 499; i++){
EEPROM.write(i,0);
}
for(i=0; i < 499; i++){
runningText[i] = '';
EEPROM.write(i,runningText[i]);
}
index = 0;
}
while(Serial.available() > 0){
if(index < (maxChar-1)) {
rChar = Serial.read();
runningText[index] = rChar;
EEPROM.write(index,runningText[index]);
index++;
runningText[index] = '';
}
}
for(i=0; i < 499; i++){
runningText[i] = EEPROM.read(i);
}

dmd.clearScreen( true );
dmd.selectFont(Arial_Black_16);
dmd.drawMarquee(runningText, maxChar,(32*dmdPanjang)-1 ,0);
long start=millis();
long timer=start;
boolean ret=false;
while(!ret){
if ((timer+30) < millis()) {
ret=dmd.stepMarquee(-1,0);
timer=millis();
}
}
}

Related Posts

P10 tampilkan text simpan di eeprom
4/ 5
Oleh

Silakan dikomentari