When I executed the source code below, I guessed that the LED will turn on in red because LEDColor = neopixel.colors(NeoPixelColors.Black) at line 9. However, the LED turned green.
function setLED (color: number) {
strip.showColor(color)
LEDColor = color
}
let LEDColor = 0
let strip: neopixel.Strip = null
strip = neopixel.create(DigitalPin.P0, 3, NeoPixelMode.RGB_RGB)
setLED(neopixel.colors(NeoPixelColors.Black))
if (LEDColor == neopixel.colors(NeoPixelColors.Red)) {
setLED(neopixel.colors(NeoPixelColors.Green))
} else {
setLED(neopixel.colors(NeoPixelColors.Red))
}
When I executed the source code below, I guessed that the LED will turn on in red because LEDColor = neopixel.colors(NeoPixelColors.Black) at line 9. However, the LED turned green.
Source : https://makecode.microbit.org/_Pdf0pyWJg01i
However, when I removed the "else" part at line 11, the LED did not light up in red somehow. Source : https://makecode.microbit.org/_Kmv4wkM7h718
I am wondering if this phenomenon is an implementation error or a defect.