[Beginer] How import board and digitalio

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
pierrot10
 
Posts: 349
Joined: Tue Nov 17, 2015 4:34 pm

[Beginer] How import board and digitalio

Post by pierrot10 »

Hello,

I am very new and I trying to code a Feather MO Adaloger with CircuitPython.
I add a free board and I succeeded this procedure https://learn.adafruit.com/welcome-to-c ... ac-2978784 with Bossac and now my board is running with CircuitPython https://circuitpython.org/board/feather_m0_adalogger/.

I uploaded a very simple file

Code: Select all

# Insert Module
import time
import board
import digitalio

# LEDs
d13 = digitalio.DigitalInOut(board.d13)
d13.switch_to_output()
d8 = digitalio.DigitalInOut(board.d8)
d8.switch_to_output()

while True:
    d13.switch_to_output()
    time.sleep(0.15)
    d8.switch_to_output()
    time.sleep(0.15)
But I got a basic error, because it can find 'board' and 'digitalio'.
the line

Code: Select all

import board
has an underline red and I could install the package but how can I do the same on CIRCUITPY drive?
However I do not have the option to install the package for digitalio. So how can I have the both module on CIRCUITPY?

I supposed, I should have a library file in the lib folder?

Many thanks for your clarification

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: [Beginer] How import board and digitalio

Post by dastels »

Both board and digitalio are built into CircuitPython; there are no files to put in lib.

You have the CIRCUITPY drive mounting?

The Feather M0 has a UF2 bootloader. You should use it: https://learn.adafruit.com/welcome-to-c ... er-2977081

Can you post what you see in the REPL when the code runs? That should give a better idea of what's happening.

If you aren't familiar with using the REPL (or even just the serial connection), see
https://learn.adafruit.com/welcome-to-c ... al-console
https://learn.adafruit.com/welcome-to-c ... al-console
https://learn.adafruit.com/welcome-to-c ... n/the-repl

Dave

User avatar
pierrot10
 
Posts: 349
Joined: Tue Nov 17, 2015 4:34 pm

Re: [Beginer] How import board and digitalio

Post by pierrot10 »

Hello Thanks for your reply,
but I wonder if I did well my previous steps.

If I look at this stage https://learn.adafruit.com/welcome-to-c ... re-2978787
I downloaded the bin file here https://circuitpython.org/board/feather_m0_adalogger/ from the first section, next to the picture. But, if you looked at the bottom of the same link page. there is Update UF2 Bootloader , but no way to download a bin file.

Then if you continue reading the following page https://learn.adafruit.com/welcome-to-c ... er-3000302 I did the following

1. I list my usb port

Code: Select all

ls /dev/cu.*
2. I connect my Adalogger MO board and I pressed twice the reset bottom to be in bootload mode and then I listed again the USB ports
3. I downloaded the adafruit-circuitpython-feather_m0_adalogger-en_US-8.0.4.bin file (I supposed that s wrong)
4. I lunched the bossac command

Code: Select all

bossac -p /dev/cu.usbmodem141101 -e -w -v -R --offset=0x2000 adafruit-circuitpython-feather_m0_adalogger-en_US-8.0.4.bin
Since, when I plug my adafruit adalogger board to my MAC, I can see the CIRCUITPY is mounted

I also download the uf2 file and I drag to my CIRCUITPY drive, but an error message stats that there is no enougn space on my board!!!!

Did my above steps are correct? Did I well downloaded the bootloader and what I missed to do?

Thanks

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: [Beginer] How import board and digitalio

Post by dastels »

UF2 files contain firmware, just like BIN files. The UF2 bootloader is simpler to use since you just copy the UF2 file to the *BOOT drive that gets mounted when you double-press reset. BIN files require another program to load them (e.g. bossac).

UF2 files do not go onto the CIRCUITPY drive.

Anyway, it seems you have CircuitPython running on your board.

Dave

User avatar
pierrot10
 
Posts: 349
Joined: Tue Nov 17, 2015 4:34 pm

Re: [Beginer] How import board and digitalio

Post by pierrot10 »

Yep, I open my project with MU and it's work. I should not choose PyCharm or Atom for my first script with CircuitPython

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: [Beginer] How import board and digitalio

Post by dastels »

You can use any editor, but you need to make sure the code 1s running on the board, not your PC.

Dave

User avatar
pierrot10
 
Posts: 349
Joined: Tue Nov 17, 2015 4:34 pm

Re: [Beginer] How import board and digitalio

Post by pierrot10 »

All right, thanks

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

Return to “Adafruit CircuitPython”