hola no me muevo mucho con la programación de arduino y tengo el siguiente sketch a ver si alguien me puede editar el problema de antemano muchas gracias
el problema es que los led digamos encienden demasiado y me gustaría fueran un poco mas leves de iluminacion...
#ifdef REVERSE
#include <InvertedTM1638.h>
#else
#include <TM1638.h>
#endif
#define METRIC 1
#define ENGLISH 0
const int DATA_PIN=8;
const int CLOCK_PIN=7;
const int STROBE_PIN=9;
const byte SYSTEM=METRIC;
#ifdef REVERSE
InvertedTM1638 module(DATA_PIN, CLOCK_PIN, STROBE_PIN);
#else
TM1638 module(DATA_PIN, CLOCK_PIN, STROBE_PIN);
#endif
byte Gear,Buttons,Mode_Buttons, Previous_Mode_External;
int Speed, Fuel_Remaining;
String Velocidad, Velocidad2;
String Fuel, Fuel2;
word Vel;
const int TRAMA_LENGTH=13;
byte TramaSerie[TRAMA_LENGTH];
short int Puntero,Modo_Hud;
long Blink_Interval=50;
boolean Leds_up;
boolean External_Control;
word estado_leds=0;
unsigned long CurrentMillis, PreviousMillis=0;
word leds [10] = {0, 1, 3, 7, 15, 31, 8223, 24607, 57375, 65535};
void setup()
{
// Inicializar puerto serie a 9600 baudios
Serial.begin(9600);
Modo_Hud=-1;
Mode_Buttons=0;
Previous_Mode_External=0;
External_Control=true;
}
void loop()
{
Buttons=module.getButtons();
if (Buttons!=0)
{
switch(Buttons)
{
case 1: Mode_Buttons=0;
External_Control=false;
break;
case 2: Mode_Buttons=1;
External_Control=false;
break;
case 128: Mode_Buttons=99;
External_Control=false;
break;
}
}
if (Serial.available()>0)
{
if (Serial.available()>TRAMA_LENGTH)
{
Puntero=0;
memset(TramaSerie, 0, sizeof(TramaSerie));
TramaSerie[Puntero]=Serial.read();
if (TramaSerie[Puntero]==0xFF)
{
for (Puntero=1; Puntero<TRAMA_LENGTH; Puntero++)
{
TramaSerie[Puntero]=Serial.read();
}
if (TramaSerie[1]!=Previous_Mode_External)
{
External_Control=true;
}
if (!External_Control)
{
if( Mode_Buttons !=Modo_Hud)
{
module.clearDisplay();
}
switch(Mode_Buttons)
{
case 0: Display_Velocidad();
break;
case 1: Display_Fuel();
break;
case 99: Borrar_Display();
break;
default: Display_Velocidad();
break;
}
}
else
{
if( TramaSerie[1]!=Modo_Hud)
{
module.clearDisplay();
}
switch(TramaSerie[1])
{
case 0: Display_Velocidad();
break;
case 1: Display_Fuel();
break;
case 2: Display_DeltaTime1();
break;
case 99: Borrar_Display();
break;
default: Display_Velocidad();
break;
}
}
Previous_Mode_External=TramaSerie[1];
//Gestión de LED's
if (TramaSerie[5] == 9)
{
CurrentMillis=millis();
if (CurrentMillis - PreviousMillis > Blink_Interval)
{
PreviousMillis=CurrentMillis;
if ( Leds_up )
{
Leds_up=false;
module.setLEDs(65535);
estado_leds=65535;
}
else
{
Leds_up=true;
module.setLEDs(0);
estado_leds=0;
}
}
else
{
module.setLEDs(estado_leds);
}
}
else
{
module.setLEDs(leds[TramaSerie[5]]);
Leds_up=false;
estado_leds=65535;
}
}
}
}
}
void Display_Velocidad()
{
switch(TramaSerie[2])
{
case 255:
module.setDisplayToString("r", 0,0);
break;
case 0:
module.setDisplayToString("N", 0,0);
break;
default:
module.setDisplayToString(String(TramaSerie[2],DEC), 0,0);
}
Vel=(TramaSerie[4] << 8)| TramaSerie[3];
if (SYSTEM==ENGLISH)
{
Vel=round(Vel/1.609);
}
Velocidad=String(Vel,DEC);
Speed=Velocidad.length();
switch (Speed)
{
case 1: Velocidad2=" "+Velocidad;
break;
case 2: Velocidad2=" "+Velocidad;
break;
default: Velocidad2=Velocidad;
break;
}
module.setDisplayToString(Velocidad2, 0,5);
Modo_Hud=0;
}
void Display_Fuel()
{
module.setDisplayToString("FUEL",0,0);
Fuel=String(TramaSerie[6], DEC);
Fuel_Remaining=Fuel.length();
switch (Fuel_Remaining)
{
case 1: Fuel2=" "+Fuel;
break;
case 2: Fuel2=" "+Fuel;
break;
default: Fuel2=Fuel;
break;
}
module.setDisplayToString(Fuel2, 0, 5);
Modo_Hud=1;
}
void Borrar_Display()
{
if (Modo_Hud!=99)
{
module.setLEDs(0);
module.clearDisplay();
}
Modo_Hud=99;
}
void Test_Display()
{
module.setLEDs(leds[8]);
module.setDisplayToString("TM1638OK",0,0);
Modo_Hud=98;
}
void Display_DeltaTime1()
{
char buffer[8];
buffer[0]=TramaSerie[7];
buffer[1]=TramaSerie[8];
buffer[2]=TramaSerie[9];
buffer[3]=TramaSerie[11];
buffer[4]=TramaSerie[12];
buffer[5]='\0';
module.setDisplayToString("F1", 0,0);
module.setDisplayToString(buffer, 0b010000,3);
Modo_Hud=2;
}
decir que por supuesto no lo hice yo claro esta, si alguien me editara eh indicara cual es el valor a cambiar , si me lo edita mejor aun muchisimas gracias