Adafruit Feather M4 Express Manual Download Page 110

Find the pin

Use the diagrams below to find the A0 pin marked with a magenta arrow!

Circuit Playground Express
 

A0 is located between VOUT and A1 near the battery
port.

Trinket M0
 

A0 is labeled "1~" on Trinket! A0 is located between "0"
and "2" towards the middle of the board on the same
side as the red LED.

© Adafruit Industries

https://learn.adafruit.com/adafruit-feather-m4-express-atsamd51

Page 115 of 183

Summary of Contents for Feather M4 Express

Page 1: ...Adafruit Feather M4 Express Created by lady ada Last updated on 2019 03 04 10 41 14 PM UTC...

Page 2: ...ll our FeatherWings What a great way to quickly get up and running The most exciting part of the Feather M4 is that while you can use it with the Arduino IDE and it s bonkers fast when you do we are s...

Page 3: ...d serial port debugging Built in crypto engines with AES 256 bit true RNG Pubkey controller Tons of GPIO 21 x GPIO pins with following capabilities Dual 1 MSPS 12 bit true analog DAC A0 and A1 can be...

Page 4: ...d then with our helper program access the files over USB Easy reprogramming the Feather M4 comes pre loaded with the UF2 bootloader https adafru it vQd which looks like a USB storage key Simply drag f...

Page 5: ...Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 10 of 183...

Page 6: ...e voltage to from the JST jack for the optional Lipoly battery USB this is the positive voltage to from the micro USB jack if connected EN this is the 3 3V regulator s enable pin It s pulled up so con...

Page 7: ...alog Pins A0 This pin is analog input A0 but is also an analog output due to having a DAC digital to analog converter You can set the raw voltage to anything from 0 to 3 3V unlike PWM outputs this is...

Page 8: ...device has enumerated correctly green or USB failure red In CircuitPython the LED is used to indicate the runtime status The QSPI Flash is connected to 6 pins that are not brought out on the GPIO pad...

Page 9: ...han 3 3V Debugging Interface If you d like to do more advanced development trace debugging or not use the bootloader we have the SWD interface exposed You ll have to solder to the two SWD SWCLK pads o...

Page 10: ...e and configure your Feather Header Options Before you go gung ho on soldering there s a few options to consider The first option is soldering in plain male headers this lets you plug in the Feather i...

Page 11: ...h socket female headers This won t let you plug the Feather into a breadboard but it will let you attach featherwings very easily Adafruit Industries https learn adafruit com adafruit feather m4 expre...

Page 12: ...e also have slim versions of the female headers that are a little shorter and give a more compact shape Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 17 of 183...

Page 13: ...ss breadboard and plug a featherwing on top But its a little bulky Soldering in Plain Headers Prepare the header strip Cut the strip to length if necessary It will be easier to solder if you insert it...

Page 14: ...through the breakout pads And Solder Be sure to solder all pins for reliable electrical contact For tips on soldering be sure to check out our Guide to Excellent Soldering https adafru it aTk Adafrui...

Page 15: ...Solder the other strip as well Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 20 of 183...

Page 16: ...e onto the next steps Soldering on Female Header Tape In Place For sockets you ll want to tape them in place so when you flip over the board they don t fall out Adafruit Industries https learn adafrui...

Page 17: ...Flip Tack Solder After flipping over solder one or two points on each strip to tack the header in place Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 22 of 183...

Page 18: ...l pins for reliable electrical contact For tips on soldering be sure to check out our Guide to Excellent Soldering https adafru it aTk Adafruit Industries https learn adafruit com adafruit feather m4...

Page 19: ...You re done Check your solder joints visually and continue onto the next steps Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 24 of 183...

Page 20: ...tery to the JST jack This will let the Feather run on a rechargable battery When the USB power is powered it will automatically switch over to USB for power as well as start charging the battery if at...

Page 21: ...na know what the voltage is at That way you can tell when the battery needs recharging Lipoly batteries are maxed out at 4 2V and stick around 3 7V for much of the battery life then slowly sink down t...

