Projeto com Fita RGB com leds fracos - ajuda

Boas. Após o desenvolvimento do projecto, estando já ele concluido, deparei-me com um problema de iluminação leds fraca.
A fita led é de 5v.
Constatei ainda que, se em vez de usar os resistores 220, se ligar direto, os leds ficam um pouco mais fortes, mas ainda assim nao teem a mesma iluminação se os ligar directamente ao usb do pc.
Deixo aqui o codigo e esquema do projecto para conseguir desvendar o problema de tal suceder.

Obrigada

Você deixou um link exigindo uma senha. Publique um link de "acesso público".

segue link publico

segue link publico

Não é publico. Pede login.

Click em " < code> " na barra de ferramentas e poste seu codigo
Poste também u esquemático do seu projeto.

#include <LiquidCrystal_I2C.h>

#include <Wire.h>


#define LEDPIN 13
#define HOME_SENSORPIN 7
#define AWAY_SENSORPIN 4
#define dcasa 8
#define dfora 2
#define BRIGHTNESS  80


LiquidCrystal_I2C lcd(0x27, 16, 2);

const char HOME_TEAM[] = "SPORTING      ";
const char AWAY_TEAM[] = "BENFICA       ";

//RGB
int vermelho = 10;
int verde = 11;
int azul = 12;

int home_goals = 0;
int away_goals = 0;

int home_wins = 0;
int away_wins = 0;

int homeSensorState = 0, homeLastState = 0;       // variable for reading the pushbutton status
int awaySensorState = 0, awayLastState = 0;       // variable for reading the pushbutton status
int dcasaState = 0, dcasaLastState = 0;
int dforaState = 0, dforaLastState = 0;

//-------------------------------------------------------------
void printScore() {
  // Write home info
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(HOME_TEAM);
  if (home_goals < 10) {
    lcd.print(" ");
  }
  lcd.print(home_goals);
  if (home_wins < 10) {
    lcd.print(" ");
  }
  
  // Write away info
  lcd.setCursor(0, 1);
  lcd.print(AWAY_TEAM);
  if (away_goals < 10) {
    lcd.print(" ");
  }
  lcd.print(away_goals);
  if (away_wins < 10) {
    lcd.print(" ");
  }
  
}

void setColor(int redValue, int greenValue, int blueValue) {
  analogWrite(vermelho, redValue);
  analogWrite(verde, greenValue);
  analogWrite(azul, blueValue);
}

void piscared() {
setColor(255, 0, 0);
}

void piscagreen() {
setColor(0, 0, 255);
}

void apagado() {
setColor(0, 0, 0);
}
  //-------------------------------------------------------------
void splashScreen() {
  int i = 0;
  int j = 0;
  for (i = 0; i < 2; i++) {
    for (j = 0; j < 16; j++) {
      //lcd.clear();
      lcd.setCursor(j, i);
      lcd.print("-");
      delay(25);
    }
  }
}
//-------------------------------------------------------------
void blinkHome() {
  Serial.println("blinkHome");
  piscagreen();
  delay(150);
  apagado();
  delay(150);
  piscagreen();
}
//-------------------------------------------------------------
void blinkAway() {
  Serial.println("blinkAway");
  piscared();
  delay(150);
  apagado();
  delay(150);
  piscared();
}
//-------------------------------------------------------------
void printGoalHOME() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("GOLO  GOLO  GOLO");
  lcd.setCursor(0, 1);
  lcd.print("    SPORTING    ");
  delay(1100);
  }

void printGoalAWAY() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("GOLO  GOLO  GOLO");
  lcd.setCursor(0, 1);
  lcd.print("    BENFICA    ");
  delay(1100);
}
void printGoalmenos() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("   INVALIDO    ");
  lcd.setCursor(0, 1);
  lcd.print("    ANULADO    ");
  delay(500);
  }
//-------------------------------------------------------------
void setup() {
  // set up the LCD's number of columns and rows:
  lcd.init();
  lcd.backlight();
  // Print a message to the LCD.
  //lcd.print("hello, world!");
  
  printScore();
  // initialize the LED pin as an output:
  pinMode(LEDPIN, OUTPUT);
  // initialize the sensor pin as an input:
  pinMode(HOME_SENSORPIN, INPUT);
  digitalWrite(HOME_SENSORPIN, HIGH); // turn on the pullup
  pinMode(AWAY_SENSORPIN, INPUT);
  digitalWrite(AWAY_SENSORPIN, HIGH); // turn on the pullup
  pinMode(dcasa, INPUT);
  digitalWrite(dcasa, HIGH);
  pinMode(dfora, INPUT); 
  digitalWrite(dfora, HIGH);
  pinMode(vermelho, OUTPUT);
  pinMode(verde, OUTPUT);
  pinMode(azul, OUTPUT);
  
  Serial.begin(9600);
}

