Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Tlc5940.h>
- #include <Wire.h>
- #define EXPANDER B0100000
- static unsigned long timerDuration;
- void setup(){
- Tlc.init();
- Wire.begin(EXPANDER);
- timerDuration = micros() + 100;
- }
- byte pattern[8][2] = {
- {B10000011,B11001100},
- {B10000010,B00001010},
- {B10000010,B00001001},
- {B10000010,B00001001},
- {B10000011,B10001001},
- {B10000010,B00001001},
- {B10000010,B00001010},
- {B11110011,B11001100}};
- void loop(){
- if((long)(micros() - timerDuration) >= 0){
- timer_Tick();
- timerDuration = micros() + 100;
- }
- }
- void sendByte(int adress, int data){
- Wire.beginTransmission(EXPANDER);
- Wire.write(data);
- Wire.endTransmission();
- }
- int counter = 0;
- void timer_Tick(){
- if(counter > 7){
- counter = 0;
- }
- sendByte(EXPANDER, 255);
- Tlc.clear();
- for(int i = 0; i <= 1; i++){
- for (byte pos = 0, mask = B10000000; mask > 0; mask >>= 1){
- if (pattern[counter][i] & mask){
- if(i == 0){
- Tlc.set(pos, 4095);
- }
- else{
- Tlc.set(pos + 8, 4095);
- }
- }
- pos++;
- }
- }
- Tlc.update();
- delay(1);
- sendByte(EXPANDER, ~(1 << counter));
- counter++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement