Étape 3: Code
Copie le code ci-dessous et le coller le code dans l’IDE Arduino, puis sélectionnez un port COM approprié et télécharger le code du One Linkit ci-dessous.
? * / 0 X 13, 0 X 43, 0X5B, 0 X 0, 0 X 0, 0 X 0 0 X 0, / * 03, * / 0 X 13, 0 X 43, 0X5B, 0 X 0, 0 X 0, 0 X 0 0 X 0, / * 04-* / 0XA, 0 X 54, 0X6E, 0XD, 0XA, 0 X 8, 0 X 0, / * 05 IY * / 0XE, 0 X 49, 0X5D, 0XD, 0 X 8, 0 X 7, 0 X 0, / * 06 IH * / 0 X 13, 0 X 43, 0X5B, 0XE, 0XD, 0 X 8, 0 X 0, / * 07 EH * / 0 X 18, 0X3F, 0 X 58, 0XF 0XE, 0 X 8, 0 X 0, / * 08 AE * / 0X1B, 0 X 28, 0 X 59, 0XF, 0XD, 0 X 1, 0 X 0, / * 09 AA * / 0 X 17 , 0X2C, 0 X 57, 0XF, 0XC, 0 X 1, 0 X 0, / * 10 AH * / 0 X 15, 0X1F, 0 X 58, 0XF, 0XC, 0 X 0 0 X 0, / * 11 AO * / 0 X 10, 0 X 25, 0 X 52, 0XF, 0XB, 0 X 1, 0 X 0, / * 12 EUH * / 0 X 14, 0X2C, 0 X 57, 0XE, 0XB, 0 X 0 0 X 0, / * AX 13 * / 0XE, 0 X 49, 0X5D, 0XD, 0XB, 0 X 7, 0 X 0, / * 14 IX * / 0 X 12, 0 X 31, 0X3E, 0 X 0, 0 X 5, 0XB, 0XC / * 15 ER * / 0XE, 0 X 24, 0 X 52, 0XF, 0XC, 0 X 1, 0 X 0, / * 16 UX * / 0 X 12 , 0X1E, 0 X 58, 0XF, 0XC, 0 X 0 0 X 0, / * 17 OH * / 0 X 12, 0 X 33, 0X3E, 0XD, 0XC, 0 X 6, 0 X 0, / * 18 RX * / 0 X 10, 0 X 25, 0X6E, 0XD, 0 X 8, 0 X 1, 0 X 0, / * 19 LX * / 0XD, 0X1D, 0 X 50, 0XD, 0 X 8, 0 X 0 0 X 0, / * WX 20 * / 0XF, 0 X 45, 0X5D, 0XE, 0XC, 0 X 7, 0 X 0, / * 21 YX * / 0XB, 0 X 18, 0X5A, 0XD, 0 X 8, 0 X 0 0 X 0, / * 22 WH * / 0 X 12, 0 X 32, 0X3C, 0XC, 0XA, 0 X 5, 0 X 0, / * 23 R * / 0XE , 0X1E, 0X6E, 0XD, 0 X 8, 0 X 1, 0 X 0, / * 24 L * / 0XB, 0 X 18, 0X5A, 0XD, 0 X 8, 0 X 0 0 X 0, / * 25 W * / 0 X 9, 0 X 53, 0X6E, 0XD, 0XA, 0 X 8, 0 X 0, / * 26 Y * / 0 X 6, 0X2E, 0 X 51, 0XC, 0 X 3, 0 X 0 0 X 0, / * 27 M * / 0 X 6, 0 X 36, 0X79, 0 X 9, 0 X 9, 0 X 0 0 X 0, / * 28 N * / 0 X 6, 0 X 56, 0 X 65, 0 X 9, 0 X 6, 0 X 3, 0 X 0, / * 29 NX * / 0 X 6, 0 X 36, 0X79, 0 X 0, 0 X 0, 0 X 0 0 X 0, / * 30 DX * / 0 X 11 , 0 X 43, 0X5B, 0 X 0, 0 X 0, 0 X 0 0 X 0, / * 31 Q * / 0 X 6, 0 X 49, 0 X 63, 0 X 7, 0XA, 0XD 0XF, / * 32 S * / 0 X 6, 0X4F, 0X6A, 0 X 0, 0 X 0, 0 X 0 0 X 0, / * 33 SH * / 0 X 6, 0X1A, 0 X 51, 0 X 3, 0 X 3, 0 X 3, 0XF, / * 34 F * / 0 X 6, 0 X 42, 0X79, 0 X 0, 0 X 0, 0 X 0 0 X 0, / * 35 TH * / 0XE, 0 X 49, 0X5D, 0 X 0, 0 X 0, 0 X 0 0 X 0, / * /H* 36 / 0 X 10, 0 X 25, 0 X 52, 0 X 0, 0 X 0, 0 X 0 0 X 0, / * 37 /X* / 0 X 9 , 0 x 33, 0x5d, 0xf, 0 x 3, 0 x 3, 0 x 0 / * 38 Z * / 0xa, 0 x 42, 0x67, 0xb, 0 x 5, 0 x 1, 0 x 0, / * 39 ZH * / 0 x 8, 0 x 28, 0x4c, 0xb, 0 x 3, 0 x 0 0 x 0, / * 40 V * / 0xa, 0x2f, 0x5d, 0xb, 0 x 4, 0 x 0 0 x 0, / * 41 DH * / 0 x 6, 0x4f, 0 x 65, 0 x 0, 0 x 0, 0 x 0 0 x 0, / * 42 CHa * / 0 x 6, 0x4f, 0 x 65, 0 x 0, 0 x 0, 0 x 0 0 x 0, / * 43 CHb * / 0 x 6, 0 x 42, 0x79, 0 x 1, 0 x 0, 0 x 0 0 x 0, / * 44 Ja * / 0 x 5 , 0 x 42, 0x79, 0 x 1, 0 x 0, 0 x 0 0 x 0, / * 45 Jb * / 0 x 6, 0x6e, 0x79, 0 x 0, 0xa, 0xe, 0 x 0, / * 46 Jc * / 0 x 0 0 x 0, 0 x 0, 0 x 2, 0 x 2, 0 x 1, 0 x 0, / * 47 Jd * / 0 x 13, 0 x 48, 0x5a, 0xe, 0xe, 0 x 9, 0 x 0, / * 48 EY * / 0x1b, 0 x 27, 0 x 58, 0xf, 0xd, 0 x 1, 0 x 0, / * 49 AY * / 0 x 15, 0x1f, 0 x 58, 0xf, 0xc, 0 x 0 0 x 0, / * 50 OY * / 0x1b, 0x2b, 0 x 58, 0xf, 0xd, 0 x 1, 0 x 0, / * 51 AW * / 0 x 12 , 0x1e, 0 x 58, 0xf, 0xc, 0 x 0 0 x 0, / * 52 * OW / 0xd, 0 x 22, 0 x 52, 0xd, 0 x 8, 0 x 0 0 x 0, / * 53 UW * / 0 x 6, 0x1a, 0 x 51, 0 x 2, 0 x 0, 0 x 0 0 x 0, / * 54 Ba * / 0 x 6, 0x1a, 0 x 51, 0 x 4, 0 x 1, 0 x 0, 0xf, / * 55 Bb * / 0 x 6, 0x1a, 0 x 51, 0 x 0, 0 x 0, 0 x 0 0 x 0, / * 56 Bc * / 0 x 6, 0 x 42, 0x79, 0 x 2, 0 x 0, 0 x 0 0 x 0, / * 57 Da * / 0 x 6, 0 x 42, 0x79, 0 x 4, 0 x 1, 0 x 0, 0xf, / * 58 Db * / 0 x 6 , 0 x 42, 0x79, 0 x 0, 0 x 0, 0 x 0 0 x 0, / * 59 dc * / 0 x 6, 0x6e, 0 x 70, 0 x 1, 0 x 0, 0 x 0 0 x 0, / * 60 Ga * / 0 x 6, 0x6e, 0x6e, 0 x 4, 0 x 1, 0 x 0, 0xf, / * 61 Gb * / 0 x 6, 0x6e, 0x6e, 0 x 0, 0 x 0, 0 x 0 0 x 0, / * 62 Gc * / 0 x 6, 0 x 54, 0x5e, 0 x 1, 0 x 0, 0 x 0 0 x 0, / * 63 GXa * / 0 x 6, 0 x 54, 0x5e, 0 x 4, 0 x 1, 0 x 0, 0xf, / * 64 GXb * / 0 x 6, 0 x 54, 0x5e, 0 x 0, 0 x 0, 0 x 0 0 x 0, / * 65 GXc * / 0 x 6 , 0x1a, 0 x 51, 0 x 0, 0 x 0, 0 x 0 0 x 0, / * 66 Pa * / 0 x 6, 0x1a, 0 x 51, 0 x 0, 0 x 0, 0 x 0 0 x 0, / * 67 Pb * / 0 x 6, 0x1a, 0 x 51, 0 x 0, 0 x 0, 0 x 0 0 x 0, / * 68 Pc * / 0 x 6, 0 x 42, 0x79, 0 x 0, 0 x 0, 0 x 0 0 x 0, / * 69 Ta * / 0 x 6, 0 x 42, 0x79, 0 x 0, 0 x 0, 0 x 0 0 x 0, / * 70 CT * / 0 x 6, 0 x 42, 0x79, 0 x 0, 0 x 0, 0 x 0 0 x 0, / * Tc 71 * / 0 x 6, 0x6d, 0 x 65, 0 x 0, 0 x 0, 0 x 0 0 x 0, / * 72 Ka * / 0xa 0 x 56, 0 x 65, 0xc, 0xa, 0 x 7, 0 x 0, / * 73 Ko * / 0xa, 0x6d, 0 x 70, 0 x 0, 0 x 0, 0 x 0 0 x 0, / * 74 Kc * / 0 x 6, 0 x 54, 0x5e, 0 x 0, 0 x 0, 0 x 0 0 x 0, / * KXa 75 * / 0 x 6, 0 x 54, 0x5e, 0 x 0, 0xa, 0 x 5, 0 x 0, / * 76 KXb * / 0 x 6, 0 x 54, 0x5e, 0 x 0, 0 x 0, 0 x 0 0 x 0 / * 77 type * /}; uint16_t pitchTable [64] = {/ / couvertures A1 à C7 58,61,65,69,73,77,82,86,92,97, 103,109,115,122,129,137,145,154,163,173, 183,194,206,218,231,244,259,274,291,308, 326,346,366,388,411,435,461,489,518,549, 581,616,652,691,732,776,822,871,923,978, 1036,1097,1163,1232,1305,1383,1465,1552,1644,1742, 1845,1955,2071,2195}; uint8_t frameList [] PROGMEM = {#if 1 _Da , 3,0,39, Private, 1, 0, 39, _Dc, 1, 3, 39, installation, 8, 6, 39, _YX, 3, 20, 39, / / Dai... _Z, 10, 0, 36, _IY, 3, 35, 36, / /... Sy _Da, 3, 0, 32, Private, 1, 0, 32, _Dc, 1, 3, 32, installation, 8, 6, 32, _YX, 3, 20, 32, / / Dai... _Z, 10, 0, 27, _IY, 35, 3, 27, / /... Sy _Ga, 2, 0, 29, _Gb, 2, 0, 29, _Gc, 2, 0, 29, _IH, 10, 3, 29, _V, 5, 0, 29, / / donner _M, 2, 0, 31, _IY, 10, 3, 31, / / me _YX, 5, 0, 32, _AO, 10, 0, 32, _RX, 5, 0, 32, / / votre _AH, 25, 0, 29, _NX, 5, 0, 29, / / une... _S, 2, 0, 32, _ER, 10, 0, 32, _RX, 3, 0, 32, / /... SWER _Da, 3, 0, 27, Private, 1, 0, 27, _Dc, 1, 3, 27, _UX, 80, 3, 27, _WX, 5, 0, 27, / / do _AY, 5, 20, 34, _YX, 10, 0, 34, _M, 8, 0, 34, / / je suis __H, 5, 0, 39, _AX, 0, 30, 39, _F, 10, 0, 39, / / moitié _Ka, 3, 0, 36, o KB, 3, 0, 36, _Kc, 4, 0, 36, _R, 5, 0, 36, installation, 30, 0, 36, / / arc... _Z, 5, 0, 32, _IY, 0, 40, 32, / /... zy _AO,10,0,29,_LX,5,0,29, // all _F,5,0,31,_AO,10,0,31, // for _DH,5,0,32,_AH,10,0,32, // the _L,5,0,34,_AH,20,0,34,_V,5,0,34,// love _AA,10,0,36,_V,5,0,36,// of _Y,10,0,34,_UX,80,0,34, // you _IH,10,0,36,_Ta,2,0,36,_Tb,1,0,36,_Tc,2,0,36,// It _W,2,0,37,_OH,10,0,37,_N,1,0,37,_Ta,1,0,37,_Tb,1,0,37,_Tc,1,0,37,// won't _Ba,2,0,36,_Bb,1,0,36,_Bc,2,0,36 , _IY, 10, 0, 36, / / be _AH, 15, 0, 34, / / a _S, 2, 0, 39, _Ta, 2, 0, 39, _Tb, 2, 0, 39, _Tc, 2, 0, 39, _AY, 1, 10, 39, _YX, 10, 0, 39, / / sty... _L, 3, 0, 36, _IH, 10, 0, 36, _SH, 2, 0, 36, / /... Lish _M, 5, 0, 34, _AE, 10, 0, 34, / / ma... _R, 5, 0, 32, _IH, 60, 0, 32, _Ja, 2, 0, 32, _Jb, 2, 0, 32, _Jc, 2, 0, 32, / /... distribution _AY, 5, 10, 34, _YX, 5, 0, 34, / / je _Ka, 2, 0, 36, o KB, 2, 0, 36, _Kc, 2, 0, 36, _AH, 20, 0, 36, _N, 2, 0, 36, _Ta, 2, 0, 36, _Tb, 2, 0, 26, _Tc, 2, 0, 36, / / ne peut pas _AX, 15, 0, 32, / / a... _F, 5, 0, 29, _AO, 20, 0, 29, _R, 2, 0, 29, _Da, 1, 0, 29, Private, 1, 0, 29, _Dc, 1, 0, 29, / /... FfORd _AX, 15, 0, 32, / / a _Ka, 1, 0, 29, o KB, 1, 0, 29, _Kc, 1, 0, 29, _AE, 12, 0, 29, / / ca.. _R, 5, 0, 27, _IH, 45, 0, 27, _Ja, 2, 0, 27, _Jb, 2, 0, 27, _Jc, 2, 0, 27, / /... _Ba distribution, 1, 0, 27, _Bb, 1, 0, 27, _Bc, 1, 0, 27, _AH, 10, 0, 27, _Ta, 1, 0, 27, _Tb, 1, 0, 27, _Tc, 1, 0, 27, / / mais FLF, 5, 0, 32, _UH, 10, 10, 32, _L, 5, 0, 32, / / you'll _L, 3, 0, 36, _UH, 10, 0, 36, _Ka, 1, 0, 36, o KB, 1, 0, 36, _Kc, 1, 0, 36, / / look _S, 2, 0, 34, _W, 2, 0, 34, _IY, 20, 0, 34, _Ta, 2, 0, 34, _Tb, 2, 0, 34, _Tc, 2, 0, 34, / / sweet _AX, 15, 0, 27, / / a... _Ka, 2, 0, 32, o KB, 2, 0, 32, _Kc, 2, 0, 32, _R, 2, 0, 32, _AA, 20, 0, 32, _S, 5, 0, 32, / /... Croix de _DH, 5, 0, 36, _AH, 10, 0, 36, / / le _S, 2, 0, 34, _IY, 10, 0, 34, _Ta, 2, 0, 34, _Tb, 2, 0, 34, _Tc, 2, 0, 34, / / siège _AA, 10, 0, 36, _V, 5, 0, 36, / / de _AE, 15, 0, 37, / / a _Ba, 2, 0, 39, _Bb, 2, 0, 39, _Bc, 2, 0, 39, _AY, 5, 5, 39, _YX, 5, 0, 39, / / bi... _S, 5, 0, 36, _IH, 10, 0, 36, / /... CY... _Ka, 2, 0, 32, o KB, 2, 0, 32, _Kc, 2, 0, 32, _L, 9, 0, 32, / /... cle _M, 2, 0, 34, installation, 5, 10, 34, _YX, 10, 0, 34, _Da, 2, 0, 34, Private, 2, 0, 34, _Dc, 2, 0, 34, / / fait _F, 5, 0, 27, _OY, 1, 5, 27, _RX, 5, 0, 27, / / pour _Ta, 2, 0, 32, _Tb, 2, 0, 32, _Tc, 2, 0, 32, _UX, 50, 0, 32, / / deux #endif _Ta, 0, 0, 61}; int frameTime = 15 ; MS uint16_t basePitch ; int formantScale ; void loop() {formantScale = uint8_t ; //54 ; //random (20,80), 54 * framePos = frameList ; while(1) {int n; uint8_t startFormant, staticFrames, tweenFrames ; uint16_t startPitch, nextPitch ; uint8_t nextFormant ; int16_t startForm1PhaseInc, startForm2PhaseInc, startForm3PhaseInc ; uint8_t startForm1Amp, startForm2Amp, startForm3Amp ; uint8_t startMod ; uint8_t * formantPos; / / lire la prochaine framelist point startFormant = pgm_read_byte(framePos++) ; staticFrames = pgm_read_byte(framePos++) ; if (! staticFrames) break; / / fin de phrase tweenFrames = pgm_read_byte(framePos++) ; startPitch = pitchTable[pgm_read_byte(framePos++)]; nextFormant = pgm_read_byte () framePos) ; nextPitch = pitchTable[pgm_read_byte(framePos+3)] ; pitchPhaseInc = startPitch ; formantPos = formantTable + startFormant * FORMANT_SZ ; form1PhaseInc = startForm1PhaseInc = pgm_read_byte(formantPos++) * formantScale ; form2PhaseInc = startForm2PhaseInc = pgm_read_byte(formantPos++) * formantScale ; form3PhaseInc = startForm3PhaseInc = pgm_read_byte(formantPos++) * formantScale ; form1Amp = startForm1Amp = pgm_read_byte(formantPos++) ; form2Amp = startForm2Amp = pgm_read_byte(formantPos++) ; form3Amp = startForm3Amp = pgm_read_byte(formantPos++) ; noiseMod = startMod = pgm_read_byte(formantPos++) ; pour (; staticFrames--;) delay(frameTime) ; if (tweenFrames) {uint8_t * formantPos int16_t deltaForm1PhaseInc, deltaForm2PhaseInc, deltaForm3PhaseInc int8_t deltaForm1Amp, deltaForm2Amp, deltaForm3Amp ; int8_t deltaMod ; uint8_t nextMod ; deltaPitch int16_t ; tweenFrames--; formantPos = formantTable + nextFormant * FORMANT_SZ ; deltaForm1PhaseInc = pgm_read_byte(formantPos++) * formantScale - startForm1PhaseInc ; deltaForm2PhaseInc = pgm_read_byte(formantPos++) * formantScale - startForm2PhaseInc ; deltaForm3PhaseInc = pgm_read_byte(formantPos++) * formantScale - startForm3PhaseInc ; deltaForm1Amp = pgm_read_byte(formantPos++) - startForm1Amp ; deltaForm2Amp = pgm_read_byte(formantPos++) - startForm2Amp ; deltaForm3Amp = pgm_read_byte(formantPos++) - startForm3Amp ; deltaMod = pgm_read_byte(formantPos++) - startMod ; deltaPitch = nextPitch - startPitch ; deltaMod = nextMod - startMod ; pour (int j’ai = 1; j’ai < = tweenFrames; i ++) {form1PhaseInc = startForm1PhaseInc + (j’ai * deltaForm1PhaseInc) / tweenFrames ; form2PhaseInc = startForm2PhaseInc + (j’ai * deltaForm2PhaseInc) / tweenFrames ; form3PhaseInc = startForm3PhaseInc + (j’ai * deltaForm3PhaseInc) / tweenFrames ; form1Amp = startForm1Amp + (j’ai * deltaForm1Amp) / tweenFrames ; form2Amp = startForm2Amp + (j’ai * deltaForm2Amp) / tweenFrames ; form3Amp = startForm3Amp + (j’ai * deltaForm3Amp) / tweenFrames ; pitchPhaseInc = startPitch + (j’ai * deltaPitch) / tweenFrames ; noiseMod = startMod + (j’ai * deltaMod) / tweenFrames ; delay(frameTime);}} } delay(300) ; } SIGNAL(PWM_INTERRUPT) {int8_t valeur ; public static int8_t bruit ; int16_t phaseNoise = bruit * noiseMod ; bruit bruit += << 2; bruit ++; / / noise' = 5 * bruit + 1 form1Phase += form1PhaseInc ; valeur = pgm_read_byte (sinCalc + (((form1Phase >> 8) & 0xf0) | form1Amp)); form2Phase += form2PhaseInc ; valeur += pgm_read_byte (sinCalc + (((form2Phase >> 8) & 0xf0) | form2Amp)); form3Phase += form3PhaseInc ; valeur += pgm_read_byte (sqrCalc + (((form3Phase >> 8) & 0xf0) | form3Amp)); valeur = (valeur * (0xff ^ (pitchPhase >> 8))) >> 8; pitchPhase += pitchPhaseInc ; si (() pitchPhase + phaseNoise) < pitchPhaseInc) {form1Phase = 0; form2Phase = 0; form3Phase = 0;} PWM_VALUE = valeur + 0 x 80 ; }