• Increase font size
  • Default font size
  • Decrease font size
  • default color
  • cyan color
  • red color

Arduino.TW樂園

Member Area
用Firmata 控制LED矩陣(max7219)
站長Blog文章單元 - 程式語法類(arduino basic, arduinoTW language)
作者是 ken   
週二, 25 十月 2011 00:58

code:

#include <Firmata.h>
#include "LedControl.h"
int led = 13;
LedControl lc=LedControl(12,11,10,1);

void sysexCallback(byte command, byte argc, byte *argv){
  //F0 00 01 02 03 04 05 06 07 08 F7
    Serial.print((int)command);
    Serial.println((int)*argv);
 if(command == 0){
   if(argc == 8){
    Serial.println("_getData:");
    int getLed = (int)argv;
    Serial.println(getLed);
    for(int i=0;i<8;i++){
      lc.setRow(0,i,*argv);
    }
   }
 }
}

void setup() {
  pinMode(led,OUTPUT);
  Firmata.setFirmwareVersion(2, 2);
  Firmata.attach(START_SYSEX, sysexCallback);
  Firmata.begin(57600);
  lc.shutdown(0,false);
  lc.setIntensity(0,8);
  lc.clearDisplay(0);
 }

void loop() {
 while(Firmata.available()){
    Firmata.processInput();
 
 }
 
}

 

附件:
下載此檔案 (firmataLEDMatrix.pde.zip)firmataLEDMatrix.pde.zip[ ]0 Kb西元2011年10月25日 01:00

blog comments powered by Disqus
最近更新在 週二, 25 十月 2011 01:00