On Sat, Apr 6, 2019 at 10:17 PM <[email protected]> wrote:

>
> I am trying to run the code below on my beaglebone black but it is not
> working
>
> *var b = require('bonescript');*
> *b.analogWrite('P9_14', 0.7, 2000, printJSON);*
> *function printJSON(x) { console.log(JSON.stringify(x)); }*
>
> but I am getting this error
>
> *Exception: Please perform setTargetAddress on a valid target*
>
> Does anyone know what I did wrong?
>

Are you doing this in the Cloud9 IDE, command-line or on a web page in your
browser?

The error indicates you are doing this in a browser window, which isn’t
running with access to the hardware. You need to connect to the BoneScript
RPC server.

Your web page must already be including bonescript.js. You still need to
point to your board to make the network connection from your browser
window.

Maybe this’ll make more sense...

http://jsfiddle.net/jkridner/z547taL9/

> I ran it on the browser and I got that error. i tried on Cloud9 IDE but
it kept stopping and it wasn't telling me if it actually did something.

Do you have anything hooked up to the pin to see if it is toggling?

I suspect that the pinmux mode isn't right, but I'm not sure if I don't set
it up in that loop. Anyway, below is an example that probably gets a bit
more usage. Note the usage of b.pinMode().

https://github.com/beagleboard/cloud9-examples/blob/master/BeagleBone/fade.js

var b = require('bonescript');
// setup starting conditions
var awValue = 0.01;
var awDirection = 1;
var awPin = "P9_14";
// configure pin
b.pinMode(awPin, b.ANALOG_OUTPUT);
// call function to update brightness every 10ms
setInterval(fade, 10);
// function to update brightness
function fade() {
b.analogWrite(awPin, awValue);
awValue = awValue + (awDirection*0.01);
if(awValue > 1.0) { awValue = 1.0; awDirection = -1; }
else if(awValue <= 0.01) { awValue = 0.01; awDirection = 1; }
}

  --
> For more options, visit http://beagleboard.org/discuss
> ---
> You received this message because you are subscribed to the Google Groups
> "BeagleBoard" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beagleboard/4b5ea172-ebd4-403b-ad74-f0d7433ef06b%40googlegroups.com
> <https://groups.google.com/d/msgid/beagleboard/4b5ea172-ebd4-403b-ad74-f0d7433ef06b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
https://beagleboard.org/about - a 501c3 non-profit educating around open
hardware computing

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/CA%2BT6QP%3DBmtvpgrF6dtQORqyEvMNKmbNw8Hqcdb1h-uD9D09aUA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to