Page 22: ...supply use a 5V buck converter https adafru it DHs and wire it to a USB cable s 5V and GND input https adafru it DHu Here s what you cannot do Do not use alkaline or NiMH batteries and connect to the...

Page 23: ...ngs use those pins for high current usages You may end up damaging your Feather Connect an external 5V power supply to the USB and GND pins Not recommended this may cause unexpected behavior when plug...

Page 24: ...tps adafru it f1P After you have downloaded and installed the latest version of Arduino IDE you will need to start the IDE and navigate to the Preferences menu You can access it from the File menu in...

Page 25: ...ble installed boards To find the most up to date list of URLs you can add you can visit the list of third party board URLs on the Arduino IDE wiki https adafru it f7U We will only need to add one URL...

Page 26: ...rduino Leonardo Micro MIDI USB This adds MIDI over USB support for the Flora Feather 32u4 Micro and Leonardo using the arcore project https adafru it eSI If you have multiple boards you want to suppor...

Page 27: ...menu Once the Board Manager opens click on the category drop down menu on the top left hand side of the window and select All You will then be able to select and install the boards supplied by the URL...

Page 28: ...now be able to select and upload to the new boards listed in the Tools Board menu Select the matching board the current options are Feather M0 for use with any Feather M0 other than the Express Feathe...

Page 29: ...to download our Driver Installer https adafru it AB0 https adafru it AB0 Download and run the installer Run the installer Since we bundle the SiLabs and FTDI drivers as well you ll need to click thro...

Page 30: ...d your first blink sketch Plug in the M0 or M4 board and wait for it to be recognized by the OS just takes a few seconds It will create a serial COM port you can now select it from the drop down it ll...

Page 31: ...d Properly about the BOOT drive You can ignore that message it s an artifact of how the bootloader and uploading work the setup function runs once when you press reset or power the board void setup in...

Page 32: ...t its in bootloader mode Once it is in bootloader mode you can select the newly created COM Serial port and re try uploading You may need to go back and reselect the normal USB serial port next time y...

Page 33: ...se rules is made to configure modem manager not to touch the Feather board and will fix the programming difficulty issue Follow the steps for installing Adafruit s udev rules on this page https adafru...

Page 34: ...ware which means it s free for anyone to use modify or improve upon CircuitPython adds hardware support to all of these amazing features If you already have Python knowledge you can easily apply that...

Page 35: ...teracting with files Strong hardware support There are many libraries and drivers for sensors breakout boards and other external components It s Python Python is the fastest growing programming langua...

Page 36: ...te The following instructions will show you how to install CircuitPython If you ve already installed CircuitPython but are looking to update it or reinstall it the same steps work for that as well Set...

Page 37: ...e the NeoPixel RGB LED turn green If it turns red check the USB cable try another USB port etc Note The little red LED next to the USB connector will pulse red That s ok If double clicking doesn t wor...

Page 38: ...ive called CIRCUITPY will appear That s it you re done Further Information For more detailed info on installing CircuitPython check out Installing CircuitPython https adafru it Amd Adafruit Industries...

Page 39: ...7 Installing Mu for Linux Each Linux distro is a little different so use this as a guideline 1 Mu require python version 3 If you haven t installed python yet do so via your command line using somethi...

Page 40: ...the gear icon If the mode says Microbit or something else click on that and then choose Adafruit in the dialog box that appears Mu attempts to auto detect your board so please plug in your CircuitPyt...

Page 41: ...Current versions are available from links at the bottom of this page https adafru it Be5 However use at your own risk These are not stable versions and come with no guarantees of working Adafruit Indu...

Page 42: ...rs don t write back changes immediately to files that you edit That can cause problems when using CircuitPython See the Editing Code https adafru it id3 section below If you want to skip that section...

Page 43: ...re indented exactly the same amount All other lines have no spaces before the text Save this file as code py on your CIRCUITPY drive On each board you ll find a tiny red LED It should now be blinking...

Page 44: ...not seem to have this delay which is nice This is really important to be aware of If you unplug or reset the board before your computer finishes writing the file to your board you can corrupt the dri...

Page 45: ...the editors above If you are using notepad be sure to eject the drive see below IDLE does not force out changes immediately nano on Linux does not force out changes Anything else we haven t tested oth...

