Sabtu, 19 Agustus 2017

Running text via bluetooth v2

#include <SPI.h>
#include <DMD.h>
#include <TimerOne.h>
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
#define DISPLAYS_ACROSS 1
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);
#define max_char 100
char message[max_char];
char r_char;
byte index = 0;
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()){
for(i=0; i<99; i++){
message[i] = '\0';
}
index=0;
}
while(Serial.available() > 0){
if(index < (max_char-1)) {
r_char = Serial.read();
message[index] = r_char;
index++;
message[index] = '\0';
}
}
dmd.clearScreen( true );
dmd.selectFont(Arial_Black_16);
dmd.drawMarquee(message, max_char,(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();
}
}
}

Download disini

Tidak ada komentar:

Posting Komentar

coding suhu arduino

#include <SD.h> #include <SPI.h> #include <DS3231.h> File data_file; DS3231  rtc(SDA, SCL); const int lm35_pi...