So to start I have two Xiaos that won’t go into bootloader no matter how much I try to short the pads. I know how to do it normally because I’m constantly needing to trigger the bootloader.
Neither one will work even plugged into a battery pack, so it’s not just a PC thing.
What do I do? How do I get them so they can work again?
Also they both died after running the same sketch. I was just playing around with sounds on a piezo speaker. Can anyone spot anything in the code that would cause the board to kill itself?
I basically have a 2D array that I’m storing frequencies and duration in. As the loop function runs, it plays a little bit of the current note (durSeg) and keeps track of how much of that particular note needs to still play.
Once it’s played enough of that note, we copy all of the other array indices forward, and set the last index to 0,0. A non-zero duration is what triggers the code to play something. Otherwise it just skips the audio portion.
As part of the main loop, its also checking for a button press. If there is one, we add a tone and duration to the 0th index of the play track.
Otherwise there’s some code to add in some music (both at the start and into the track).
That’s it, but something apparently is killing my Xiaos here…
Summary
#define durSeg 30 #define wn 1000/durSeg #define hn 500/durSeg #define qn 250/durSeg #define en 125/durSeg #define sn 62/durSeg #define R1 0 #define NB0 31 #define NC1 33 #define NCS1 35 #define ND1 37 #define NDS1 39 #define NE1 41 #define NF1 44 #define NFS1 46 #define NG1 49 #define NGS1 52 #define NA1 55 #define NAS1 58 #define NB1 62 #define NC2 65 #define NCS2 69 #define ND2 73 #define NDS2 78 #define NE2 82 #define NF2 87 #define NFS2 93 #define NG2 98 #define NGS2 104 #define NA2 110 #define NAS2 117 #define NB2 123 #define NC3 131 #define NCS3 139 #define ND3 147 #define NDS3 156 #define NE3 165 #define NF3 175 #define NFS3 185 #define NG3 196 #define NGS3 208 #define NA3 220 #define NAS3 233 #define NB3 247 #define NC4 262 #define NCS4 277 #define ND4 294 #define NDS4 311 #define NE4 330 #define NF4 349 #define NFS4 370 #define NG4 392 #define NGS4 415 #define NA4 440 #define NAS4 466 #define NB4 494 #define NC5 523 #define NCS5 554 #define ND5 587 #define NDS5 622 #define NE5 659 #define NF5 698 #define NFS5 740 #define NG5 784 #define NGS5 831 #define NA5 880 #define NAS5 932 #define NB5 988 #define NC6 1047 #define NCS6 1109 #define ND6 1175 #define NDS6 1245 #define NE6 1319 #define NF6 1397 #define NFS6 1480 #define NG6 1568 #define NGS6 1661 #define NA6 1760 #define NAS6 1865 #define NB6 1976 #define NC7 2093 #define NCS7 2217 #define ND7 2349 #define NDS7 2489 #define NE7 2637 #define NF7 2794 #define NFS7 2960 #define NG7 3136 #define NGS7 3322 #define NA7 3520 #define NAS7 3729 #define NB7 3951 #define NC8 4186 #define NCS8 4435 #define ND8 4699 #define NDS8 4978 int sT[48][2] = { {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0} }; int pH = 0; void stAdd(int type=0){ sT[0][0] = 3200; sT[0][1] = 1; } void playST(){ int f = sT[0][0]; int d = sT[0][1]; int noteBreak = d*1.3; //noTone(6); if (d != 0){ tone(6, f, durSeg); delay(durSeg*1.3); if(d<2){ for (int x = 0; x<sizeof(sT)-1; x++){ sT[x][0]= sT[x+1][0]; sT[x][1]= sT[x+1][1]; } sT[sizeof(sT)-1][0]=0; sT[sizeof(sT)-1][1]=0; delay(noteBreak); }else{ sT[0][1]--; } } //noTone(6); } void setup() { int button_state = 1; pinMode(2, INPUT_PULLUP); sT[pH][0] =NA5; sT[pH][1] = qn; pH++; sT[pH][0] =NA5; sT[pH][1] = en; pH++; sT[pH][0] =NA5; sT[pH][1] = en; pH++; sT[pH][0] =NA5; sT[pH][1] = qn; pH++; sT[pH][0] =NA5; sT[pH][1] = en; pH++; sT[pH][0] =NA5; sT[pH][1] = en; pH++; sT[pH][0] =NA5; sT[pH][1] = qn; pH++; sT[pH][0] =NE4; sT[pH][1] = qn; pH++; sT[pH][0] =NF5; sT[pH][1] = qn; pH++; sT[pH][0] =NA5; sT[pH][1] = qn; pH++; sT[pH][0] =NG5; sT[pH][1] = qn; pH++; sT[pH][0] =NG5; sT[pH][1] = en; pH++; sT[pH][0] =NG5; sT[pH][1] = en; pH++; sT[pH][0] =NG5; sT[pH][1] = qn; pH++; sT[pH][0] =NG5; sT[pH][1] = en; pH++; sT[pH][0] =NG5; sT[pH][1] = en; pH++; sT[pH][0] =NG5; sT[pH][1] = qn; pH++; sT[pH][0] =NE4; sT[pH][1] = qn; pH++; sT[pH][0] =NE5; sT[pH][1] = qn; pH++; sT[pH][0] =NG5; sT[pH][1] = qn; pH++; sT[pH][0] =NA5; sT[pH][1] = qn; pH++; sT[pH][0] =NA5; sT[pH][1] = en; pH++; sT[pH][0] =NA5; sT[pH][1] = en; pH++; sT[pH][0] =NA5; sT[pH][1] = qn; pH++; sT[pH][0] =NA5; sT[pH][1] = en; pH++; sT[pH][0] =NA5; sT[pH][1] = en; pH++; sT[pH][0] =NA5; sT[pH][1] = qn; pH++; sT[pH][0] =NB5; sT[pH][1] = qn; pH++; sT[pH][0] =NC5; sT[pH][1] = qn; pH++; sT[pH][0] =ND5; sT[pH][1] = qn; pH++; sT[pH][0] =NC5; sT[pH][1] = qn; pH++; sT[pH][0] =NA5; sT[pH][1] = qn; pH++; sT[pH][0] =NG5; sT[pH][1] = qn; pH++; sT[pH][0] =NE5; sT[pH][1] = qn; pH++; sT[pH][0] =NF5; sT[pH][1] = hn; pH++; sT[pH][0] =NF5; sT[pH][1] = hn; pH++; tone(6, NA4, 250); delay(250*1.3); tone(6, NC5, 250); delay(250*1.3); tone(6, ND5, 250); delay(250*1.3); tone(6, NC4, 250); delay(250*1.3); tone(6, ND5, 250); delay(250*1.3); tone(6, ND5, 250); delay(250*1.3); tone(6, ND5, 250); delay(250*1.3); tone(6, NG5, 250); delay(250*1.3); tone(6, NF5, 250); delay(250*1.3); tone(6, NE5, 250); delay(250*1.3); tone(6, ND5, 250); delay(250*1.3); tone(6, NE5, 250); delay(250*1.3); tone(6, NE5, 250); delay(250*1.3); tone(6, NG5, 250); delay(250*1.3); tone(6, NA5, 250); delay(250*1.3); tone(6, ND5, 250); delay(250*1.3); tone(6, NC5, 250); delay(250*1.3); tone(6, NG5, 250); delay(250*1.3); tone(6, NG5, 250); delay(250*1.3); tone(6, NE5, 250); delay(250*1.3); tone(6, NG5, 250); delay(250*1.3); tone(6, NG5, 250); delay(250*1.3); tone(6, NA5, 250); delay(250*1.3); delay(1000); } void loop() { playST(); int button_state = digitalRead(2); if(button_state==0){ stAdd(0); } }