Go Down

Topic: TLC5940 + VirtualWire, problems (Read 391 times) previous topic - next topic

tessomc

Hello all,

Im using RF to talk betweeen two arduinos, to light up some leds using TLC5940.

the RF Part is ok, the server send the data and the receiver receives it and display in my serial output

Then i merged the TLC stuff with the receiver.

Then i got a problem, the TLC overwrites the VirtualWire.

I changed the ports on TLC
BLANK -> PB2 (D10)
XLAT -> PB1 (D9)
SIN -> PD7 (D7)
XERR -> PD6 (D6)
SCLK -> PD4 (D4)
GSCLK -> PD3 (D3)

Edited the tlc_config.h  and setted
#define DATA_TRANSFER_MODE TLC_BITBANG

Then switched the virtualwires to tx 0, rx 1 then rx to 8, but any case the problem remains the same

When i upload the scketch, commenting the TLC.init(), the virtualwire works fine, but if i leave uncommented the virtualwire stops receiving the data.

The tlc is working fine, just overrinding, or messing with the virtualwire.

Im attaching the source, but dunno if it will help.

any thoughts? Thanks for the help!

Code: [Select]

#include "Tlc5940.h"
#include <VirtualWire.h>

int pinR[12] = {0,3,6,9,12,15,18,21,24,27,30,33};
int pinG[12] = {1,4,7,10,13,16,19,22,25,28,31,34};
int pinB[12] = {2,5,8,11,14,17,20,23,26,29,32,35};

int hourForecast[12] = {10,11,10,11,10,10,10,10,11,10,10,10};

char dados[] =  "110212011301140115031603170318021902200221012201";

void setup() {
  Serial.begin(9600);
  Serial.println("setup");
 
  //VirtualWire
  vw_set_tx_pin(0);
  vw_set_rx_pin(8);
  vw_setup(2000); // Bits per sec
  vw_rx_start();
 
  Tlc.init();

}

void loop() {
 
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
int i;

        //digitalWrite(13, true); // Flash a light to show received good message
// Message with a good checksum received, dump it.
Serial.print("Got: ");

       
//char dados[i];
for (i = 0; i < 47; i++)
{

            dados[i] = buf[i];
   
}
        Serial.print(dados);   
Serial.println("");
        //digitalWrite(13, false);
       
       
    }
 
  //setForecast();
  //setLights();
 
}

void setForecast(){
 
   for(int i = 0; i <= 44; i = i+4){
    int hora = (String(dados[i]).toInt()*10 )+  (String(dados[i+1]).toInt());
    int dado = (String(dados[i+2]).toInt()*10 )+  (String(dados[i+3]).toInt());
   
   if(hora >= 12){
     hora = hora - 12;
   }
   
    hourForecast[hora] = dado;
  }
}

void setLights(){
Tlc.clear();
  for(int i=0; i <= 11; i++){
   
    //Serial.print(i);
    //Serial.print("-");
    //Serial.println(hourForecast[i]);
   
    if(hourForecast[i] >= 1 && hourForecast[i] <=2){
      Tlc.set(pinR[i], ((4095 * 255) / 255));
      Tlc.set(pinG[i], ((4095 * 255) / 255));
      Tlc.set(pinB[i], ((4095 * 0) / 255));
    } else if(hourForecast[i] >= 3 && hourForecast[i] <=6){
     Tlc.set(pinR[i], ((4095 * 102) / 255));
     Tlc.set(pinG[i], ((4095 * 255) / 255));
     Tlc.set(pinB[i], ((4095 * 255) / 255));
    }
   
   
  }
  Tlc.update();
  delay(5000);
}

Go Up