/ README.rst
README.rst
1 Introduction 2 ============ 3 4 .. image:: https://readthedocs.org/projects/adafruit-circuitpython-crickit/badge/?version=latest 5 :target: https://circuitpython.readthedocs.io/projects/crickit/en/latest/ 6 :alt: Documentation Status 7 8 .. image:: https://img.shields.io/discord/327254708534116352.svg 9 :target: https://adafru.it/discord 10 :alt: Discord 11 12 .. image:: https://github.com/adafruit/Adafruit_CircuitPython_Crickit/workflows/Build%20CI/badge.svg 13 :target: https://github.com/adafruit/Adafruit_CircuitPython_Crickit/actions/ 14 :alt: Build Status 15 16 This convenience library makes coding for the Crickit robotics boards simpler and shorter. 17 18 Dependencies 19 ============= 20 This driver depends on: 21 22 * `Adafruit seesaw library <https://github.com/adafruit/Adafruit_Circuitpython_seesaw>`_ 23 * `Adafruit Motor library <https://github.com/adafruit/Adafruit_Circuitpython_Motor>`_ 24 25 26 Please ensure all dependencies are available on the CircuitPython filesystem. 27 This is easily achieved by downloading 28 `the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_. 29 30 Installing from PyPI 31 ==================== 32 33 On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from 34 PyPI <https://pypi.org/project/adafruit-circuitpython-crickit/>`_. To install for current user: 35 36 .. code-block:: shell 37 38 pip3 install adafruit-circuitpython-crickit 39 40 To install system-wide (this may be required in some cases): 41 42 .. code-block:: shell 43 44 sudo pip3 install adafruit-circuitpython-crickit 45 46 To install in a virtual environment in your current project: 47 48 .. code-block:: shell 49 50 mkdir project-name && cd project-name 51 python3 -m venv .env 52 source .env/bin/activate 53 pip3 install adafruit-circuitpython-crickit 54 55 Usage Example 56 ============= 57 58 This examples shows how to control all the devices supported by the library. 59 In most cases you just need a couple of imports. 60 61 .. code-block:: python 62 63 # This is a mock example showing typical usage of the library for each kind of device. 64 65 from adafruit_crickit import crickit 66 67 # Add this import if using stepper motors. 68 # It will expose constants saying how to step: stepper.FORWARD, stepper.BACKWARD, etc. 69 from adafruit_motor import stepper 70 71 # Set servo 1 to 90 degrees 72 crickit.servo_1.angle = 90 73 74 # Change servo settings. 75 crickit.servo_1.actuation_range = 135 76 crickit.servo_1.set_pulse_width_range(min_pulse=850, max_pulse=2100) 77 78 # You can assign a device to a variable to get a shorter name. 79 servo_2 = crickit.servo_2 80 servo_2.throttle = 0 81 82 # Run a continous servo on Servo 2 backwards at half speed. 83 crickit.continuous_servo_2.throttle = -0.5 84 85 # Run the motor on Motor 1 terminals at half speed. 86 crickit.dc_motor_1.throttle = 0.5 87 88 # Set Drive 1 terminal to 3/4 strength. 89 crickit.drive_1.fraction = 0.75 90 91 if crickit.touch_1.value: 92 print("Touched terminal Touch 1") 93 94 # A single stepper motor uses up all the motor terminals. 95 crickit.stepper_motor.onestep(direction=stepper.FORWARD) 96 97 # You can also use the Drive terminals for a stepper motor 98 crickit.drive_stepper_motor.onestep(direction=stepper.BACKWARD) 99 100 # Note: On CPX Crickit, NeoPixel pin is normally connected to A1, not to seesaw, 101 # so this part of the demo cannot control the NeoPixel terminal. 102 # Strip or ring of 8 NeoPixels 103 crickit.init_neopixel(8) 104 crickit.neopixel.fill((100, 100, 100)) 105 106 # Set the Crickit's on-board NeoPixel to a dim purple. 107 crickit.onboard_pixel.brightness = 0.01 108 crickit.onboard_pixel[0] = (255, 24, 255) 109 # or 110 crickit.onboard_pixel.fill((255, 24, 255)) 111 112 Contributing 113 ============ 114 115 Contributions are welcome! Please read our `Code of Conduct 116 <https://github.com/adafruit/Adafruit_CircuitPython_Crickit/blob/master/CODE_OF_CONDUCT.md>`_ 117 before contributing to help this project stay welcoming. 118 119 Documentation 120 ============= 121 122 For information on building library documentation, please check out `this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.