I need your help. I've converted the Tutorial on Programming the NeoPixel to PICBASIC. I’m using a PIC18F25K22 at 40MHz. I get the right timings (400ns & 800ns) but I don’t have a NeoPixel! I’ve ordered a Led strip from AliExpress but it takes one month to get it…

So, if anyone of you can give it a try please. Keep the data line as short as possible with a short ground return. This will improve the rise and fall time. The nice thing about these pixels is when data is forwarded, it is passed through the internal reshaping mechanism. (Ref: Understanding the WS2812 ).

Thanks!

Code:
'****************************************************************
'*  Name    : NeoPixel                                           
'*  Author  : Michel Jasmin                                           
'*  Notice  : Copyright (c) 2014
'*          : All Rights Reserved                               
'*  Date    : 2014-08-13                                           
'*  Version : 1.0                                               
'*  Notes   :                                                   
'*          :                                                   
'****************************************************************
'PIC18F25K22

#CONFIG
        __CONFIG    _CONFIG1H, _FOSC_HSHP_1H & _PLLCFG_OFF_1H & _PRICLKEN_ON_1H & _FCMEN_ON_1H & _IESO_ON_1H
        __CONFIG    _CONFIG2H, _WDTEN_OFF_2H
        __CONFIG    _CONFIG3H, _PBADEN_ON_3H & _CCP2MX_PORTB3_3H  & _MCLRE_EXTMCLR_3H
        __CONFIG    _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _XINST_OFF_4L
        __CONFIG    _CONFIG5L, _CP0_ON_5L & _CP1_ON_5L & _CP2_ON_5L & _CP3_ON_5L
        __CONFIG    _CONFIG5H, _CPB_ON_5H & _CPD_ON_5H
#ENDCONFIG

DEFINE OSC 40   
DEFINE NO_CLRWDT 1  ' Don't waste cycles clearing WDT

'------------ ALIAS -------------------------
LedPin      VAR LATC.3
NeoPin      VAR LATC.5

'------------ Const -------------------------
NEO_NUM     CON 60
CR CON 13
LF CON 10

'------------ Variables -------------------------
NeoGreen    VAR BYTE[NEO_NUM]
NeoBlue     VAR BYTE[NEO_NUM]
NeoRed      VAR BYTE[NEO_NUM]
NeoPixel    VAR BYTE
BitCount    VAR BYTE
TempW       VAR WORD

'Flags
AppFlags    VAR BYTE
DataBit     VAR AppFlags.0


'------------------------  Initialization -------------------------------

Clear   ' Clear RAM before entry

TRISC.3 = 0 'Led Pin
TRISC.5 = 0 'NeoPin
TRISC.6 = 1 'TX1
TRISC.7 = 1 'RX1

'The serial port is used only for debugging purpose.
RCSTA = $90   ' Enable serial port & continuous receive
TXSTA = $24   ' Enable transmit, BRGH = 1
SPBRG = 17    ' 9600 Baud @ 40 MHz -0.03%
SPBRGH = 4
BAUDCON.3 = 1 ' Enable 16 bit baudrate generator

PAUSE 100

HSEROUT [CR,LF,CR,LF,"Test NeoPixel v 17",CR,LF]

'Blink a LED just to say: Hello, I'm alive!
LedPin = 0
FOR TempW = 0 TO 4
    TOGGLE LedPin
    PAUSE 250
NEXT
LedPin = 0

DataBit = 0
GOSUB NeoInit

'------------ Main program -------------------------
Main:

    'For testing purpose:
    'DataBit = 1
    'GOSUB NeoBit
    'GOTO Main

    GOSUB NeoDraw
    GOSUB NeoRotate
    PAUSE 25
    GOTO Main

END

NeoBit:
    IF DataBit = 1 THEN
        '400ns pulse required
        NeoPin = 1

        '3 nop = 500ns @ 32MHz
        '2 nop = 376ns @ 32MHz

        '2 nop = 300ns @ 40MHz
        '3 nop = 400ns @ 40MHz

        ASM
            nop
            nop
            nop
        ENDASM
        NeoPin = 0

    ELSE
        '800ns pulse required
        NeoPin = 1

        '5 nop = 740ns @ 32MHz
        '6 nop = 880ns @ 32MHz

        '6 nop = 700ns @ 40MHz
        '7 nop = 800ns @ 40MHz

        ASM
            nop
            nop
            nop
            nop
            nop
            nop
            nop
        ENDASM
        NeoPin = 0
    ENDIF

    RETURN


NeoInit:
    FOR NeoPixel = 0 TO NEO_NUM

        IF NeoPixel < 10 THEN
            NeoGreen[NeoPixel] = 0
            NeoBlue[NeoPixel] = 0
            NeoRed[NeoPixel] = 64

        ELSEIF NeoPixel < 20 THEN
            NeoGreen[NeoPixel] = 0
            NeoBlue[NeoPixel] = 64
            NeoRed[NeoPixel] = 0

        ELSEIF NeoPixel < 30 THEN
            NeoGreen[NeoPixel] = 0
            NeoBlue[NeoPixel] = 64
            NeoRed[NeoPixel] = 64

        ELSEIF NeoPixel < 40 THEN
            NeoGreen[NeoPixel] = 64
            NeoBlue[NeoPixel] = 0
            NeoRed[NeoPixel] = 0

        ELSEIF NeoPixel < 50 THEN
            NeoGreen[NeoPixel] = 64
            NeoBlue[NeoPixel] = 0
            NeoRed[NeoPixel] = 64
        ELSE
            NeoGreen[NeoPixel] = 64
            NeoBlue[NeoPixel] = 64
            NeoRed[NeoPixel] = 0
        ENDIF

    NEXT

    RETURN

NeoDraw:
    FOR NeoPixel = 0 TO NEO_NUM
        FOR BitCount = 7 TO 0 STEP -1
            DataBit = NeoGreen.0[NeoPixel * BitCount]
            GOSUB NeoBit
        NEXT

        FOR BitCount = 7 TO 0 STEP -1
            DataBit = NeoRed.0[NeoPixel * BitCount]
            GOSUB NeoBit
        NEXT

        FOR BitCount = 7 TO 0 STEP -1
            DataBit = NeoBlue.0[NeoPixel * BitCount]
            GOSUB NeoBit
        NEXT

    NEXT

    NeoPin = 0

    RETURN

NeoRotate:
    FOR NeoPixel = 0 TO (NEO_NUM - 1)
        NeoGreen[NeoPixel] = NeoGreen[NeoPixel + 1]
        NeoBlue[NeoPixel] = NeoBlue[NeoPixel + 1]
        NeoRed[NeoPixel] = NeoRed[NeoPixel + 1]
    NEXT

    NeoGreen[NEO_NUM - 1] = NeoGreen[0]
    NeoBlue[NEO_NUM - 1] = NeoBlue[0]
    NeoRed[NEO_NUM - 1] = NeoRed[0]

    RETURN