void loop() {
  homeSensorState = digitalRead(HOME_SENSORPIN);
  awaySensorState = digitalRead(AWAY_SENSORPIN);
  dcasaState = digitalRead(dcasa);
  dforaState = digitalRead(dfora); 
  if (homeSensorState == LOW) {
    digitalWrite(LEDPIN, HIGH);
  }
  else {
    digitalWrite(LEDPIN, LOW);
  }
  if (awaySensorState == LOW) {
    digitalWrite(LEDPIN, HIGH);
  }
  else {
    digitalWrite(LEDPIN, LOW);
  }
  if (homeSensorState && !homeLastState) {
    Serial.println("home Unbroken");
  }
  if (!homeSensorState && homeLastState) {
    Serial.println("home Broken");
    printGoalHOME();
    blinkHome();
    blinkHome();
    blinkHome();
    blinkHome();
    blinkHome();
    blinkHome();
    apagado();
    home_goals++;
    printScore();
    if (home_goals == 5) {
      if (home_goals > away_goals) {
        home_wins++;
      }
      else {
        away_wins++;
      }
      home_goals = 0;
      away_goals = 0;
      delay(2000);
      printScore();
    }
  }
  if (dcasaState == LOW) {
    digitalWrite(LEDPIN, HIGH);
  }
  else {
    digitalWrite(LEDPIN, LOW);
  }
  if (dforaState == LOW) {
    digitalWrite(LEDPIN, HIGH);
  }
  else {
    digitalWrite(LEDPIN, LOW);
  }
  if (dcasaState && !dcasaLastState) {
    Serial.println("home Unbroken");
  }
  if (!dcasaState && dcasaLastState) {
    Serial.println("home Broken");
    printGoalmenos();
    home_goals--;
    printScore();
    if (home_goals == 5) {
      if (home_goals > away_goals) {
        home_wins++;
      }
      else {
        away_wins++;
      }
      home_goals = 0;
      away_goals = 0;
      delay(2000);
      printScore();
    }
  }
  if (awaySensorState && !awayLastState) {
    Serial.println("away Unbroken");
  }
  if (!awaySensorState && awayLastState) {
    Serial.println("away Broken");
    printGoalAWAY();
    blinkAway();
    blinkAway();
    blinkAway();
    blinkAway();
    blinkAway();
    blinkAway();
    apagado();
    away_goals++;
    printScore();
    if (away_goals == 5) {
      if (away_goals > home_goals) {
        away_wins++;
      }
      else {
        home_wins++;
      }
      away_goals = 0;
      home_goals = 0;
      delay(2000);
      printScore();
    }
  }
  if (dforaState && !dforaLastState) {
    Serial.println("away Unbroken");
  }
  if (!dforaState && dforaLastState) {
    Serial.println("away Broken");
    printGoalmenos();
    away_goals--;
    printScore();
    if (away_goals == 5) {
      if (away_goals > home_goals) {
        away_wins++;
      }
      else {
        home_wins++;
      }
      away_goals = 0;
      home_goals = 0;
      delay(2000);
      printScore();
    }
  }
  homeLastState = homeSensorState;
  awayLastState = awaySensorState;
  dcasaLastState = dcasaState;
  dforaLastState = dforaState;
}

Após muita pesquisa, cheguei há conclusão que tudo se deve há falta de corrente. Por isso a minha ideia, vais ser usar uma fonte externa, e com 3 transistores BC547, para promover chaveamento, e assim conseguir ter a corrente necessaria. Assim que tenha feito o teste, irei postar se resultou ou não.
No entanto se alguém souber o que podera estar a acontecer, agradecia sugestao.
Obrigada

Este projeto é um projeto escolar?
Achei o codigo dele muito similar à um outro que ajudei recentemente.
" Duvidas em código projecto placar desportivo

Esta função que utiliza o LED RGB usa função analogWrite(), que é uma função PWM.
Mas os pinos verde (11) e azul (12) no UNO não são pinos PWM.

Boas. O projeto que dizes semelhante, é o mesmo, já me tinhas auxiliado no outro tb. O problema foi na compra da fita, comprei a normal, e tive de alterar a programação dos leds, porque a outra era ara fita apenas de 3 fios. Esta que comprei tem 4. Não tinha reparado nisso, do pwm. Vou proceder à essa alteração da numeração. No entanto achas que para este projecto deva usar uma fonte externa para os leds. Será que a alimentação fornecida pelo arduino é suficiente para rolar 2 sensores, dois display lcd e ainda fita led?
A minha ideia é usar uma bateria de 12v 7amperes, na saída colocar um regulador de tensão para baixar para os 9v. É a partir daí alimentar o arduino. A minha dúvida é se devo alimentar os leds com fonte externa ou não!

