{"id":6594,"date":"2022-02-24T12:01:12","date_gmt":"2022-02-24T17:01:12","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2022\/?page_id=6594"},"modified":"2022-02-24T12:01:55","modified_gmt":"2022-02-24T17:01:55","slug":"class-12","status":"publish","type":"page","link":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2022\/class-notes\/class-12\/","title":{"rendered":"Class 12 &#8211; Thu Feb 24 &#8211; CircuitPython"},"content":{"rendered":"\n<p>Feb 24, 2022, 12:20PM to 2:10PM<\/p>\n\n\n\n<p>Welcome!  The main objectives for today are to introduce the <a rel=\"noreferrer noopener\" href=\"https:\/\/www.adafruit.com\/product\/4333\" target=\"_blank\">Adafruit Circuit Playground Bluefruit<\/a> microcontroller and <a rel=\"noreferrer noopener\" href=\"https:\/\/learn.adafruit.com\/welcome-to-circuitpython\" target=\"_blank\">CircuitPython<\/a> programming.  You will work in pairs for this learning activity today.<\/p>\n\n\n\n<p>You will need <meta charset=\"utf-8\">a laptop for today (one per pair).  Please try to install the free <a href=\"https:\/\/codewith.mu\/\">mu editor<\/a> (or equivalent tools) in advance for working with CircuitPython microcontrollers.  <\/p>\n\n\n\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">Contents<\/p><ul class=\"toc_list\"><li><a href=\"#Administrative\"><span class=\"toc_number toc_depth_1\">1<\/span> Administrative<\/a><\/li><li><a href=\"#Looking_Ahead\"><span class=\"toc_number toc_depth_1\">2<\/span> Looking Ahead<\/a><\/li><li><a href=\"#Materials_for_Today\"><span class=\"toc_number toc_depth_1\">3<\/span> Materials for Today<\/a><\/li><li><a href=\"#Circuit_Playground_Bluefruit_Microcontroller\"><span class=\"toc_number toc_depth_1\">4<\/span> Circuit Playground Bluefruit Microcontroller<\/a><ul><li><a href=\"#Downloads\"><span class=\"toc_number toc_depth_2\">4.1<\/span> Downloads<\/a><\/li><li><a href=\"#Live_Demo\"><span class=\"toc_number toc_depth_2\">4.2<\/span> Live Demo<\/a><\/li><li><a href=\"#Setting_Up_Your_Hardware\"><span class=\"toc_number toc_depth_2\">4.3<\/span> Setting Up Your Hardware<\/a><\/li><li><a href=\"#Crickit\"><span class=\"toc_number toc_depth_2\">4.4<\/span> Crickit<\/a><\/li><li><a href=\"#Next_Steps\"><span class=\"toc_number toc_depth_2\">4.5<\/span> Next Steps<\/a><\/li><\/ul><\/li><li><a href=\"#Assignment\"><span class=\"toc_number toc_depth_1\">5<\/span> Assignment<\/a><\/li><\/ul><\/div>\n<h2><span id=\"Administrative\">Administrative<\/span><\/h2>\n\n\n\n<p>Next class we have a fantastic visiting speaker &#8211; Chico MacMurtrie &#8211; you are welcome to invite a friend to the talk at 1pm on Tues., Mar. 1.<\/p>\n\n\n\n<h2><span id=\"Looking_Ahead\">Looking Ahead<\/span><\/h2>\n\n\n\n<ul><li>Tuesday: visiting speaker (in-class, but remote presenter )<\/li><li>Thursday: costume integration, improvisatory kinetic sculpture<\/li><li>(Spring Break.)<\/li><li>(Start project, with interspersed topical workshops.)<\/li><\/ul>\n\n\n\n<h2><span id=\"Materials_for_Today\">Materials for Today<\/span><\/h2>\n\n\n\n<ul><li>Bluefruit installed on Crickit<\/li><li>5V 3A power adapter<\/li><li>micro-USB cable for your laptop<\/li><li>your personal laptop<\/li><li>DC motor pump<\/li><li>micro hobby servo<\/li><li>small flat screwdriver<\/li><\/ul>\n\n\n\n<h2><span id=\"Circuit_Playground_Bluefruit_Microcontroller\">Circuit Playground Bluefruit Microcontroller<\/span><\/h2>\n\n\n\n<p>The motorized elements of our kinetic creations will be controlled using a wearable microcontroller to measure sensors, operate actuators, and perform scripted actions. Today\u2019s objective is to help you get started with the tools.<\/p>\n\n\n\n<p>We will generally be following the hardware notes and sample code from the course technical guide.   But we\u2019ll go step by step at a novice level so no one gets left behind.<\/p>\n\n\n\n<p>The link to the guide can always be found under  <a href=\"https:\/\/courses.ideate.cmu.edu\/16-376\/s2022\/ref\/text\/index.html\">SOFTWARE AND MECHANISM RESOURCES<\/a> in the left-hand navigation bar of the course website.<\/p>\n\n\n\n<h3><span id=\"Downloads\">Downloads<\/span><\/h3>\n\n\n\n<p>If you have not already installed the&nbsp;<a href=\"https:\/\/codewith.mu\/\">mu Python editor<\/a>, please also download that now and run the installer.<\/p>\n\n\n\n<h3><span id=\"Live_Demo\">Live Demo<\/span><\/h3>\n\n\n\n<p>We first want to give you a quick preview of the end goal for the day.<\/p>\n\n\n\n<ol><li>touch-sensitive light demo<\/li><li>mu editor<\/li><li>editing\/running code<\/li><li>interacting directly with the Python system<\/li><li>attaching a motor pump to the Crickit<\/li><li>attaching a hobby servo to the Crickit<\/li><\/ol>\n\n\n\n<h3><span id=\"Setting_Up_Your_Hardware\">Setting Up Your Hardware<\/span><\/h3>\n\n\n\n<ol><li>connecting the board<\/li><li>testing using mu \u2018Serial\u2019, the read-eval-print loop (REPL) window<br><code>2+2<\/code><br><code>3**201<\/code><br><code>import time<\/code><br><code>time.monotonic()<\/code><br><code>help('modules')<\/code><\/li><li>testing the library<br><code>from adafruit_circuitplayground import cp<\/code><br><code>cp.red_led = True<\/code><br><code>cp.play_tone(440, 1.0)<\/code><\/li><li>trying out&nbsp;<a href=\"https:\/\/courses.ideate.cmu.edu\/16-376\/s2022\/ref\/text\/code\/cpb-intro.html\">sample code<\/a><\/li><\/ol>\n\n\n\n<h3><span id=\"Crickit\">Crickit<\/span><\/h3>\n\n\n\n<p>The Crickit baseboard include motor drivers, hobby servo ports, and additional capacitive touch sensors.<\/p>\n\n\n\n<ol><li>Connecting a motor and running the sample code<\/li><li>Connecting a hobby servo and running the sample code.<\/li><\/ol>\n\n\n\n<h3><span id=\"Next_Steps\">Next Steps<\/span><\/h3>\n\n\n\n<p>CircuitPython lets you treat the microcontroller like a tiny data drive. Your code can be edited in-place, and saving will run it. But you\u2019ll need to work out a plan for copying final programs back to your computer for your documentation.<\/p>\n\n\n\n<ol><li>editing code in place<\/li><li>saving programs back to your computer<\/li><li>exploring the Adafruit tutorials<\/li><li>exploring the library documentation<\/li><\/ol>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2><span id=\"Assignment\">Assignment<\/span><\/h2>\n\n\n\n<p>Assignment 7<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Feb 24, 2022, 12:20PM to 2:10PM Welcome! The main objectives for today are to introduce the Adafruit Circuit Playground Bluefruit microcontroller and CircuitPython programming. You will work in&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":5504,"menu_order":12,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2022\/wp-json\/wp\/v2\/pages\/6594"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2022\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2022\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2022\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2022\/wp-json\/wp\/v2\/comments?post=6594"}],"version-history":[{"count":12,"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2022\/wp-json\/wp\/v2\/pages\/6594\/revisions"}],"predecessor-version":[{"id":6613,"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2022\/wp-json\/wp\/v2\/pages\/6594\/revisions\/6613"}],"up":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2022\/wp-json\/wp\/v2\/pages\/5504"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2022\/wp-json\/wp\/v2\/media?parent=6594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}