setWatch & analogRead on BBC micro:bit #6698
Replies: 1 comment
-
Posted at 2016-03-20 by @allObjects You don't mention any Therefore, give it a shot and define pin's mode first. I used both analog and digital input in conjunction with Resistive Touchscreen directly (no touch controller). You may get some ideas from there. Basically, I set the pin up for digital single shot watch with pull_up/down, in the callback I change the setup and make analog reads with no-pulls to get the x/y coordinates of the resistive touch screen, and return to initial setup with single shot watch. For you, this means:
Posted at 2016-03-21 by @gfwilliams So you're saying that even without For So you've got it set to digital input for As @allObjects says you might be able to force it with Posted at 2016-03-24 by user63222 Thanks, I was just using the default pin mode and assuming it was set to digital like the classic Espruino seems to be. I'll try setting it explicitly and see what happens. (I was not trying to use analog mode at the same time by the way, I just had to resort to that later). Posted at 2016-03-29 by @gfwilliams Well, if you're not using analogRead, you shouldn't need the pin mode... But are you properly pulling the pin high and low? If not, you might need to use the internal pullup/down resistors (eg. pinMode with |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2016-03-20 by user63222
Hi Gordon,
I can use analogRead on pin D0 of the microbit ok, but setWatch does not seem work using the following code (this code works fine on classic Espruino to detect low to high voltage changes):-
function OnMotion()
{
console.log("Movement detected");
}
setWatch( OnMotion, D0, {repeat:true, edge:"rising"} );
Strangely when I call analogRead after setting the watch it seems to trigger the watch callback into action for one shot.
Regards
David
Beta Was this translation helpful? Give feedback.
All reactions