0

neopixel won't turn off
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

neopixel won't turn off

by schlaepfer on Thu Feb 14, 2019 10:22 am

Hello,

I am working on a project involving 5 neopixel fading in and out one after the other. The whole thing is powered by a Teensy 3.2.

The code is the following:
Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_NeoPixel.h>

#define DATA_PIN 7
#define NLEDS 5

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NLEDS, DATA_PIN, NEO_RGBW + NEO_KHZ800);

#define STEP 1000
#define WAIT 1
#define INTER1 50
#define INTER2 20
#define MAX 250

int val1 = 0;
int val2 = 0;
int val3 = 0;
int val4 = 0;
int val5 = 0;

void setup() {
  strip.begin();
  strip.show();
}

void loop() {
  for (int i=0;i< STEP;i++) {
    val5 = map(i,0, STEP,0,INTER1);
    strip.setPixelColor(4, 0, 0, 0, val5);
    strip.show();
    delay(WAIT);
  }
  delay(WAIT*5);
  for (int i=0;i< STEP;i++) {
    val4 = map(i,0, STEP,0,INTER1);
    strip.setPixelColor(3, 0, 0, 0, val4);
    strip.show();
    delay(WAIT);
  }
  delay(WAIT*5);
  for (int i=0;i< STEP;i++) {
    val3 = map(i,0, STEP,0,INTER1);
    strip.setPixelColor(2, 0, 0, 0, val3);
    val5 = map(i,0, STEP,INTER1,INTER2);
    strip.setPixelColor(4, 0, 0, 0, val5);
    strip.show();
    delay(WAIT);
  }
  for (int i=0;i< STEP;i++) {
    val2 = map(i,0, STEP,0,INTER1);
    strip.setPixelColor(1, 0, 0, 0, val2);
    val4 = map(i,0, STEP,INTER1,INTER2);
    strip.setPixelColor(3, 0, 0, 0, val4);
    strip.show();
    delay(WAIT);
  }
  for (int i=0;i< STEP;i++) {
    val1 = map(i,0, STEP,0,INTER1);
    strip.setPixelColor(0, 0, 0, 0, val1);
    val3 = map(i,0, STEP,INTER1,INTER2);
    strip.setPixelColor(2, 0, 0, 0, val3);
    val5 = map(i,0, STEP,INTER2,MAX);
    strip.setPixelColor(4, 0, 0, 0, val5);
    strip.show();
    delay(WAIT);
  }
  for (int i=0;i< STEP;i++) {
    val2 = map(i,0, STEP,INTER1,INTER2);
    strip.setPixelColor(1, 0, 0, 0, val2);
    val4 = map(i,0, STEP,INTER2,MAX);
    strip.setPixelColor(3, 0, 0, 0, val4);
    val5 = map(i,0, STEP,MAX,INTER2);
    strip.setPixelColor(4, 0, 0, 0, val5);
    strip.show();
    delay(WAIT);
  }
  for (int i=0;i< STEP;i++) {
    val1 = map(i,0, STEP,INTER1,INTER2);
    strip.setPixelColor(0, 0, 0, 0, val1);
    val3 = map(i,0, STEP,INTER2,MAX);
    strip.setPixelColor(2, 0, 0, 0, val3);
    val4 = map(i,0, STEP,MAX,INTER2);
    strip.setPixelColor(3, 0, 0, 0, val4);
    strip.show();
    delay(WAIT);
  }
  for (int i=0;i< STEP;i++) {
    val2 = map(i,0, STEP,INTER2,MAX);
    strip.setPixelColor(1, 0, 0, 0, val2);
    val3 = map(i,0, STEP,MAX,INTER2);
    strip.setPixelColor(2, 0, 0, 0, val3);
    val5 = map(i,0, STEP,INTER2,INTER1);
    strip.setPixelColor(4, 0, 0, 0, val5);
    strip.show();
    delay(WAIT);
  }
  for (int i=0;i< STEP;i++) {
    val1 = map(i,0, STEP,INTER2,MAX);
    strip.setPixelColor(0, 0, 0, 0, val1);
    val2 = map(i,0, STEP,MAX,INTER2);
    strip.setPixelColor(1, 0, 0, 0, val2);
    val4 = map(i,0, STEP,INTER2,INTER1);
    strip.setPixelColor(3, 0, 0, 0, val4);
    strip.show();
    delay(WAIT);
  }
  for (int i=0;i< STEP;i++) {
    val1 = map(i,0, STEP,MAX,INTER2);
    strip.setPixelColor(0, 0, 0, 0, val1);
    val3 = map(i,0, STEP,INTER2,INTER1);
    strip.setPixelColor(2, 0, 0, 0, val3);
    val5 = map(i,0, STEP,INTER1,0);
    strip.setPixelColor(4, 0, 0, 0, val5);
    strip.show();
    delay(WAIT);
  }
  for (int i=0;i< STEP;i++) {
    val2 = map(i,0, STEP,INTER2,INTER1);
    strip.setPixelColor(1, 0, 0, 0, val2);
    val4 = map(i,0, STEP,INTER1,0);
    strip.setPixelColor(3, 0, 0, 0, val4);
    strip.show();
    delay(WAIT);
  }
  for (int i=0;i< STEP;i++) {
    val1 = map(i,0, STEP,INTER2,INTER1);
    strip.setPixelColor(0, 0, 0, 0, val1);
    val3 = map(i,0, STEP,INTER1,0);
    strip.setPixelColor(2, 0, 0, 0, val3);
    strip.show();
    delay(WAIT);
  }
  for (int i=0;i< STEP;i++) {
    val2 = map(i,0, STEP,INTER1,0);
    strip.setPixelColor(1, 0, 0, 0, val2);
    strip.show();
    delay(WAIT);
  }
  for (int i=0;i< STEP;i++) {
    val1 = map(i,0, STEP,INTER1,0);
    strip.setPixelColor(0, 0, 0, 0, val1);
    strip.show();
    delay(WAIT);
  }
  delay(2000);
 
}


