i uploaded a new version of a program to my arduino, now it is no longer recognized by the pc.
when i plug it in, a windows notification pos up saying "usb device not recognized", and the arduino does not appear in Tools/Port.
i think the reason is that i am overflowing an array in my program, which has to cause the arduino to no longer respond.
obviously, the reset button on the arduino only restearts the problematic program
is there a way to "clear" or hardreset the arduino?
using arduino 1.6.12 on aduino micro with fastLED library
full uploaded code with the overflow in the third loop:
#include <FastLED.h>
#define NUM_LEDS 60
#define DATA_PIN 6
#define BRIGHTNESS 16
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
uint8_t hue1 = 0;
uint8_t hueDelta = 1;
void setup() {
FastLED.addLeds<WS2812B, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
}
void loop() {
hue1 += hueDelta;
uint8_t hue2 = hue1 + 85;
uint8_t hue3 = hue1 - 85;
int thirdNumLeds = NUM_LEDS / 3;
for(int i = 0; i < thirdNumLeds; i++){
int hue = hueLerp(hue1, hue2, i*255/thirdNumLeds);
leds[i] = CHSV(hue, 255, 255);
}
for(int i = 0; i < thirdNumLeds; i++){
int hue = hueLerp(hue2, hue3, i*255/thirdNumLeds);
leds[i+thirdNumLeds] = CHSV(hue, 255, 255);
}
for(int i = 0; i < thirdNumLeds*3; i++){
int hue = hueLerp(hue3, hue1, i*255/thirdNumLeds);
leds[i+thirdNumLeds*2] = CHSV(hue, 255, 255);
}
FastLED.show();
delay(60);
}
uint8_t hueLerp(uint8_t a, uint8_t b, int lerp){ // lerp is from 0 to 255
int d = b-a; //difference from a to b
//if(d > 128) d -= 256; //make sure to lerp over the short "side"
//if(d < -128) d += 256;//so we do not lerp from 0 to 255 over 128
int result = a * 255 + d * lerp;
return result / 255;
}