Page 46: ...D on your board Something changed Do you know why Let s find out Exploring Your First CircuitPython Program First we ll take a look at the code we re editing Here is the original code again import boa...

Page 47: ...ime let s you pass time by sleeping Setting Up The LED The next two lines setup the code to use the LED Your board knows the red LED as D13 So we initialise that pin and we set it to output We set led...

Page 48: ...eaves the LED on and off Now try increasing both of the 0 1 to 1 Your LED will blink much more slowly because you ve increased the amount of time that the LED is turned on and off Well done You re doi...

Page 49: ...quires a terminal program A terminal is a program that gives you a text based interface to perform various tasks Are you using Mu If so good news The serial console is built into Mu and will autodetec...

Page 50: ...serial console you can run the serial console as a separate program Windows requires you to download a terminal program check out this page for more details https adafru it AAH Mac and Linux both have...

Page 51: ...your file Now let s go take a look at the window with our connection to the serial console Excellent Our print statement is showing up in our console Try changing the printed text to something else K...

Page 52: ...value True so that it says led value Tru Save your file You will notice that your red LED will stop blinking and you may have a colored status LED blinking at you This is because the code is no longer...

Page 53: ...ou know what to look for You spelled True wrong Fix the typo and save your file Nice job fixing the error Your serial console is streaming and your red LED Is blinking again The serial console will di...

Page 54: ...e CTRL D to reload Follow those instructions and press any key on your keyboard The Traceback most recent call last is telling you the last thing your board was doing before you pressed Ctrl C and int...

Page 55: ...code The first thing we ll do is run help This will tell us where to start exploring the REPL To run code in the REPL type it in next to the REPL prompt Type help next to the prompt in the REPL Then...

Page 56: ...st Type import board into the REPL and press enter It ll go to a new prompt It might look like nothing happened but that s not the case If you recall the import statement simply tells the code to expe...

Page 57: ...to the REPL to test them As we said though remember that nothing typed into the REPL is saved There s a lot the REPL can do for you It s great for testing new ideas if you want to see if a few new lin...

Page 58: ...Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 63 of 183...

Page 59: ...s we can place our library files in the lib directory because its part of the Python path by default One downside of this approach of separate libraries is that they are not built in To use them one n...

Page 60: ...n firmware version If you don t know the version look at the initial prompt in the CircuitPython REPL which reports the version For example if you re running v3 0 2 download the v3 library bundle Ther...

Page 61: ...new folder and call it lib Then open the lib folder you extracted from the downloaded zip Inside you ll find a number of folders and mpy files Find the library you d like to use and copy it to the li...

Page 62: ...ED starts blinking again Let s check the serial console No errors Excellent You ve successfully resolved an ImportError If you run into this error in the future follow along with the steps above and c...

Page 63: ...board Updating CircuitPython Libraries Examples Libraries and examples are updated from time to time and it s important to update the files you have on your CIRCUITPY drive To update a single library...

Page 64: ...ome of the common questions regarding CircuitPython and CircuitPython microcontrollers Is ESP8266 or ESP32 supported in CircuitPython Why not Adafruit Industries https learn adafruit com adafruit feat...

Page 65: ...How do I connect to the Internet with CircuitPython Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 70 of 183...

Page 66: ...Is there asyncio support in CircuitPython Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 71 of 183...

Page 67: ...My RGB NeoPixel DotStar LED is blinking funny colors what does it mean Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 72 of 183...

Page 68: ...code or any other clean up you can do to shorten your code If you re using a lot of functions you could try moving those into a separate library creating a mpy of that library and importing it into y...

Page 69: ...when they will be included Does Feather M0 support WINC1500 No WINC1500 will not fit into the M0 flash space Can AVRs such as ATmega328 or ATmega2560 run CircuitPython No Commonly Used Acronyms CP or...

Page 70: ...ome of the common questions regarding CircuitPython and CircuitPython microcontrollers Is ESP8266 or ESP32 supported in CircuitPython Why not Adafruit Industries https learn adafruit com adafruit feat...

Page 71: ...How do I connect to the Internet with CircuitPython Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 76 of 183...

