• Hello,

    while trying the 'array' version of the function 'digitalWrite', i get the error:

    Uncaught Error: Invalid pin!

    The test i performed on the web IDE (after invoking reset()) were:

    digitalWrite(LED1,1); => OK
    digitalWrite(LED2,1); => OK
    digitalWrite([LED1,LED2],3); => Uncaught Error: Invalid pin!
    digitalWrite([LED1],1); => Uncaught Error: Invalid pin!
    digitalWrite([LED2],1); => Uncaught Error: Invalid pin!

    Am i missing something?

    I am using a Bangle.js
    version 2v05
    commit 09aa0d84
    bootloader v0.17
    launcher v0.01
    settings v.0.19

  • have a look at this statement,

    digitalWrite([A1,A1,A0,A0],0b0101)
    
  • thank you; i tried and it returns a different error:

    Uncaught ReferenceError: "A1" is not defined

    I think that's to be expected: since the device is a Bangle.js, the only 'pins' available are LED1 and LED2 (as far as i can tell); also, i don't understand why each pin appears twice in your example...

    the binary representation of the number yields the same effect, using the pins i'm interested in:

    digitalWrite([LED1,LED2],0b0001) => Uncaught Error: Invalid pin!
    digitalWrite([LED1,LED2],0b0010) => Uncaught Error: Invalid pin!
    digitalWrite([LED1,LED2],0b0100) => Uncaught Error: Invalid pin!
    digitalWrite([LED1,LED2],0b1000) => Uncaught Error: Invalid pin!

    It looks like on the watch the virtual pins "LED1\2" work only if used one at a time, not both.
    Could that be the case?

  • Ahh - yes, the issue is because on Bangle.js LED1/LED2 are 'virtual'. When using an array it looks like digitalWrite uses an slightly different (faster) method of writing to pins that expects 'real' pins.

    Were you trying out something from one of the 'getting started' examples? If so I should probably add a note about Bangle.js in there.

  • That's it!
    Anyway, the Quick Start (Writing Code) page uses it.

    Thank you for your explanation

  • Thanks! I'll update that with a note about the arrays

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

[Solved] Bangle.js - digitalWrite([array],value)

Posted by Avatar for user112894 @user112894

Actions