using console to troubleshoot Circuit Playground Express, CR

Play with it! Please tell us which board you're using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
troublesturm
 
Posts: 5
Joined: Wed Dec 31, 2014 3:25 am

using console to troubleshoot Circuit Playground Express, CR

Post by troublesturm »

I'm hooking a 2-axis joystick to a CRICKET with Circuit Playground Express.
The MakeCode is pretty simple:

forever(function () {
crickit.servo1.setAngle(crickit.signal1.analogRead())
crickit.servo2.setAngle(crickit.signal2.analogRead())
})

So, the results are that it responds to the joystick pushed up, and to the right, but ignores to the left and down.

I'm using these joysticks: http://a.co/5DMA3WB

So, I'll gratefully accept advice to get it working, but I'd also welcome information to track values read from the joystick. I see the console drawer in advanced section of the tools menu, and I can produce a line like this: console.logValue("x", crickit.signal1.analogRead())

So, how do I read this console? If I connect to the Circuit Playground USB connection, using putty, I only have a valid serial device when the Circuit Playground is in programming mode. And I don't see any info on that serial device in that mode, using putty to connect to it.
How do I read that console?

User avatar
troublesturm
 
Posts: 5
Joined: Wed Dec 31, 2014 3:25 am

Re: using console to troubleshoot Circuit Playground Express

Post by troublesturm »

Found it.
The console is available in the MakeCode app.

https://www.microsoft.com/en-us/p/makec ... verviewtab

It showed me that the joystick was returning values between 0 and 1024, and the servos expect values between 0 and 180 (as in degrees). So I needed to divide it by 5.688888888 (the result of 1027/180).

So, now my code looks like this:

forever(function () {
crickit.servo1.setAngle(crickit.signal1.analogRead() / 5.688888)
crickit.servo2.setAngle(crickit.signal2.analogRead() / 5.688888)
console.logValue("x", crickit.signal1.analogRead() / 5.688888)
console.logValue("y", crickit.signal2.analogRead() / 5.688888)
})

Locked
Please be positive and constructive with your questions and comments.

Return to “Circuit Playground Classic, Circuit Playground Express, Circuit Playground Bluefruit”