Điện tử vuotlen.com

Arduino truyền dữ liệu phần 2

Arduino truyền dữ liệu Phần 2

1.  SPI:

Led Ma trận 8x8

Linh kiện: Arduino Uno, Matrix 8x8 Red, Max7219

Lib Import Zip: bitBangedSPI.zip, MAX7219_Dot_Matrix-master.zip

Proteus:

Arduino IDE:

#include <SPI.h>

#include <bitBangedSPI.h>

#include <MAX7219_Dot_Matrix.h>

 

MAX7219_Dot_Matrix matrix(1, 10);

const char mess[] = "Tien Giang Viet Nam";

 

unsigned long lastMove = 0;

unsigned long thoigian= 120;

int messageOffset;

 

void Hienthi(){

  matrix.sendSmooth(mess, messageOffset);

  if(messageOffset++ >= (int)(strlen(mess)*8)) messageOffset = -8;

}

 

void setup() {

  // put your setup code here, to run once:

  matrix.begin();

}

 

void loop() {

  // put your main code here, to run repeatedly:

  if(millis() - lastMove >= thoigian){

    Hienthi();

    lastMove = millis();

  }

}