Buenos días.
Actualmente tengo un Arduino Pro Micro con el cual programo una tira de led (u otros proyectos pequeños).
El código funciona correctamente (adjunto al final). Pero cuando quito la alimentación al arduino pro micro, se "desprograma" y tengo que volver a cargar el sketch para que funcione.
He estado mirando en varias páginas y quizá sea problema del bootloader. Mi problema es que en este mometno no dispongo de otro arduino (nano o uno) y no "Puedo" probarlo.
He seguido las instrucciones de este doble reset de la página:
https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/troubleshooting-and-faq
sin solución tampoco. ¿Se os ocurre algún otro método? ¿Puede ser otro tipo de problema?
Muchas gracias.
EDITO: Después de una serie de intentos he conseguido que funcionase. He usado el método del doble reset.
#include "FastLED.h"
// Number of independents LEDs
#define NUM_LEDS 24
// Output PIN (Data LED strip connection) definition
#define DATA_PIN 6
// This is an array of leds. One item for each led in your strip.
CRGB leds[NUM_LEDS];
// Data reception via serial counter.
int incomingByte = 0;
void setup()
{
Serial.begin(9600); // Opens serial port and set 9600bps
while (!Serial)
{
;// wait for serial line to be ready. Necessary for LEONARDO
}
// Initialize each segment
FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, NUM_LEDS);
}
void loop()
{
if (Serial.available() > 0) //
{
incomingByte = Serial.read();
switch (incomingByte)
{
case '1':
LEFT_ON();
break;
case '2':
RIGTH_ON();
break;
case '3':
LEFT_OFF();
break;
case '4':
RIGTH_OFF();
break;
case '5':
RAINBOW();
break;
default:
break;
}
}
}
void RIGTH_ON()
{
for (int i = 0; i < NUM_LEDS; i++)
{
if (Serial.available() == 0)
{
leds[i] = CRGB::Green;
FastLED.show(); // Show the leds
delay(30); // Wait a little bit to see led lighting
}
else break;
}
} //End RIGHT_ON
void RIGTH_OFF()
{
for (int i = 0; i < NUM_LEDS; i++)
{
if (Serial.available() == 0)
{
leds[i] = CRGB::Black;
FastLED.show(); // Show the leds
delay(30); // Wait a little bit to see led lighting
}
else break;
}
} //End RIGHT_OFF
void LEFT_ON()
{
for (int i = (NUM_LEDS - 1); i >= 0; i--)
{
if (Serial.available() == 0)
{
leds[i] = CRGB::Green;
FastLED.show(); // Show the leds
delay(30); // Wait a little bit to see led lighting
}
else break;
}
} // End LEFT_ON
void LEFT_OFF()
{
for (int i = (NUM_LEDS - 1); i >= 0; i--)
{
if (Serial.available() == 0)
{
leds[i] = CRGB::Black;
FastLED.show(); // Show the leds
delay(30); // Wait a little bit to see led lighting
}
else break;
}
} // End LEFT_OFF
void RAINBOW()
{
APAGARLEDS();
//First, shuffle all the current colors up one spot on the strip
for (int i = 0; i < NUM_LEDS; i++)
{
if (Serial.available() == 0)
{
leds[0].r = random(0xFF);
leds[0].g = random(0xFF);
leds[0].b = random(0xFF);
FastLED.show();
delay(100);
for (int j = (NUM_LEDS - 1); j > 0; j--) leds[j] = leds[j - 1];
}
else break;
}
} //End RAINBOW
// Funcion to turn all LEDs off
void APAGARLEDS()
{
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB::Black;
FastLED.show();
}
} //End APAGARLEDS