Page 72: ...Is there asyncio support in CircuitPython Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 77 of 183...

Page 73: ...My RGB NeoPixel DotStar LED is blinking funny colors what does it mean Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 78 of 183...

Page 74: ...code or any other clean up you can do to shorten your code If you re using a lot of functions you could try moving those into a separate library creating a mpy of that library and importing it into y...

Page 75: ...when they will be included Does Feather M0 support WINC1500 No WINC1500 will not fit into the M0 flash space Can AVRs such as ATmega328 or ATmega2560 run CircuitPython No Commonly Used Acronyms CP or...

Page 76: ...hich your board can communicate with your computer using USB We ll use Windows Device Manager to determine which port the board is using The easiest way to determine which port the board is using is t...

Page 77: ...ad However the 64 bit version will work on most PCs Now you need to open PuTTY Under Connection type choose the button next to Serial In the box under Serial line enter the serial port you found that...

Page 78: ...ndow A new window will open If no code is running the window will either be blank or will look like the window above Now you re ready to see the results of your code Great job You ve connected to the...

Page 79: ...hich your board can communicate with your computer using USB We ll use Windows Device Manager to determine which port the board is using The easiest way to determine which port the board is using is t...

Page 80: ...ad However the 64 bit version will work on most PCs Now you need to open PuTTY Under Connection type choose the button next to Serial In the box under Serial line enter the serial port you found that...

Page 81: ...ndow A new window will open If no code is running the window will either be blank or will look like the window above Now you re ready to see the results of your code Great job You ve connected to the...

Page 82: ...M0 Basic Feather M0 Adalogger and similar boards use a regular Arduino compatible bootloader which does not show a boardnameBOOT drive MakeCode If you are running a MakeCode https adafru it zbY progra...

Page 83: ...ruit support forums https adafru it jIf or on the Adafruit Discord if this does not work for you Windows Explorer Locks Up When Accessing boardnameBOOT Drive On Windows several third party programs we...

Page 84: ...nes tall or less you may only see blank lines or blank lines followed by Press any key to enter the REPL Use CTRL D to reload If this is the case you need to either mouse over the top of the panel to...

Page 85: ...icular the mpy binary format changed between CircuitPython versions 2 x and 3 x as well as between 1 x and 2 x So for instance if you upgraded to CircuitPython 3 x from 2 x you ll need to download a n...

Page 86: ...Express If you are running a version of CircuitPython before 2 3 0 and you don t want to upgrade or you can t get to the REPL you can do this 1 Download the correct erase file https adafru it AdI htt...

Page 87: ...le click the reset button on the board to bring up the boardnameBOOT drive 3 Drag the erase uf2 file to the boardnameBOOT drive 4 The boot LED will start flashing again and the boardnameBOOT drive wil...

Page 88: ...llow the steps below to maximize the amount of space available on OSX Prevent Remove Mac OSX Hidden Files First find the volume name for your board With the board plugged in run this command in a term...

Page 89: ...annot use drag and drop copy in Finder because it will still create these hidden extended attribute files in some cases for files downloaded from the internet like Adafruit s modules To copy a file or...

Page 90: ...Whoa We have 13Ki more than before This space can now be used for libraries and code Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 95 of 183...

Page 91: ...main py or code py any other files the lib folder etc You may lose these files when you remove CircuitPython so backups are key Just drag the files to a folder on your laptop or desktop computer like...

Page 92: ...firmware to Arduino it s also pretty easy Start by plugging in your board and double clicking reset until you get the green onboard LED s just like with MakeCode Within Arduino IDE select the matchin...

Page 93: ...tically reset when you upload the setup function runs once when you press reset or power the board void setup initialize digital pin 13 as an output pinMode 13 OUTPUT the loop function runs over and o...

Page 94: ...s is your first microcontroller board or you re a computer engineer you have something important to offer the Adafruit CircuitPython community We re going to highlight some of the many ways you can be...

Page 95: ...ep a maker moving forward The Adafruit Discord is the 24x7x365 hackerspace that you can bring your granddaughter to Visit https adafru it discord to sign up for Discord We re looking forward to meetin...

