CRICKIT HAT Raspberry Pi CircuitPython BLinka API

This is a special forum devoted to educators using Adafruit and Arduino products for teaching.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Chaski
 
Posts: 30
Joined: Thu May 31, 2018 10:52 pm

CRICKIT HAT Raspberry Pi CircuitPython BLinka API

Post by Chaski »

Greetings; I successfully followed the instructions at https://learn.adafruit.com/adafruit-cri ... stallation and ran its code

Code: Select all

from adafruit_crickit import crickit
print(crickit.touch_1.value)
print(crickit.touch_1.value)
Where do I find the API to view all the methods of touch_1? Is it https://circuitpython.readthedocs.io/pr ... t/api.html ? ...But it shows adafruit_crickit.CrickitTouchIn ... raw value....value ? How does a newbee get from adafruit_crickit.CrickitTouchIn ...value.... to touch_1.value? In other words, if I want to use other devices (sensors, LEDS,etc) , is this the correct API to view properties (int or boolean return value...all possible methods) for the RPi CRICKIT HAT?

Example , from https://learn.adafruit.com/make-it-move ... cuitpython, I modified the code to have....

Code: Select all

 #
from adafruit_crickit import crickit
Create one motor on seesaw motor port #1
motor = crickit.dc_motor_1  #
 
while True:
    if crickit.touch_2.value:
        print("Button A pressed, go!") 
        motor.throttle = 1.0  # full speed!
 
So, for example, what are other options besides throttle, does that Raspberry Pi CRICKIT HAT API exist ?

User avatar
adafruit_support_carter
 
Posts: 29150
Joined: Tue Nov 29, 2016 2:45 pm

Re: CRICKIT HAT Raspberry Pi CircuitPython BLinka API

Post by adafruit_support_carter »

Yep. You are looking in the correct place for the documentation for the Crickit API.

Here's how you would figure out what raw_value and value are:
rtd.jpg
rtd.jpg (40.84 KiB) Viewed 1229 times
And you would do something similar for the other items. It would be nice if this linked directly, but for example, for dc_motor_1:
rtd_motor.jpg
rtd_motor.jpg (7.56 KiB) Viewed 1229 times
so you would then want to go look for the docs for adafruit_motor:
https://circuitpython.readthedocs.io/pr ... t/api.html
and there you could find the API for the DCMotor:
https://circuitpython.readthedocs.io/pr ... or.DCMotor

For other sensors, it would depend on the sensor. But there should be similar docs for each.

User avatar
Chaski
 
Posts: 30
Joined: Thu May 31, 2018 10:52 pm

Re: CRICKIT HAT Raspberry Pi CircuitPython BLinka API

Post by Chaski »

Hello;
I have a Raspberry Pi CRICKIT HAT. It is running motors and servos and sound! Yeah! Now, my class wants to add a on off switch.
How do I use the CRICKIT HAT Signal I/O pins connected to a toggle switch (see attachment)? I went to https://circuitpython.readthedocs.io/en ... nit__.html , but the code is for a Non Crickit HAT . I went to https://learn.adafruit.com/make-it-move ... cuitpython and am stuck. Please suggest example code how to use the Digital IO function..The code below does not work.

Code: Select all

from digitalio import DigitalInOut, Pull, Direction
from adafruit_crickit import crickit
import board
 
# Use a button or switch with SIGNAL IO CRICKIT HAT pins
button_a = DigitalInOut(board.??_D01_??)
Thank you for your time.
Attachments
SignalIO.JPG
SignalIO.JPG (25.08 KiB) Viewed 873 times

User avatar
adafruit_support_carter
 
Posts: 29150
Joined: Tue Nov 29, 2016 2:45 pm

Re: CRICKIT HAT Raspberry Pi CircuitPython BLinka API

Post by adafruit_support_carter »

You've got it. What you are missing is the what the SIGNAL I/O inputs are referred to as. They are the SIGNALx constants defined in the crickit module. So, for example, to setup for a button attached to SIGNAL I/O port 1, use:

Code: Select all

button_a = DigitalInOut(crickit.SIGNAL1)
or SIGNAL2 for 2, etc.

User avatar
Chaski
 
Posts: 30
Joined: Thu May 31, 2018 10:52 pm

Re: CRICKIT HAT Raspberry Pi CircuitPython BLinka API

Post by Chaski »

Thank you.
Now that I know the keyword, I search on the Adafruit website and found the NEWEST update...

https://learn.adafruit.com/adafruit-cri ... on-signals

User avatar
Chaski
 
Posts: 30
Joined: Thu May 31, 2018 10:52 pm

Re: CRICKIT HAT Raspberry Pi CircuitPython BLinka API

Post by Chaski »

Greetings;
Yesterday I installed on the Raspberry Pi pip3 install mu-editor and tried also sudo apt-get install mu-editor. Thus, now on the Raspberry Pi, I have mu editor 1.02 . Does the sensor plotting Icon only show up on Windows version of mu-editor because the plotting ICON does not show up on the RPi/ CRICKIT HAT ? The link, https://learn.adafruit.com/make-it-grap ... hon-and-mu shows plotting with the Circuit Python Express (CPX) hardware.

Also, my pi with the CRICKIT HAT works with the Thonny IDE, but is not recognized by mu editor. In the lower right hand I selected Adafruit, but the CRICKIT HAT hardware is not recognized?

User avatar
adafruit_support_carter
 
Posts: 29150
Joined: Tue Nov 29, 2016 2:45 pm

Re: CRICKIT HAT Raspberry Pi CircuitPython BLinka API

Post by adafruit_support_carter »

It's possible. You can file an issue with Mu if you want:
https://github.com/mu-editor/mu

Mu is meant to talk to microcontroller boards running CircuitPython. The Crickit HAT is a peripheral device. You can write Python programs to use it, but you don't push programs to it the way you do with CircuitPython boards.

User avatar
Chaski
 
Posts: 30
Joined: Thu May 31, 2018 10:52 pm

Re: CRICKIT HAT Raspberry Pi CircuitPython BLinka API

Post by Chaski »

Greetings;
In the following project uses makecode to rotate a motor https://learn.adafruit.com/collapsible- ... pload-code . Is there a way in makecode or in CircuitPython to adjust the rotation speed? I do not see any methods to adjust the stepper motor or servo motor rotational speed?

Code: Select all

 https://circuitpython.readthedocs.io/projects/crickit/en/latest/api.html
. Is that correct?

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: CRICKIT HAT Raspberry Pi CircuitPython BLinka API

Post by Franklin97355 »

You would not set the rotational speed but you would set the position in increments with a short delay between each. You could do that in a for loop.

User avatar
Chaski
 
Posts: 30
Joined: Thu May 31, 2018 10:52 pm

Re: CRICKIT HAT Raspberry Pi CircuitPython BLinka API

Post by Chaski »

Thanks ,
That is a very good option.
then I can , with my students, I can show how fast the code runs using time.time

https://pythonhow.com/measure-execution ... thon-code/

Code: Select all

 import time

t0 = time.time()
code_block
t1 = time.time()

total = t1-t0  

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

Return to “For Educators”