Bacana… eu já fiz os 2 capacetes… o meu tem entradas de ar… conseguir evoluir na base da raça… motei a grade ta funfando só falta um SKETCH arduino com animação de texto nas matrix de 32x8…
Tenho o Arduino Leonardo, não sei nada de código, o que achei é esse com 3 abas. Só ta dando erro na aba “animation.h” mostra que “uint8_t animation[][16] = {” ta errado
S e alguém fraga o código me da um help.
################### aba: Led Matrix Shifted #######################
#include <TimerOne.h>
#include “Shifting.h”
#include “animation.h”
#define PWM_LEVELS 4
int clockPin = 2;
int latchPin = 4;
int dataPin = 8;
int timerDelay = 1400;
byte pwmCounter = 0;
byte brightnesses[64];
void iProcess() {
int rowOn, colsOn, c;
for(int r=0; r<8; ++r) {
rowOn = ~(1<<r);
colsOn = 0;
for(c=0; c<8; ++c) {
colsOn |= (pwmCounter < brightnesses[r * 8 + c])<<c;
}
shiftOutByte(dataPin, clockPin, MSBFIRST, rowOn);
shiftOutByte(dataPin, clockPin, MSBFIRST, colsOn);
bitOut(latchPin, LOW);
bitOut(latchPin, HIGH);
if(++pwmCounter > PWM_LEVELS) pwmCounter = 0;
}
}
void setup() {
pinMode(clockPin, OUTPUT);
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
Timer1.initialize(timerDelay);
Timer1.attachInterrupt(iProcess);
}
unsigned long nextImage = 0;
int animationIndex = -1;
void loop() {
if(millis() > nextImage) {
if(++animationIndex >= animationFrames) animationIndex = 0;
nextImage = millis() + animationDelays[animationIndex];
for(int i=0; i<(88); ++i) {
brightnesses[i] = (animation[animationIndex][i/4] >> (i%42)) & B00000011;
}
}
}
################### Aba: Shifiting #######################
#ifndef SHIFTING_H
#define SHIFTING_H
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#define sbipin(pin) sbi((pin)<8 ? PORTD:PORTB, (pin) - ((pin)<8 ? 0:8))
#define cbipin(pin) cbi((pin)<8 ? PORTD:PORTB, (pin) - ((pin)<8 ? 0:8))
#define bitOut(pin, val) {
if ((val) == LOW) cbipin(pin);
else sbipin(pin);
}
#define shiftOutBit(dataPin, clockPin, val, bit) {
bitOut(dataPin, ((val) & (1 << (bit))) ? HIGH:LOW);
bitOut(clockPin, HIGH);
bitOut(clockPin, LOW);
}
#define shiftOutByte(dataPin, clockPin, bitOrder, val) {
shiftOutBit(dataPin, clockPin, val, (bitOrder) == LSBFIRST ?0:7);
shiftOutBit(dataPin, clockPin, val, (bitOrder) == LSBFIRST ?1:6);
shiftOutBit(dataPin, clockPin, val, (bitOrder) == LSBFIRST ?2:5);
shiftOutBit(dataPin, clockPin, val, (bitOrder) == LSBFIRST ?3:4);
shiftOutBit(dataPin, clockPin, val, (bitOrder) == LSBFIRST ?4:3);
shiftOutBit(dataPin, clockPin, val, (bitOrder) == LSBFIRST ?5:2);
shiftOutBit(dataPin, clockPin, val, (bitOrder) == LSBFIRST ?6:1);
shiftOutBit(dataPin, clockPin, val, (bitOrder) == LSBFIRST ?7:0);
}
#endif
################### Aba: Animation #######################
int animationFrames = 28;
int animationDelays[] = { 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 2000 };
// Animation is designed for 8x8 pixels
uint8_t animation[][16] = {
{ 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0 },
{ 0xf, 0x0, 0xf, 0x0, 0xf, 0x0, 0xf, 0x0, 0xf, 0x0, 0xf, 0x0, 0xf, 0x0, 0xf, 0x0 },
{ 0x3f, 0x0, 0x3f, 0x0, 0x3f, 0x0, 0x3f, 0x0, 0x3f, 0x0, 0x3f, 0x0, 0x3f, 0x0, 0x3f, 0x0 },
{ 0xff, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0x0 },
{ 0xff, 0x3, 0xff, 0x3, 0xff, 0x3, 0xff, 0x3, 0xff, 0x3, 0xff, 0x3, 0xff, 0x3, 0xff, 0x3 },
{ 0xff, 0xf, 0xff, 0xf, 0xff, 0xf, 0xff, 0xf, 0xff, 0xf, 0xff, 0xf, 0xff, 0xf, 0xff, 0xf },
{ 0xff, 0x3f, 0xff, 0x3f, 0xff, 0x3f, 0xff, 0x3f, 0xff, 0x3f, 0xff, 0x3f, 0xff, 0x3f, 0xff, 0x3f },
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
{ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa },
{ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 },
{ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x45, 0x51 },
{ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x45, 0x51, 0x0, 0x0 },
{ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x45, 0x51, 0x0, 0x0, 0x0, 0x0 },
{ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x45, 0x51, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
{ 0x55, 0x55, 0x55, 0x55, 0x45, 0x51, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
{ 0x55, 0x55, 0x45, 0x51, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
{ 0x0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