Tente este codigo:

//https://forum.arduino.cc/t/projeto-com-fita-rgb-com-leds-fracos-ajuda/1240753/8
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#define LEDPIN 13
#define HOME_SENSORPIN 7
#define AWAY_SENSORPIN 4
#define dcasa 8
#define dfora 2
#define BRIGHTNESS  80
LiquidCrystal_I2C lcd(0x27, 16, 2);
const char HOME_TEAM[] = "SPORTING      ";
const char AWAY_TEAM[] = "BENFICA       ";
//RGB
int vermelho = 10;
int verde = 11;
int azul = 12;
int home_goals = 0;
int away_goals = 0;
int home_wins = 0;
int away_wins = 0;
int homeSensorState = 0, homeLastState = 0;       // variable for reading the pushbutton status
int awaySensorState = 0, awayLastState = 0;       // variable for reading the pushbutton status
int dcasaState = 0, dcasaLastState = 0;
int dforaState = 0, dforaLastState = 0;
//-------------------------------------------------------------
void printScore() {
  // Write home info
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(HOME_TEAM);
  if (home_goals < 10) {
    lcd.print(" ");
  }
  lcd.print(home_goals);
  if (home_wins < 10) {
    lcd.print(" ");
  }
  // Write away info
  lcd.setCursor(0, 1);
  lcd.print(AWAY_TEAM);
  if (away_goals < 10) {
    lcd.print(" ");
  }
  lcd.print(away_goals);
  if (away_wins < 10) {
    lcd.print(" ");
  }
}
//---------------------------------------------------------------------
void setColor(int redValue, int greenValue, int blueValue) {
  //analogWrite(vermelho, redValue);
  //analogWrite(verde, greenValue);
  //analogWrite(azul, blueValue);
 // Serial.println("Apaga tudo");
  digitalWrite(vermelho, !redValue);
  digitalWrite(verde, !greenValue);
  digitalWrite(azul, !blueValue);
}
//---------------------------------------------------------------------
void piscared() {
  setColor(255, 0, 0);
}
//---------------------------------------------------------------------
void piscagreen() {
  setColor(0, 0, 255);
}
//---------------------------------------------------------------------
void apagado() {
  setColor(0, 0, 0);
}
//-------------------------------------------------------------
void splashScreen() {
  int i = 0;
  int j = 0;
  for (i = 0; i < 2; i++) {
    for (j = 0; j < 16; j++) {
      //lcd.clear();
      lcd.setCursor(j, i);
      lcd.print("-");
      delay(25);
    }
  }
}
//-------------------------------------------------------------
void blinkHome() {
  Serial.println("blinkHome");
  piscagreen();
  delay(150);
  apagado();
  delay(150);
  piscagreen();
}
//-------------------------------------------------------------
void blinkAway() {
  Serial.println("blinkAway");
  piscared();
  delay(150);
  apagado();
  delay(150);
  piscared();
}
//-------------------------------------------------------------
void printGoalHOME() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("GOLO  GOLO  GOLO");
  lcd.setCursor(0, 1);
  lcd.print("    SPORTING    ");
  delay(1100);
}
//---------------------------------------------------------------------
void printGoalAWAY() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("GOLO  GOLO  GOLO");
  lcd.setCursor(0, 1);
  lcd.print("    BENFICA    ");
  delay(1100);
}
void printGoalmenos() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("   INVALIDO    ");
  lcd.setCursor(0, 1);
  lcd.print("    ANULADO    ");
  delay(500);
}
//-------------------------------------------------------------
void setup() {
  // set up the LCD's number of columns and rows:
  lcd.init();
  lcd.backlight();
  // Print a message to the LCD.
  //lcd.print("hello, world!");
  printScore();
  // initialize the LED pin as an output:
  pinMode(LEDPIN, OUTPUT);
  // initialize the sensor pin as an input:
  pinMode(HOME_SENSORPIN, INPUT);
  digitalWrite(HOME_SENSORPIN, HIGH); // turn on the pullup
  pinMode(AWAY_SENSORPIN, INPUT);
  digitalWrite(AWAY_SENSORPIN, HIGH); // turn on the pullup
  pinMode(dcasa, INPUT);
  digitalWrite(dcasa, HIGH);
  pinMode(dfora, INPUT);
  digitalWrite(dfora, HIGH);
  pinMode(vermelho, OUTPUT);
  pinMode(verde, OUTPUT);
  pinMode(azul, OUTPUT);
  Serial.begin(9600);
  setColor(0, 0, 0);
}
//---------------------------------------------------------------------
void loop() {
  homeSensorState = digitalRead(HOME_SENSORPIN);
  awaySensorState = digitalRead(AWAY_SENSORPIN);
  dcasaState = digitalRead(dcasa);
  dforaState = digitalRead(dfora);
  if (homeSensorState == LOW) {
    digitalWrite(LEDPIN, HIGH);
  }
  else {
    digitalWrite(LEDPIN, LOW);
  }
  if (awaySensorState == LOW) {
    digitalWrite(LEDPIN, HIGH);
  }
  else {
    digitalWrite(LEDPIN, LOW);
  }
  if (homeSensorState && !homeLastState) {
    Serial.println("home Unbroken");
  }
  if (!homeSensorState && homeLastState) {
    Serial.println("home Broken");
    printGoalHOME();
    blinkHome();
    blinkHome();
    blinkHome();
    blinkHome();
    blinkHome();
    blinkHome();
    apagado();
    home_goals++;
    printScore();
    if (home_goals == 5) {
      if (home_goals > away_goals) {
        home_wins++;
      }
      else {
        away_wins++;
      }
      home_goals = 0;
      away_goals = 0;
      delay(2000);
      printScore();
    }
  }
  if (dcasaState == LOW) {
    digitalWrite(LEDPIN, HIGH);
  }
  else {
    digitalWrite(LEDPIN, LOW);
  }
  if (dforaState == LOW) {
    digitalWrite(LEDPIN, HIGH);
  }
  else {
    digitalWrite(LEDPIN, LOW);
  }
  if (dcasaState && !dcasaLastState) {
    Serial.println("home Unbroken");
  }
  if (!dcasaState && dcasaLastState) {
    Serial.println("home Broken");
    printGoalmenos();
    home_goals--;
    printScore();
    if (home_goals == 5) {
      if (home_goals > away_goals) {
        home_wins++;
      }
      else {
        away_wins++;
      }
      home_goals = 0;
      away_goals = 0;
      delay(2000);
      printScore();
    }
  }
  if (awaySensorState && !awayLastState) {
    Serial.println("away Unbroken");
  }
  if (!awaySensorState && awayLastState) {
    Serial.println("away Broken");
    printGoalAWAY();
    blinkAway();
    blinkAway();
    blinkAway();
    blinkAway();
    blinkAway();
    blinkAway();
    apagado();
    away_goals++;
    printScore();
    if (away_goals == 5) {
      if (away_goals > home_goals) {
        away_wins++;
      }
      else {
        home_wins++;
      }
      away_goals = 0;
      home_goals = 0;
      delay(2000);
      printScore();
    }
  }
  if (dforaState && !dforaLastState) {
    Serial.println("away Unbroken");
  }
  if (!dforaState && dforaLastState) {
    Serial.println("away Broken");
    printGoalmenos();
    away_goals--;
    printScore();
    if (away_goals == 5) {
      if (away_goals > home_goals) {
        away_wins++;
      }
      else {
        home_wins++;
      }
      away_goals = 0;
      home_goals = 0;
      delay(2000);
      printScore();
    }
  }
  homeLastState = homeSensorState;
  awayLastState = awaySensorState;
  dcasaLastState = dcasaState;
  dforaLastState = dforaState;

}

