Coder Social home page Coder Social logo

2019-ignite-circuit-playground's Introduction

Welcome to CircuitPython, the Circuit Playground Express, and the Device Simulator Express

This sample demonstrates the basic functionality of the Circuit Playground Express (CPX) and the Visual Studio Device Simulator Express extension.

The Circuit Playground Express is brought to you by Adafruit. It's pre-loaded with CircuitPython! CircuitPython is Adafruit's branch of MicroPython, designed to simplify experimentation and education on low-cost microcontrollers. It makes it easier than ever to get prototyping with Visual Studio Code.

Circuit Playground Express with lights on

The Device Simulator Express extension for VS Code, a Microsoft Garage project, allows you to code in CircuitPython for CPX projects. Test and debug your code on the device simulator and see the same result when you plug in your actual microcontroller. Observe the output of the device with the serial monitor.

Device Simulator Express new file side by side with simulator

What's on the device

The pre-loaded demo shows off some of what your Circuit Playground Express can do with CircuitPython:

  • The NeoPixel ring on the CPX animates with orange and white colors.
  • The switch controls the direction of the animation. Move the switch left and right to change the direction.
  • Press and hold Button A to dim the lights and Button B to brighten.
  • The touch pads labeled A1-A7 to play a scale of tones. Change the TONE_PIANO variable to False at the top of the file to disable the tone piano.
  • After installing the extension, connect to the serial port to print temperature, light intensity, and acceleration sensor readings in the console.
  • Shake the device to pause the lights and sensor reporting. Shake again to restart.

See "Formatting the device" below to return to this state or load the demo on a non-Ignite CPX.

Prerequisites

The following dependencies are required before launching Device Simulator Express:

  • Visual Studio Code
  • Node
  • Python 3.7.4
    • Make sure Python and pip are added to the PATH environment variables. To check whether Python has been added, type python in a terminal. Version 3.7.4 should print out.
    • If installing Python, select the "Add to PATH" option to add directly on install.
    • If Python is already installed but not not a PATH variable, search for instructions given your OS.

Install the Device Simulator Express extension:

The following Python dependencies will be installed by the Device Simulator Express extension on first use by clicking yes when prompted. Alternatively, install manually by typing the following commands in a console:

  • Playsound: pip install playsound
  • Python-Socketio: pip install python-socketio
  • Requests: pip install requests
  • Application Insights: pip install applicationinsights

If using Windows, install this additional Python dependency. It will not automatically install with the extension. Type the following command in a console:

  • Pywin 32: pip install pywin32

Setup and running the sample

CircuitPython code can run with either the simulator in VS Code or be deployed to the device.

Simulator - using the Device Simulator Express Extension

After installing the prerequisites and the Device Simulator Express extension, reload VS Code. To get started with the simulator:

  1. Start with a new file or open an sample. Create a new file with the "New File" command. CTRL+SHIFT+P to open the command palette and type Device Simulator Express: New File. Alternatively, open an existing .py file or sample.
  2. Run the code on the simulator. Run Device Simulator Express: Run Simulator from the command palette or the play icon in the editor toolbar.

For a detailed and visual walkthrough, visit the Device Simulator Express home page in the Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=ms-python.devicesimulatorexpress.

Device - deploy and run code on the Circuit Playground Express

Deploy code to the device:

  1. Save the file as "code.py".
  2. Connect the device to the computer via USB. It should be recognized as a drive.
  3. Replace the "code.py" file on the device. In the command palette type Device Simulator Express: Deploy to Device. The CPX will reboot and run the code.

If you want to work directly from the device, open the device as a folder in VS Code. Editing and saving the .py file will cause the device to reboot and run the code without the extra step of copying the file.

Use the Serial Monitor to see sensor data from the CPX (available on Windows or Mac only):

  1. Plug in the CPX.
  2. Run the command Device Simulator Express: Open Serial Monitor.
  3. Select the serial port and, if required, set baud rate.
  4. With the pre-loaded demo you'll see temperature, light, and accelerometer data. Use print() statements in code to show output in the console.

Formatting the device

If you picked up the device from the Development and Architecture Center at Ignite and the device boots and animates with orange and white lights, you're good to go. Edit the code.py file.

If you acquired the device elsewhere, follow these tutorials for formatting:

  1. Download the firmware with the .uf2 file: https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quickstart
  2. Download the latest version of the cpx library: https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries

If you'd like to return to the initial Ignite state, download the files from initial_board.

Note: Name your file "code.py". The device automatically runs the "code.py" file.

Useful links

Visit the CPX product page for more info on the device: https://adafruit.com/product/3333. To get started with CircuitPython, which comes built into the CPX, visit: https://learn.adafruit.com/welcome-to-circuitpython.

About Device Simulator Express

The Device Simulator Express extension is an open source extension built by Microsoft Garage interns. To learn more about the extension and contribute visit: https://github.com/microsoft/vscode-python-devicesimulator.

Contents

File/folder Description
initial_board Sample source code from Ignite.
.gitignore Define what to ignore at commit time.
CHANGELOG.md List of changes to the sample.
CONTRIBUTING.md Guidelines for contributing to the sample.
README.md This README file.
LICENSE The license for the sample.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

2019-ignite-circuit-playground's People

Contributors

microsoft-github-operations[bot] avatar microsoftopensource avatar yaynoel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.