Page 96: ...These are things we ve identified as something that someone with any level of experience can help with These issues include options like updating documentation providing feedback and fixing simple bug...

Page 97: ...tPython There are details about each of thecore modules https adafru it Beh Each module lists the available libraries Each module library page lists the available parameters and an explanation for eac...

Page 98: ...erent boards and explain how to use the code with each board These examples work with any board designed for CircuitPython including Circuit Playground Express Trinket M0 Gemma M0 ItsyBitsy M0 Express...

Page 99: ...floating point values so you can use int and float whenever you expect Tuples Lists Arrays and Dictionaries You can organize data in and including strings objects floats etc Classes Objects and Funct...

Page 100: ...h DigitalInOut board D7 depending on what changes you already made and uncomment switch DigitalInOut board D5 For Circuit Playground Express you ll need to comment out switch DigitalInOut board D2 and...

Page 101: ...oard explains the location of the Digital pin suggested for use as input and the location of the D13 LED Circuit Playground Express We re going to use the switch which is pin D7 and is located between...

Page 102: ...to the blue wire on the board D13 is labeled 13 and is located next to the USB micro port To use D5 comment out the current pin setup line and uncomment the line labeled for Feather M0 Express See th...

Page 103: ...blue wire D13 is labeled L and is located next to the USB micro port Read the Docs For a more in depth look at what digitalio can do check out the DigitalInOut page in Read the Docs https adafru it C...

Page 104: ...range from 0 minimum to 65535 maximum This helper will convert the 0 65535 reading from pin value and convert it a 0 3 3V voltage reading Main Loop The main loop is simple It prints out the voltage as...

Page 105: ...nges as you rotate the potentiometer on the plotter like in the image above Click the Plotter icon at the top of the window to open the plotter Wire it up The list below shows wiring diagrams to help...

Page 106: ...ide Trinket M0 A1 is labeled as 2 It s located between 1 and 3V on the same side of the board as the little red LED Ground is located on the opposite side of the board 3V is located next to 2 on the s...

Page 107: ...t see the pinout page https adafru it AMa on the main guide Feather M0 Express and Feather M4 Express A1 is located along the edge opposite the battery connector There are multiple ground pins 3V is l...

Page 108: ...M4 Express A1 is located on the same side of the board as the barrel jack There are multiple ground pins available 3V is labeled 3 3 and is located in the center of the board on the same side as the...

Page 109: ...t Main Loop The main loop is fairly simple it goes through the entire range of the DAC from 0 to 65535 but increments 64 at a time so it ends up clicking up one bit for each of the 10 bits of range av...

Page 110: ...und Express A0 is located between VOUT and A1 near the battery port Trinket M0 A0 is labeled 1 on Trinket A0 is located between 0 and 2 towards the middle of the board on the same side as the red LED...

Page 111: ...m the battery connector towards the end with the Reset button Feather M4 Express A0 is located between GND and A1 on the opposite side of the board from the battery connector towards the end with the...

Page 112: ...cated between VHI and A1 and the pin pad has left and right white parenthesis markings around it Metro M0 Express A0 is between VIN and A1 and is located along the same side of the board as the barrel...

Page 113: ...de of the board as the barrel jack adapter towards the middle of the headers found on that side of the board On the Metro M4 Express there are TWO true analog outputs A0 and A1 Adafruit Industries htt...

Page 114: ...is below 50 it PWMs the LED brightness up and when the range is above 50 it PWMs the brightness down This is how it fades the LED brighter and dimmer The time sleep is needed to allow the PWM process...

Page 115: ...n on the M4 boards As you can see it s much simpler Remember To comment out a line put a and a space before it To uncomment a line remove the space from the beginning of the line import time import bo...

Page 116: ...5 SLIDE_SWITCH D7 D13 REMOTEIN IR_RX REMOTEOUT IR_TX IR_PROXIMITY MICROPHONE_CLOCK MICROPHONE_DATA ACCELEROMETER_INTERRUPT ACCELEROMETER_SDA ACCELEROMETER_SCL SPEAKER_ENABLE There is NO PWM on A0 SPEA...

