0

makecode digital input problem with circuit playground/crick
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

makecode digital input problem with circuit playground/crick

by fmorton on Sat Aug 04, 2018 9:29 am

Attached are two equivalent sketches. One using circuit python and the other makecode.

A photo of the hardware setup is attached. The white clip on the black lead is simulating a pressed button with a 10K pull-down resistor.

Another photo of the makecode is attached. Given that the "button" is attached (by clipping white clip to black lead), the neopixels should all be blue (as in the photo). But, if the program runs some (anywhere from 2 to 6 minutes), eventually pin 8 goes low and stays low, so the neopixels go to red.

I have tried this with multiple circuit playgrounds and on two different crickits.

To test the hardware and the button simulator connections, running this circuit python code works correctly and does not exhibit this behavior of working at first and then failing after a few minutes.

All help will be appreciated. In not too many days students will starting using makecode and the last thing I want to frustrate them with is hardware not working. Hopefully, it is something with my button simulator.

Here is the circuit python code:

Code: Select all | TOGGLE FULL SIZE
import time
from adafruit_circuitplayground.express import cpx
from adafruit_crickit import crickit

ss = crickit.seesaw

BUTTON_8 = crickit.SIGNAL8

ss.pin_mode(BUTTON_8, ss.INPUT_PULLDOWN)

while True:
  button_8_connected = ss.digital_read(BUTTON_8)

  if button_8_connected:
    cpx.pixels.fill((0, 0, 10))
  else:
    cpx.pixels.fill((10, 0, 0))

  time.sleep(0.25)
Attachments
makecode_example.jpg
makecode_example.jpg (548.13 KiB) Viewed 116 times
connections.jpg
connections.jpg (503.14 KiB) Viewed 116 times

fmorton
 
Posts: 8
Joined: Tue Aug 29, 2017 7:48 pm

Re: makecode digital input problem with circuit playground/c

by adafruit_support_carter on Mon Aug 06, 2018 12:33 pm

The inputs have an internal pull up:
https://learn.adafruit.com/adafruit-cri ... ash-o-2-20
All pins can have an internal ~50Kohm pull-up resistor set when used as an input

Try changing your wiring and software to match that. I.e. - code for pull up, not down. And remove external resistor.

adafruit_support_carter
 
Posts: 6598
Joined: Tue Nov 29, 2016 2:45 pm

Re: makecode digital input problem with circuit playground/c

by fmorton on Thu Aug 09, 2018 11:05 pm

Thanks for pointing that out.

If I switch to just connecting the pin-8 signal to the pin-8 ground without any resistors, the leds are blue when not connected and red when they are connected. Works fine like that for anywhere from 1 1/2 minutes to about 3 minutes. After that, the leds go all red as if there is a connection between the pins in both cases of an open or closed connection between those pin-8 pins.

If you reset the board, works again just fine for a short amount of time and then acts as if it connected in both the open and closed connection case.

This is with the makecode example. Changing the circuit python example to INPUT_PULLUP does not experience the same problem. It works as expected the entire time I tested.

fmorton
 
Posts: 8
Joined: Tue Aug 29, 2017 7:48 pm

Re: makecode digital input problem with circuit playground/c

by adafruit2 on Fri Aug 10, 2018 1:37 pm

there was a killer bug in makecode i2c that was making inputs not work well. but it should work as of a day or two ago.
plz try making a new 'private' session to verify you get the latest makecode installed and then try again?
also try circuitpython, we have a lot better control over the i2c bus stack there :)

adafruit2
Site Admin
 
Posts: 17142
Joined: Fri Mar 11, 2005 7:36 pm

Please be positive and constructive with your questions and comments.