You are reading a single comment by @goliatone and its replies. Click here to read the full conversation.
  • I have an arduino sketch that I would like to port JavaScript and run on a pico.
    The sketch is reading input from pins 2 and 3 and then attaching two interrupts to get 0/1 bits.

    What would be the way to achieve this using a pico?

    The following is an excerpt of the sketch I'm using, I could post the whole script but I figured this encompasses the core of my question.

    void ISR_INT0()
    {
        bitCount++;
        flagDone = 0;
        pulseCounter = WAIT_TIME;
    
    }
    
    void ISR_INT1()
    {
        databits[bitCount] = 1;
        bitCount++;
        flagDone = 0;
        pulseCounter = WAIT_TIME;
    }
    
    void setup()
    {
        pinMode(13, OUTPUT);   // LED
        pinMode(2, INPUT);     // DATA0 (INT0)
        pinMode(3, INPUT);     // DATA1 (INT1)
    
        Serial.begin(115200);
        Bridge.begin();
    
        while (!Serial);
    
        attachInterrupt(1, ISR_INT0, RISING);
        attachInterrupt(0, ISR_INT1, RISING);
    
        pulseCounter = WAIT_TIME;
    }
    
    void loop()
    {
        if (!flagDone)
        {
            if (--pulseCounter == 0)
            {
                flagDone = 1;
            }
        }
    
        // if we have bits and we the pulse counter went out
        if (bitCount > 0 && flagDone)
        {
            //... logic removed
            bitCount = 0;
        }
    }
    
About

Avatar for goliatone @goliatone started