Page 117: ...4 SCK MOSI MISO D0 RX D1 TX SDA SCL D5 D6 D9 D10 D11 D12 D13 NEOPIXEL There is NO PWM on A0 A1 A5 Feather M4 Express Use jumper wires to attach A1 and one of the two GND to different legs of the piezo...

Page 118: ...line and uncomment the line labeled for the M4 boards See the details above ItsyBitsy M0 Express has PWM on the following pins A1 D0 RX D1 TX D2 D4 D5 D7 D9 D10 D11 D12 D13 SDA SCL There is NO PWM on...

Page 119: ...PWM on every pin available and lets you know which ones work and which ones don t Check it out import board import pulseio for pin_name in dir board pin getattr board pin_name try p pulseio PWMOut pi...

Page 120: ...ring Connect the servo s brown or black ground wire to ground on the CircuitPython board Connect the servo s red power wire to 5V power USB power is good for a servo or two For more than that you ll n...

Page 121: ...wire alligator clips to connect the ground wire to GND the power wire to VOUT and the signal wire to A2 For boards like Feather M0 Express ItsyBitsy M0 Express and Metro M0 Express connect the ground...

Page 122: ...ax_pulse For example servo adafruit_motor servo Servo pwm min_pulse 0 5 max_pulse 2 5 For more detailed information on using servos with CircuitPython check out the CircuitPython section of the servo...

Page 123: ...necessary and we have called it NEOPIXEL for easier use In the case of a DotStar however there are two pins necessary and so we use the pin names APA102_MOSI and APA102_SCK to get it set up Since we r...

Page 124: ...a number between 0 and 255 that determines the amount of each color present Red green and blue in different combinations can create all the colors in the rainbow So for example to set the LED to red t...

Page 125: ...time sleep but try changing the amount of time to create different cycle animations Making Rainbows Because Who Doesn t Love Em Coding a rainbow effect involves a little math and a helper function ca...

Page 126: ...urrent code is only one So why bother with fill Well you may have a Circuit Playground Express which as you can see has TEN NeoPixel LEDs built in The examples so far have only turned on the first one...

Page 127: ...save the code and watch the rainbow go You can make the same 1 to 10 change to the previous examples as well and use led fill to light up all the LEDs in the colors you chose For more details check o...

Page 128: ...ls first Verify your connection is on the DATA INPUT or DIN side Plugging into the DATA OUT or DOUT side is a common mistake The connections are labeled and some formats have arrows to indicate the di...

Page 129: ...p or shape may not exactly match the diagram above Check the markings to verify which pin is DIN 5V and GND CircuitPython demo NeoPixel import time import board import neopixel pixel_pin board A1 num_...

Page 130: ...pixels i color time sleep wait pixels show time sleep 0 5 def rainbow_cycle wait for j in range 255 for i in range num_pixels rc_index i 256 num_pixels j pixels i wheel rc_index 255 pixels show time...

Page 131: ...g each subsequent LED the same color during the chase Last we call rainbow_cycle 0 which means the animation is as fast as it can be Increase both of those numbers to slow down each animation Note tha...

Page 132: ...ime sleep 0 5 def rainbow_cycle wait for j in range 255 for i in range num_pixels rc_index i 256 num_pixels j pixels i wheel rc_index 255 pixels show time sleep wait RED 255 0 0 0 YELLOW 255 150 0 0 G...

Page 133: ...on Read the Docs https adafru it C5m color_chase GREEN 0 1 color_chase CYAN 0 1 color_chase BLUE 0 1 color_chase PURPLE 0 1 rainbow_cycle 0 Increase the number to slow down the rainbow Adafruit Indust...

Page 134: ...ide Plugging into the DATA OUT DO or CLOCK OUT CO side is a common mistake The connections are labeled and some formats have arrows to indicate the direction the data must flow Always verify your wiri...

Page 135: ...board A1 board A2 num_pixels brightness 0 1 auto_write False def wheel pos Input a value 0 to 255 to get a color value The colours are a transition r g b back to r if pos 0 or pos 255 return 0 0 0 if...

