CPX/Crickit I/O pins

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
htmagic
 
Posts: 89
Joined: Tue Dec 03, 2013 12:18 am

CPX/Crickit I/O pins

Post by htmagic »

So I learned something about the Circuit Playground Express (CPX)/Crickit board last weekend.
So you set it up like so:

Code: Select all

ss.pin_mode(BUTTON_1, ss.INPUT_PULLUP)
And when you put the line like this:

Code: Select all

if ss.digital_read(BUTTON_1):
It keeps triggering until the signal and ground are shorted.
This is the exact opposite of what I would have thought.
So if you want to make it "normal", use a "not" statement after the if and it will look for a normally open (NO) switch to short Normally, the output is offthe pins and work as one would think.
Now I want to add a RC receiver to the pins. This is the momentary version that Adafruit sells.
So the LEDs are off until the button is pushed, then turn on.
I have to test this when I get home but I think I might need the not to make it work when I push the RC button, right?
Thanks in advance for answering this.

MagicBill

User avatar
dastels
 
Posts: 15831
Joined: Tue Oct 20, 2015 3:22 pm

Re: CPX/Crickit I/O pins

Post by dastels »

Using the pullup on the input means it will be high unless it's shorted to ground. That's why the 'if' triggers constantly until the input is grounded. To trigger while the input is grounded (e.g. the button is pushed) you'll need to use 'if not'.

Inputs have traditionally always had pullups that you could enable, but not always pulldowns. So grounding the input is typically the active condition.

You don't need to use pullups with the RF module since its outputs are digital signals: True when the corresponding button is pressed, False when it's not.

Dave

User avatar
htmagic
 
Posts: 89
Joined: Tue Dec 03, 2013 12:18 am

Re: CPX/Crickit I/O pins

Post by htmagic »

Dave,

Thank you for confirming that.
It's probably a neophyte or newbie error but it seems counter-intuitive.
And if you read carefully enough, it's in there.
But before I learned this and reread it again, I did not realize this truth.
Hopefully someone else will learn from this post when they're trying to get a circuit to work.

Again, thank you for your help.
May the FORCE be with you and have a magical day!

MagicBill

User avatar
dastels
 
Posts: 15831
Joined: Tue Oct 20, 2015 3:22 pm

Re: CPX/Crickit I/O pins

Post by dastels »

My pleasure. Have fun!

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

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