# Logically invert the pin?

• I tried this:

``````SPI1.setup({baud:3200000, mosi:B5});

// like so
SPI1.send4bit([1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1], 0b1110, 0b1100);
``````

This should turn the first led white, but did nothing :(
Is this wrong?

I also found this guide showing how to control WS2812 with PWM and DMA. This is a very efficient way, as they say. This guide is far beyond my understanding. Is something like this available with Espruino?

When I started this project, I thought that the LED part would be easy and fun. Already wasted four days on this problem, lol)

• Sun 2018.11.04

Hello @George,

'I thought that the LED part would be easy and fun'

Yes, if this were an LED. This is in fact a Neopixel. Much more fun! ;-)

'Already wasted four days on this problem'

Nothing about what you are in the process of learning is wasted. Imagine Thomas Edison, 'I've just found 10,000 ways that won't work!'

You are in fact just re-discovering methods that prove the limitation of the circuit board data input inversion!

Note that I don't have access to a scope to verify the following . . . .

I re-checked the device data requirement:

The reset pulse required for the 5050 is a low state, greater than 50usec

Although @Gordon #16 suggestion `leds = new Uint8Array([255,255,255])` will turn the first Neopixel in a strip white, this will only work when on a non-inverted circuit, as you already have discovered.

https://www.espruino.com/Reference#l_SPI­_send4bit    bit0 - The 4 bits to send for a 0 (MSB first)

So if `SPI1.send4bit(leds, 0b1110, 0b1100);` sends the correct reset pulse, your data will need to be inverted. As a suggestion, try the middle road `leds = new Uint8Array([127,127,127])` on the first test. Better yet, `leds = new Uint8Array([90,165,15])` e.g. `0x5A 0xA5 0x0F` Alternate the bits, in case the inversion is changing the reset width too much. If the reset pulse is detected, some color of some sort may be seen.

Depending on the number of Neopixels there are, send more data. For the above circuit of three, send nine bytes or more. It's possible that some data might get detected as the reset.

In #10 above Gordon pointed out:

'No guarantees though - SPI may change its state when idling which would break it.'

My guess is that this is in fact what is occurring that the data line is remaining in a high state, so a low reset pulse is never seen at
the correct place and at the correct time interval, in the data sequence.

As you discovered in #15 `SPI1.send4bit([1,1,1,1,1,1,` may work, if you are able to prove being able to send that reset pulse.

In your circuit, remember that data is inverted, so the above code is sending a continuous stream of set the output to black.

Although there hasn't been an indication of how many circuit boards, it seems from #1 'for my nixie clock project', only one or two perhaps?
Four days have been spent researching a software solution when I believe @allObjects had the best suggestion in #2 Just lift the base of the input data transistor and tack solder a matching flying transistor and input resistor. Should be able to tack solder on top of the existing one without having to remove it.

Here is yet another simple schematic showing the same - unless others disagree, two common 2n2222 should also work.