Page 136: ...rainbow wait pixels 6 RED num_pixels 6 pixels show time sleep wait pixels 1 6 ORANGE num_pixels 6 pixels show time sleep wait pixels 2 6 YELLOW num_pixels 6 pixels show time sleep wait pixels 3 6 GREE...

Page 137: ...on t need to include it in your LED object at all We ve chosen to set auto_write False If you set auto_write False you must include pixels show each time you d like to send data GREEN 0 255 0 TEAL 0 2...

Page 138: ...ber of LEDs that is divisible by the slices the code will work Main Loop Our main loop begins by calling color_fill once for each color on our list and sets each to hold for 0 5 seconds You can change...

Page 139: ..._pin data_pin try p busio SPI clock_pin data_pin p deinit return True except ValueError return False Provide the two pins you intend to use if is_hardware_spi board A1 board A2 print This pin combinat...

Page 140: ...provide the pins we d like to use board TX and board RX and we set the baudrate 9600 While these pins are labeled on most of the boards be aware that RX and TX are not labeled on Gemma and are labeled...

Page 141: ...press you ll need a breadboard and jumper wires to connect to the Ultimate GPS Breakout We ve included diagrams show you how to connect the GPS to your board In these diagrams the wire colors match th...

Page 142: ...et to VIN on the GPS Connect Gnd on the Trinket to GND on the GPS Connect D3 on the Trinket to TX on the GPS Connect D4 on the Trinket to RX on the GPS Watch out A common mixup with UART serial is tha...

Page 143: ...D0 on the Gemma to RX on the GPS Feather M0 Express and Feather M4 Express Connect USB on the Feather to VIN on the GPS Connect GND on the Feather to GND on the GPS Connect RX on the Feather to TX on...

Page 144: ...th fixed UART pins The good news is you can use many but not all pins Given the large number of SAMD boards we have its impossible to guarantee anything other than the labeled TX and RX So if you want...

Page 145: ...sio UART tx rx p deinit return True except ValueError return False def get_unique_pins exclude NEOPIXEL APA102_MOSI APA102_SCK pins pin for pin in getattr board p for p in dir board if p not in exclud...

Page 146: ...o I2C board SCL board SDA uart busio UART board TX board RX Traceback most recent call last File line 1 in ValueError Invalid pins Adafruit Industries https learn adafruit com adafruit feather m4 expr...

Page 147: ...SL2561 lux sensor Flora and breakout The first thing you ll want to do is get the sensor connected so your board has I2C to talk to Wire It Up You ll need a couple of things to connect the TSL2561 to...

Page 148: ...r TSL2561 Connect SDL A5 on your CPX to SDA on your TSL2561 Trinket M0 Connect USB on the Trinket to VIN on the TSL2561 Connect Gnd on the Trinket to GND on the TSL2561 Connect D2 on the Trinket to SC...

Page 149: ...the Gemma to SDA on the TSL2561 Feather M0 Express and Feather M4 Express Connect USB on the Feather to VIN on the TSL2561 Connect GND on the Feather to GND on the TSL2561 Connect SCL on the Feather t...

Page 150: ...ect GND on the Metro to GND on the TSL2561 Connect SCL on the Metro to SCL on the TSL2561 Connect SDA on the Metro to SDA on the TSL2561 Find Your Sensor The first thing you ll want to do after gettin...

Page 151: ...resses We ve connected the TSL2561 which has a 7 bit I2C address of 0x39 The result for this sensor is I2C addresses found 0x39 If no addresses are returned refer back to the wiring diagrams to make s...

Page 152: ...nnect to the serial console to see the results Try shining a light on it to see the results change CircuitPython Demo I2C sensor import time import adafruit_tsl2561 import board import busio i2c busio...

Page 153: ...me other setup or multiple I2C interfaces how will you find those pins Easy We ve written a handy script All you need to do is copy this file to your board rename it code py connect to the serial cons...

Page 154: ...CK pins pin for pin in getattr board p for p in dir board if p not in exclude if isinstance pin Pin unique for p in pins if p not in unique unique append p return unique for scl_pin in get_unique_pins...

