203 views|0 replies

13

Posts

3

Resources
The OP
 

【Follow me Season 2 Episode 1】Introductory Task - Light up the onboard LED [Copy link]

 

There are two types of CPX (LED and neopixel) with a total of 12 lamp beads.

The On button on the right side of the USB port is the power indicator light and is generally not used for programming.

So in this task, the programming object is the D13 LED lamp bead on the left side of the USB port.

import board
import digitalio
import time

led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT

while True:
    print("Hello, EEworld!")
    led.value = not led.value
    time.sleep(0.5)

Main logic

After initializing the LED light, in the big loop, print a piece of content and change the value of the LED, that is, the light is on and off, and finally sleep to enter the next loop

Tail

Careful friends will find out why the D13 pin does not appear in the code?

Let me run it in interactive environment

>>> import board;help(board)

You will see some definitions and aliases that CircuitPython has defined for the board.

That's why D13 didn't appear.

Not only LEDs, but some other onboard sensors have also been defined by CircuitPython. You can check more by yourself.

This is one of the reasons why I like CircuitPython.

This post is from DigiKey Technology Zone
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list