Continua a ter iluminação fraca, leds com pouca intensidade. Amanhã já vejo as leitura com o multímetro para ver tensão e corrente, para perceber se está a chegar corrente necessaria

Continuo com o mesmo problema. Quando a fita led é acionada pelo pin output do arduino apenas chega pouco mais de 1.5volts à fita. Isto origina que os leds estejam muito fracos

Ok, vamos usar o método JACK.

Parte 1.
Cada cor de LED tem um valor de Forward Voltage:

  • Red: 2v (typical) * Blue: 3.2(typical) * Green: 3.2(typical).
    Portanto não se pode usar somente um resistor no pino comum (A ou K comum).

Verifique qual é a corrente e a voltagem forward de cada cor do seu LED e calcule o
resistor correto para cada cor com base na sua voltagem de alimentação.

Parte 2.
Teste
Usando o resistor correto em cada cor, verifique uma por vez se ela acende intensamente.

Parte 3.
Escreva um codigo bem simples, usando os pinos que voce vai usar no seu projeto final, e então faça acender individualmente cada LED por alguns segundos, e verifique se elas(as cores) acende intensamente.

Se não ocorrer assim, provavelmente quando voce ligou o LED sem resistor, ele foi danificado.

Solução: use outro LED novo.

Parece que está resolvido. Com um transitor bc547c, colocando a base na saída do pin do arduino, o colector no negativo e o emissor para a fita led, parece agora estar normal. De referir que na primeira vez que o fiz constatei que a iluminação permanecia sempre ligada, e piscava quando era acionado o sensor. Inverti os valores do código das cores, pois o quarto fio da fita é ligado com os 5v, e não com o gnd. Como a fita trabalha em 5v, sendo que a potência máxima do circuito não chega a 5v, não coloquei nenhum resistor.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.