Everything works fine, except for one thing (of course): at the end of the loop, the leds never turn off completely. They are always emitting a little light, as if it was set on something between 1 and 5, I'd say.

I tried to change the value of STEP to 100, but it doesn't change much.

The Neopixel are 5 from a RGBW 60LED strip (ID 2842), and the Teensy is running at 72MHz (I also tried at 48MHz, but it doesn't affect the result).

Do you have any idea where it could come from?

schlaepfer
 
Posts: 7
Joined: Mon Mar 07, 2016 10:52 am

Re: neopixel won't turn off

by adafruit_support_bill on Thu Feb 14, 2019 10:32 am

Your loop goes from zero to step-1
Code: Select all | TOGGLE FULL SIZE
for (int i=0;i< STEP;i++)

Since i is never equal to STEP, your map will never return zero:
Code: Select all | TOGGLE FULL SIZE
val1 = map(i,0, STEP,INTER1,0);


Try:
Code: Select all | TOGGLE FULL SIZE
for (int i=0;i<= STEP;i++)

adafruit_support_bill
 
Posts: 72783
Joined: Sat Feb 07, 2009 10:11 am

Re: neopixel won't turn off

by schlaepfer on Thu Feb 14, 2019 10:56 am

Oh, it seems obvious now, but in this case, my "for" will loop through 1001 steps, right? Thanks for pointing this out.

However, it doesn't solve my problem either. I put a little Serial.println on my last "for" loop, returning the "val1" value. And it turns out it goes all the way down from 50 (INTER1) to 2 (each value is sent 20 or 21 times, which makes the count to 1001). I don't understand why it doesn't do the last two steps :-s

schlaepfer
 
Posts: 7
Joined: Mon Mar 07, 2016 10:52 am

Re: neopixel won't turn off

by adafruit_support_bill on Thu Feb 14, 2019 12:41 pm

Can you post the last few steps of the serial output - showing the values of both 'i' and 'val1'?

adafruit_support_bill
 
Posts: 72783
Joined: Sat Feb 07, 2009 10:11 am

Re: neopixel won't turn off

by schlaepfer on Thu Feb 14, 2019 12:59 pm

Of course, here it is, for the last two "for" loops. The output shows "i - val" (respectively val2 and val1)
Code: Select all | TOGGLE FULL SIZE
START
0 - 50
1 - 50
2 - 50
3 - 50
4 - 50
5 - 50
6 - 50
7 - 50
8 - 50
9 - 50
10 - 50
11 - 50
12 - 50
13 - 50
14 - 50
15 - 50
16 - 50
17 - 50
18 - 50
19 - 50
20 - 50
21 - 49
22 - 49
23 - 49
24 - 49
25 - 49
26 - 49
27 - 49
28 - 49
29 - 49
30 - 49
31 - 49
32 - 49
33 - 49
34 - 49
35 - 49
36 - 49
37 - 49
38 - 49
39 - 49
40 - 49
41 - 48
42 - 48
43 - 48
44 - 48
45 - 48
46 - 48
47 - 48
48 - 48
49 - 48
50 - 48
51 - 48
52 - 48
53 - 48
54 - 48
55 - 48
56 - 48
57 - 48
58 - 48
59 - 48
60 - 48
61 - 48
62 - 47
63 - 47
64 - 47
65 - 47
66 - 47
67 - 47
68 - 47
69 - 47
70 - 47
71 - 47
72 - 47
73 - 47
74 - 47
75 - 47
76 - 47
77 - 47
78 - 47
79 - 47
80 - 47
81 - 47
82 - 46
83 - 46
84 - 46
85 - 46
86 - 46
87 - 46
88 - 46
89 - 46
90 - 46
91 - 46
92 - 46
93 - 46
94 - 46
95 - 46
96 - 46
97 - 46
98 - 46
99 - 46
100 - 46
101 - 46
102 - 46
103 - 45
104 - 45
105 - 45
106 - 45
107 - 45
108 - 45
109 - 45
110 - 45
111 - 45
112 - 45
113 - 45
114 - 45
115 - 45
116 - 45
117 - 45
118 - 45
119 - 45
120 - 45
121 - 45
122 - 45
123 - 44
124 - 44
125 - 44
126 - 44
127 - 44
128 - 44
129 - 44
130 - 44
131 - 44
132 - 44
133 - 44
134 - 44
135 - 44
136 - 44
137 - 44
138 - 44
139 - 44
140 - 44
141 - 44
142 - 44
143 - 43
144 - 43
145 - 43
146 - 43
147 - 43
148 - 43
149 - 43
150 - 43
151 - 43
152 - 43
153 - 43
154 - 43
155 - 43
156 - 43
157 - 43
158 - 43
159 - 43
160 - 43
161 - 43
162 - 43
163 - 43
164 - 42
165 - 42
166 - 42
167 - 42
168 - 42
169 - 42
170 - 42
171 - 42
172 - 42
173 - 42
174 - 42
175 - 42
176 - 42
177 - 42
178 - 42
179 - 42
180 - 42
181 - 42
182 - 42
183 - 42
184 - 41
185 - 41
186 - 41
187 - 41
188 - 41
189 - 41
190 - 41
191 - 41
192 - 41
193 - 41
194 - 41
195 - 41
196 - 41
197 - 41
198 - 41
199 - 41
200 - 41
201 - 41
202 - 41
203 - 41
204 - 41
205 - 40
206 - 40
207 - 40
208 - 40
209 - 40
210 - 40
211 - 40
212 - 40
213 - 40
214 - 40
215 - 40
216 - 40
217 - 40
218 - 40
219 - 40
220 - 40
221 - 40
222 - 40
223 - 40
224 - 40
225 - 39
226 - 39
227 - 39
228 - 39
229 - 39
230 - 39
231 - 39
232 - 39
233 - 39
234 - 39
235 - 39
236 - 39
237 - 39
238 - 39
239 - 39
240 - 39
241 - 39
242 - 39
243 - 39
244 - 39
245 - 39
246 - 38
247 - 38
248 - 38
249 - 38
250 - 38
251 - 38
252 - 38
253 - 38
254 - 38
255 - 38
256 - 38
257 - 38
258 - 38
259 - 38
260 - 38
261 - 38
262 - 38
263 - 38
264 - 38
265 - 38
266 - 37
267 - 37
268 - 37
269 - 37
270 - 37
271 - 37
272 - 37
273 - 37
274 - 37
275 - 37
276 - 37
277 - 37
278 - 37
279 - 37
280 - 37
281 - 37
282 - 37
283 - 37
284 - 37
285 - 37
286 - 36
287 - 36
288 - 36
289 - 36
290 - 36
291 - 36
292 - 36
293 - 36
294 - 36
295 - 36
296 - 36
297 - 36
298 - 36
299 - 36
300 - 36
301 - 36
302 - 36
303 - 36
304 - 36
305 - 36
306 - 36
307 - 35
308 - 35
309 - 35
310 - 35
311 - 35
312 - 35
313 - 35
314 - 35
315 - 35
316 - 35
317 - 35
318 - 35
319 - 35
320 - 35
321 - 35
322 - 35
323 - 35
324 - 35
325 - 35
326 - 35
327 - 34
328 - 34
329 - 34
330 - 34
331 - 34
332 - 34
333 - 34
334 - 34
335 - 34
336 - 34
337 - 34
338 - 34
339 - 34
340 - 34
341 - 34
342 - 34
343 - 34
344 - 34
345 - 34
346 - 34
347 - 34
348 - 33
349 - 33
350 - 33
351 - 33
352 - 33
353 - 33
354 - 33
355 - 33
356 - 33
357 - 33
358 - 33
359 - 33
360 - 33
361 - 33
362 - 33
363 - 33
364 - 33
365 - 33
366 - 33
367 - 33
368 - 32
369 - 32
370 - 32
371 - 32
372 - 32
373 - 32
374 - 32
375 - 32
376 - 32
377 - 32
378 - 32
379 - 32
380 - 32
381 - 32
382 - 32
383 - 32
384 - 32
385 - 32
386 - 32
387 - 32
388 - 32
389 - 31
390 - 31
391 - 31
392 - 31
393 - 31
394 - 31
395 - 31
396 - 31
397 - 31
398 - 31
399 - 31
400 - 31
401 - 31
402 - 31
403 - 31
404 - 31
405 - 31
406 - 31
407 - 31
408 - 31
409 - 30
410 - 30
411 - 30
412 - 30
413 - 30
414 - 30
415 - 30
416 - 30
417 - 30
418 - 30
419 - 30
420 - 30
421 - 30
422 - 30
423 - 30
424 - 30
425 - 30
426 - 30
427 - 30
428 - 30
429 - 29
430 - 29
431 - 29
432 - 29
433 - 29
434 - 29
435 - 29
436 - 29
437 - 29
438 - 29
439 - 29
440 - 29
441 - 29
442 - 29
443 - 29
444 - 29
445 - 29
446 - 29
447 - 29
448 - 29
449 - 29
450 - 28
451 - 28
452 - 28
453 - 28
454 - 28
455 - 28
456 - 28
457 - 28
458 - 28
459 - 28
460 - 28
461 - 28
462 - 28
463 - 28
464 - 28
465 - 28
466 - 28
467 - 28
468 - 28
469 - 28
470 - 27
471 - 27
472 - 27
473 - 27
474 - 27
475 - 27
476 - 27
477 - 27
478 - 27
479 - 27
480 - 27
481 - 27
482 - 27
483 - 27
484 - 27
485 - 27
486 - 27
487 - 27
488 - 27
489 - 27
490 - 27
491 - 26
492 - 26
493 - 26
494 - 26
495 - 26
496 - 26
497 - 26
498 - 26
499 - 26
500 - 26
501 - 26
502 - 26
503 - 26
504 - 26
505 - 26
506 - 26
507 - 26
508 - 26
509 - 26
510 - 26
511 - 25
512 - 25
513 - 25
514 - 25
515 - 25
516 - 25
517 - 25
518 - 25
519 - 25
520 - 25
521 - 25
522 - 25
523 - 25
524 - 25
525 - 25
526 - 25
527 - 25
528 - 25
529 - 25
530 - 25
531 - 25
532 - 24
533 - 24
534 - 24
535 - 24
536 - 24
537 - 24
538 - 24
539 - 24
540 - 24
541 - 24
542 - 24
543 - 24
544 - 24
545 - 24
546 - 24
547 - 24
548 - 24
549 - 24
550 - 24
551 - 24
552 - 23
553 - 23
554 - 23
555 - 23
556 - 23
557 - 23
558 - 23
559 - 23
560 - 23
561 - 23
562 - 23
563 - 23
564 - 23
565 - 23
566 - 23
567 - 23
568 - 23
569 - 23
570 - 23
571 - 23
572 - 22
573 - 22
574 - 22
575 - 22
576 - 22
577 - 22
578 - 22
579 - 22
580 - 22
581 - 22
582 - 22
583 - 22
584 - 22
585 - 22
586 - 22
587 - 22
588 - 22
589 - 22
590 - 22
591 - 22
592 - 22
593 - 21
594 - 21
595 - 21
596 - 21
597 - 21
598 - 21
599 - 21
600 - 21
601 - 21
602 - 21
603 - 21
604 - 21
605 - 21
606 - 21
607 - 21
608 - 21
609 - 21
610 - 21
611 - 21
612 - 21
613 - 20
614 - 20
615 - 20
616 - 20
617 - 20
618 - 20
619 - 20
620 - 20
621 - 20
622 - 20
623 - 20
624 - 20
625 - 20
626 - 20
627 - 20
628 - 20
629 - 20
630 - 20
631 - 20
632 - 20
633 - 20
634 - 19
635 - 19
636 - 19
637 - 19
638 - 19
639 - 19
640 - 19
641 - 19
642 - 19
643 - 19
644 - 19
645 - 19
646 - 19
647 - 19
648 - 19
649 - 19
650 - 19
651 - 19
652 - 19
653 - 19
654 - 18
655 - 18
656 - 18
657 - 18
658 - 18
659 - 18
660 - 18
661 - 18
662 - 18
663 - 18
664 - 18
665 - 18
666 - 18
667 - 18
668 - 18
669 - 18
670 - 18
671 - 18
672 - 18
673 - 18
674 - 18
675 - 17
676 - 17
677 - 17
678 - 17
679 - 17
680 - 17
681 - 17
682 - 17
683 - 17
684 - 17
685 - 17
686 - 17
687 - 17
688 - 17
689 - 17
690 - 17
691 - 17
692 - 17
693 - 17
694 - 17
695 - 16
696 - 16
697 - 16
698 - 16
699 - 16
700 - 16
701 - 16
702 - 16
703 - 16
704 - 16
705 - 16
706 - 16
707 - 16
708 - 16
709 - 16
710 - 16
711 - 16
712 - 16
713 - 16
714 - 16
715 - 15
716 - 15
717 - 15
718 - 15
719 - 15
720 - 15
721 - 15
722 - 15
723 - 15
724 - 15
725 - 15
726 - 15
727 - 15
728 - 15
729 - 15
730 - 15
731 - 15
732 - 15
733 - 15
734 - 15
735 - 15
736 - 14
737 - 14
738 - 14
739 - 14
740 - 14
741 - 14
742 - 14
743 - 14
744 - 14
745 - 14
746 - 14
747 - 14
748 - 14
749 - 14
750 - 14
751 - 14
752 - 14
753 - 14
754 - 14
755 - 14
756 - 13
757 - 13
758 - 13
759 - 13
760 - 13
761 - 13
762 - 13
763 - 13
764 - 13
765 - 13
766 - 13
767 - 13
768 - 13
769 - 13
770 - 13
771 - 13
772 - 13
773 - 13
774 - 13
775 - 13
776 - 13
777 - 12
778 - 12
779 - 12
780 - 12
781 - 12
782 - 12
783 - 12
784 - 12
785 - 12
786 - 12
787 - 12
788 - 12
789 - 12
790 - 12
791 - 12
792 - 12
793 - 12
794 - 12
795 - 12
796 - 12
797 - 11
798 - 11
799 - 11
800 - 11
801 - 11
802 - 11
803 - 11
804 - 11
805 - 11
806 - 11
807 - 11
808 - 11
809 - 11
810 - 11
811 - 11
812 - 11
813 - 11
814 - 11
815 - 11
816 - 11
817 - 11
818 - 10
819 - 10
820 - 10
821 - 10
822 - 10
823 - 10
824 - 10
825 - 10
826 - 10
827 - 10
828 - 10
829 - 10
830 - 10
831 - 10
832 - 10
833 - 10
834 - 10
835 - 10
836 - 10
837 - 10
838 - 9
839 - 9
840 - 9
841 - 9
842 - 9
843 - 9
844 - 9
845 - 9
846 - 9
847 - 9
848 - 9
849 - 9
850 - 9
851 - 9
852 - 9
853 - 9
854 - 9
855 - 9
856 - 9
857 - 9
858 - 8
859 - 8
860 - 8
861 - 8
862 - 8
863 - 8
864 - 8
865 - 8
866 - 8
867 - 8
868 - 8
869 - 8
870 - 8
871 - 8
872 - 8
873 - 8
874 - 8
875 - 8
876 - 8
877 - 8
878 - 8
879 - 7
880 - 7
881 - 7
882 - 7
883 - 7
884 - 7
885 - 7
886 - 7
887 - 7
888 - 7
889 - 7
890 - 7
891 - 7
892 - 7
893 - 7
894 - 7
895 - 7
896 - 7
897 - 7
898 - 7
899 - 6
900 - 6
901 - 6
902 - 6
903 - 6
904 - 6
905 - 6
906 - 6
907 - 6
908 - 6
909 - 6
910 - 6
911 - 6
912 - 6
913 - 6
914 - 6
915 - 6
916 - 6
917 - 6
918 - 6
919 - 6
920 - 5
921 - 5
922 - 5
923 - 5
924 - 5
925 - 5
926 - 5
927 - 5
928 - 5
929 - 5
930 - 5
931 - 5
932 - 5
933 - 5
934 - 5
935 - 5
936 - 5
937 - 5
938 - 5
939 - 5
940 - 4
941 - 4
942 - 4
943 - 4
944 - 4
945 - 4
946 - 4
947 - 4
948 - 4
949 - 4
950 - 4
951 - 4
952 - 4
953 - 4
954 - 4
955 - 4
956 - 4
957 - 4
958 - 4
959 - 4
960 - 4
961 - 3
962 - 3
963 - 3
964 - 3
965 - 3
966 - 3
967 - 3
968 - 3
969 - 3
970 - 3
971 - 3
972 - 3
973 - 3
974 - 3
975 - 3
976 - 3
977 - 3
978 - 3
979 - 3
980 - 3
981 - 2
982 - 2
983 - 2
984 - 2
985 - 2
986 - 2
987 - 2
988 - 2
989 - 2
990 - 2
991 - 2
992 - 2
993 - 2
994 - 2
995 - 2
996 - 2
997 - 2
998 - 2
999 - 2
1000 - 2
0 - 50
1 - 50
2 - 50
3 - 50
4 - 50
5 - 50
6 - 50
7 - 50
8 - 50
9 - 50
10 - 50
11 - 50
12 - 50
13 - 50
14 - 50
15 - 50
16 - 50
17 - 50
18 - 50
19 - 50
20 - 50
21 - 49
22 - 49
23 - 49
24 - 49
25 - 49
26 - 49
27 - 49
28 - 49
29 - 49
30 - 49
31 - 49
32 - 49
33 - 49
34 - 49
35 - 49
36 - 49
37 - 49
38 - 49
39 - 49
40 - 49
41 - 48
42 - 48
43 - 48
44 - 48
45 - 48
46 - 48
47 - 48
48 - 48
49 - 48
50 - 48
51 - 48
52 - 48
53 - 48
54 - 48
55 - 48
56 - 48
57 - 48
58 - 48
59 - 48
60 - 48
61 - 48
62 - 47
63 - 47
64 - 47
65 - 47
66 - 47
67 - 47
68 - 47
69 - 47
70 - 47
71 - 47
72 - 47
73 - 47
74 - 47
75 - 47
76 - 47
77 - 47
78 - 47
79 - 47
80 - 47
81 - 47
82 - 46
83 - 46
84 - 46
85 - 46
86 - 46
87 - 46
88 - 46
89 - 46
90 - 46
91 - 46
92 - 46
93 - 46
94 - 46
95 - 46
96 - 46
97 - 46
98 - 46
99 - 46
100 - 46
101 - 46
102 - 46
103 - 45
104 - 45
105 - 45
106 - 45
107 - 45
108 - 45
109 - 45
110 - 45
111 - 45
112 - 45
113 - 45
114 - 45
115 - 45
116 - 45
117 - 45
118 - 45
119 - 45
120 - 45
121 - 45
122 - 45
123 - 44
124 - 44
125 - 44
126 - 44
127 - 44
128 - 44
129 - 44
130 - 44
131 - 44
132 - 44
133 - 44
134 - 44
135 - 44
136 - 44
137 - 44
138 - 44
139 - 44
140 - 44
141 - 44
142 - 44
143 - 43
144 - 43
145 - 43
146 - 43
147 - 43
148 - 43
149 - 43
150 - 43
151 - 43
152 - 43
153 - 43
154 - 43
155 - 43
156 - 43
157 - 43
158 - 43
159 - 43
160 - 43
161 - 43
162 - 43
163 - 43
164 - 42
165 - 42
166 - 42
167 - 42
168 - 42
169 - 42
170 - 42
171 - 42
172 - 42
173 - 42
174 - 42
175 - 42
176 - 42
177 - 42
178 - 42
179 - 42
180 - 42
181 - 42
182 - 42
183 - 42
184 - 41
185 - 41
186 - 41
187 - 41
188 - 41
189 - 41
190 - 41
191 - 41
192 - 41
193 - 41
194 - 41
195 - 41
196 - 41
197 - 41
198 - 41
199 - 41
200 - 41
201 - 41
202 - 41
203 - 41
204 - 41
205 - 40
206 - 40
207 - 40
208 - 40
209 - 40
210 - 40
211 - 40
212 - 40
213 - 40
214 - 40
215 - 40
216 - 40
217 - 40
218 - 40
219 - 40
220 - 40
221 - 40
222 - 40
223 - 40
224 - 40
225 - 39
226 - 39
227 - 39
228 - 39
229 - 39
230 - 39
231 - 39
232 - 39
233 - 39
234 - 39
235 - 39
236 - 39
237 - 39
238 - 39
239 - 39
240 - 39
241 - 39
242 - 39
243 - 39
244 - 39
245 - 39
246 - 38
247 - 38
248 - 38
249 - 38
250 - 38
251 - 38
252 - 38
253 - 38
254 - 38
255 - 38
256 - 38
257 - 38
258 - 38
259 - 38
260 - 38
261 - 38
262 - 38
263 - 38
264 - 38
265 - 38
266 - 37
267 - 37
268 - 37
269 - 37
270 - 37
271 - 37
272 - 37
273 - 37
274 - 37
275 - 37
276 - 37
277 - 37
278 - 37
279 - 37
280 - 37
281 - 37
282 - 37
283 - 37
284 - 37
285 - 37
286 - 36
287 - 36
288 - 36
289 - 36
290 - 36
291 - 36
292 - 36
293 - 36
294 - 36
295 - 36
296 - 36
297 - 36
298 - 36
299 - 36
300 - 36
301 - 36
302 - 36
303 - 36
304 - 36
305 - 36
306 - 36
307 - 35
308 - 35
309 - 35
310 - 35
311 - 35
312 - 35
313 - 35
314 - 35
315 - 35
316 - 35
317 - 35
318 - 35
319 - 35
320 - 35
321 - 35
322 - 35
323 - 35
324 - 35
325 - 35
326 - 35
327 - 34
328 - 34
329 - 34
330 - 34
331 - 34
332 - 34
333 - 34
334 - 34
335 - 34
336 - 34
337 - 34
338 - 34
339 - 34
340 - 34
341 - 34
342 - 34
343 - 34
344 - 34
345 - 34
346 - 34
347 - 34
348 - 33
349 - 33
350 - 33
351 - 33
352 - 33
353 - 33
354 - 33
355 - 33
356 - 33
357 - 33
358 - 33
359 - 33
360 - 33
361 - 33
362 - 33
363 - 33
364 - 33
365 - 33
366 - 33
367 - 33
368 - 32
369 - 32
370 - 32
371 - 32
372 - 32
373 - 32
374 - 32
375 - 32
376 - 32
377 - 32
378 - 32
379 - 32
380 - 32
381 - 32
382 - 32
383 - 32
384 - 32
385 - 32
386 - 32
387 - 32
388 - 32
389 - 31
390 - 31
391 - 31
392 - 31
393 - 31
394 - 31
395 - 31
396 - 31
397 - 31
398 - 31
399 - 31
400 - 31
401 - 31
402 - 31
403 - 31
404 - 31
405 - 31
406 - 31
407 - 31
408 - 31
409 - 30
410 - 30
411 - 30
412 - 30
413 - 30
414 - 30
415 - 30
416 - 30
417 - 30
418 - 30
419 - 30
420 - 30
421 - 30
422 - 30
423 - 30
424 - 30
425 - 30
426 - 30
427 - 30
428 - 30
429 - 29
430 - 29
431 - 29
432 - 29
433 - 29
434 - 29
435 - 29
436 - 29
437 - 29
438 - 29
439 - 29
440 - 29
441 - 29
442 - 29
443 - 29
444 - 29
445 - 29
446 - 29
447 - 29
448 - 29
449 - 29
450 - 28
451 - 28
452 - 28
453 - 28
454 - 28
455 - 28
456 - 28
457 - 28
458 - 28
459 - 28
460 - 28
461 - 28
462 - 28
463 - 28
464 - 28
465 - 28
466 - 28
467 - 28
468 - 28
469 - 28
470 - 27
471 - 27
472 - 27
473 - 27
474 - 27
475 - 27
476 - 27
477 - 27
478 - 27
479 - 27
480 - 27
481 - 27
482 - 27
483 - 27
484 - 27
485 - 27
486 - 27
487 - 27
488 - 27
489 - 27
490 - 27
491 - 26
492 - 26
493 - 26
494 - 26
495 - 26
496 - 26
497 - 26
498 - 26
499 - 26
500 - 26
501 - 26
502 - 26
503 - 26
504 - 26
505 - 26
506 - 26
507 - 26
508 - 26
509 - 26
510 - 26
511 - 25
512 - 25
513 - 25
514 - 25
515 - 25
516 - 25
517 - 25
518 - 25
519 - 25
520 - 25
521 - 25
522 - 25
523 - 25
524 - 25
525 - 25
526 - 25
527 - 25
528 - 25
529 - 25
530 - 25
531 - 25
532 - 24
533 - 24
534 - 24
535 - 24
536 - 24
537 - 24
538 - 24
539 - 24
540 - 24
541 - 24
542 - 24
543 - 24
544 - 24
545 - 24
546 - 24
547 - 24
548 - 24
549 - 24
550 - 24
551 - 24
552 - 23
553 - 23
554 - 23
555 - 23
556 - 23
557 - 23
558 - 23
559 - 23
560 - 23
561 - 23
562 - 23
563 - 23
564 - 23
565 - 23
566 - 23
567 - 23
568 - 23
569 - 23
570 - 23
571 - 23
572 - 22
573 - 22
574 - 22
575 - 22
576 - 22
577 - 22
578 - 22
579 - 22
580 - 22
581 - 22
582 - 22
583 - 22
584 - 22
585 - 22
586 - 22
587 - 22
588 - 22
589 - 22
590 - 22
591 - 22
592 - 22
593 - 21
594 - 21
595 - 21
596 - 21
597 - 21
598 - 21
599 - 21
600 - 21
601 - 21
602 - 21
603 - 21
604 - 21
605 - 21
606 - 21
607 - 21
608 - 21
609 - 21
610 - 21
611 - 21
612 - 21
613 - 20
614 - 20
615 - 20
616 - 20
617 - 20
618 - 20
619 - 20
620 - 20
621 - 20
622 - 20
623 - 20
624 - 20
625 - 20
626 - 20
627 - 20
628 - 20
629 - 20
630 - 20
631 - 20
632 - 20
633 - 20
634 - 19
635 - 19
636 - 19
637 - 19
638 - 19
639 - 19
640 - 19
641 - 19
642 - 19
643 - 19
644 - 19
645 - 19
646 - 19
647 - 19
648 - 19
649 - 19
650 - 19
651 - 19
652 - 19
653 - 19
654 - 18
655 - 18
656 - 18
657 - 18
658 - 18
659 - 18
660 - 18
661 - 18
662 - 18
663 - 18
664 - 18
665 - 18
666 - 18
667 - 18
668 - 18
669 - 18
670 - 18
671 - 18
672 - 18
673 - 18
674 - 18
675 - 17
676 - 17
677 - 17
678 - 17
679 - 17
680 - 17
681 - 17
682 - 17
683 - 17
684 - 17
685 - 17
686 - 17
687 - 17
688 - 17
689 - 17
690 - 17
691 - 17
692 - 17
693 - 17
694 - 17
695 - 16
696 - 16
697 - 16
698 - 16
699 - 16
700 - 16
701 - 16
702 - 16
703 - 16
704 - 16
705 - 16
706 - 16
707 - 16
708 - 16
709 - 16
710 - 16
711 - 16
712 - 16
713 - 16
714 - 16
715 - 15
716 - 15
717 - 15
718 - 15
719 - 15
720 - 15
721 - 15
722 - 15
723 - 15
724 - 15
725 - 15
726 - 15
727 - 15
728 - 15
729 - 15
730 - 15
731 - 15
732 - 15
733 - 15
734 - 15
735 - 15
736 - 14
737 - 14
738 - 14
739 - 14
740 - 14
741 - 14
742 - 14
743 - 14
744 - 14
745 - 14
746 - 14
747 - 14
748 - 14
749 - 14
750 - 14
751 - 14
752 - 14
753 - 14
754 - 14
755 - 14
756 - 13
757 - 13
758 - 13
759 - 13
760 - 13
761 - 13
762 - 13
763 - 13
764 - 13
765 - 13
766 - 13
767 - 13
768 - 13
769 - 13
770 - 13
771 - 13
772 - 13
773 - 13
774 - 13
775 - 13
776 - 13
777 - 12
778 - 12
779 - 12
780 - 12
781 - 12
782 - 12
783 - 12
784 - 12
785 - 12
786 - 12
787 - 12
788 - 12
789 - 12
790 - 12
791 - 12
792 - 12
793 - 12
794 - 12
795 - 12
796 - 12
797 - 11
798 - 11
799 - 11
800 - 11
801 - 11
802 - 11
803 - 11
804 - 11
805 - 11
806 - 11
807 - 11
808 - 11
809 - 11
810 - 11
811 - 11
812 - 11
813 - 11
814 - 11
815 - 11
816 - 11
817 - 11
818 - 10
819 - 10
820 - 10
821 - 10
822 - 10
823 - 10
824 - 10
825 - 10
826 - 10
827 - 10
828 - 10
829 - 10
830 - 10
831 - 10
832 - 10
833 - 10
834 - 10
835 - 10
836 - 10
837 - 10
838 - 9
839 - 9
840 - 9
841 - 9
842 - 9
843 - 9
844 - 9
845 - 9
846 - 9
847 - 9
848 - 9
849 - 9
850 - 9
851 - 9
852 - 9
853 - 9
854 - 9
855 - 9
856 - 9
857 - 9
858 - 8
859 - 8
860 - 8
861 - 8
862 - 8
863 - 8
864 - 8
865 - 8
866 - 8
867 - 8
868 - 8
869 - 8
870 - 8
871 - 8
872 - 8
873 - 8
874 - 8
875 - 8
876 - 8
877 - 8
878 - 8
879 - 7
880 - 7
881 - 7
882 - 7
883 - 7
884 - 7
885 - 7
886 - 7
887 - 7
888 - 7
889 - 7
890 - 7
891 - 7
892 - 7
893 - 7
894 - 7
895 - 7
896 - 7
897 - 7
898 - 7
899 - 6
900 - 6
901 - 6
902 - 6
903 - 6
904 - 6
905 - 6
906 - 6
907 - 6
908 - 6
909 - 6
910 - 6
911 - 6
912 - 6
913 - 6
914 - 6
915 - 6
916 - 6
917 - 6
918 - 6
919 - 6
920 - 5
921 - 5
922 - 5
923 - 5
924 - 5
925 - 5
926 - 5
927 - 5
928 - 5
929 - 5
930 - 5
931 - 5
932 - 5
933 - 5
934 - 5
935 - 5
936 - 5
937 - 5
938 - 5
939 - 5
940 - 4
941 - 4
942 - 4
943 - 4
944 - 4
945 - 4
946 - 4
947 - 4
948 - 4
949 - 4
950 - 4
951 - 4
952 - 4
953 - 4
954 - 4
955 - 4
956 - 4
957 - 4
958 - 4
959 - 4
960 - 4
961 - 3
962 - 3
963 - 3
964 - 3
965 - 3
966 - 3
967 - 3
968 - 3
969 - 3
970 - 3
971 - 3
972 - 3
973 - 3
974 - 3
975 - 3
976 - 3
977 - 3
978 - 3
979 - 3
980 - 3
981 - 2
982 - 2
983 - 2
984 - 2
985 - 2
986 - 2
987 - 2
988 - 2
989 - 2
990 - 2
991 - 2
992 - 2
993 - 2
994 - 2
995 - 2
996 - 2
997 - 2
998 - 2
999 - 2
1000 - 2


Thanks again

schlaepfer
 
Posts: 7
Joined: Mon Mar 07, 2016 10:52 am

Re: neopixel won't turn off

by adafruit_support_bill on Thu Feb 14, 2019 1:24 pm

Plugging the numbers into the equation as it is documented gives the correct result:
https://www.arduino.cc/reference/en/lan ... /math/map/
Appendix
For the mathematically inclined, here’s the whole function

long map(long x, long in_min, long in_max, long out_min, long out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

There was some discussion a while back in the Arduino forums regarding the correctness of that implementation. I'm not sure if it has been changed.

adafruit_support_bill
 
Posts: 72783
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.