Page 155: ...eck out the CircuitPython Libraries page https adafru it ABU CircuitPython Keyboard Emulator Copy and paste the code into code py using your favorite editor and save the file CircuitPython demo Keyboa...

Page 156: ...to control_key which allows us to later apply the shift key to our keypress We ll be using two keypresses but you can have up to six keypresses at once Next keyboard and keyboard_layout objects are cr...

Page 157: ...retrieves the keypress a if you grounded and ungrounded A2 the code retrieves the string Hello world If the code finds that it s retrieved a string it prints the string using the keyboard_layout to de...

Page 158: ...d to verify your wiring def steps axis Maps the potentiometer voltage range to 0 20 return round axis pot_min step while True x get_voltage x_axis y get_voltage y_axis if select value is False mouse c...

Page 159: ...t we have the get_voltage helper so we can get the correct readings from the potentiometers Look familiar We learned about it in Analog In https adafru it Bep Second we have steps axis To use it you p...

Page 160: ...to move the mouse the appropriate direction by 1 unit The second set for each axis says if the joystick is moved to the lowest or highest step for each axis to move the mouse the appropriate directio...

Page 161: ...itch digitalio DigitalInOut board D5 For Circuit Playground Express comment out switch digitalio DigitalInOut board D2 and uncomment switch digitalio DigitalInOut board D7 The following is your new co...

Page 162: ...tead of wiring up a switch however you ll be connecting the pin directly to ground with alligator clips or jumper wires import time import board import digitalio import microcontroller led digitalio D...

Page 163: ...come in live Instead when you re ready to grab the data eject and unplug your board For CPX move the switch to the left otherwise remove the wire connecting the pin to ground Now it will be possible f...

Page 164: ...Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 169 of 183...

Page 165: ...em in the REPL Plug in your board connect to the serial console https adafru it Bec and enter the REPL https adafru it Awz Then enter the following commands into the REPL That s it You ve printed the...

Page 166: ...uino plug in your board and then load your Arduino sketch If there are any issues you can double tap the reset button to get into the bootloader and then try loading your sketch Always backup any file...

Page 167: ...libraries are not available So for instance while we wish you could import numpy numpy isn t available So you may have to port some code over yourself Integers in CircuitPython On the non Express boar...

Page 168: ...Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 173 of 183...

Page 169: ...built bootloaders https adafru it Bev Entering Bootloader Mode The first step to loading new code onto your board is triggering the bootloader It is easily done by double tapping the reset button Once...

Page 170: ...sn t connected to a computer or maybe the drivers could not enumerate Try a new USB cable first Then try another port on your computer Once the bootloader is running check your computer You should see...

Page 171: ...de INFO_UF2 TXT Includes bootloader version info Please include it on bug reports Using the Mass Storage Bootloader To flash something new simply drag any UF2 onto the drive After the file is finished...

Page 172: ...ndard method of updating boards when in the Arduino IDE It is a command line tool that can be used in any operating system We won t cover the full use of the bossac tool suffice to say it can do quite...

Page 173: ...o verify the device showed up Open your Device Manager from the control panel and look under Ports COM LPT for a device called Feather M0 or Circuit Playground or whatever If you see something like th...

Page 174: ...Once downloaded extract the files from the zip and open the command line to the directory with bossac For example here s the command line you probably want to run bossac e w v R Downloads adafruit cir...

Page 175: ...ader section update the bootloader and re lock it It will overwrite your existing code such as CircuitPython or Arduino so make sure everything is backed up After the file is copied over the bootloade...

Page 176: ...id of Windows Pop ups If you do a lot of development on Windows with the UF2 bootloader you may get annoyed by the constant Hey you inserted a drive what do you want to do pop ups Go to the Control Pa...

Page 177: ...mmand will produce a firmware uf2 file in the same directory as the source firmware bin The uf2 can then be flashed in the same way as above Installing the bootloader on a fresh bricked board If you s...

Page 178: ...t Bf8 the main chip on the Feather M4 Fritzing object in the Adafruit Fritzing Library https adafru it aP3 EagleCAD PCB files in GitHub https adafru it BNv Schematic Fab Print Adafruit Industries Last...

Reviews: