LogoLogo
Terminal
  • Attic Lab
  • Getting Started
  • Crest Gold
  • Crest Silver
  • Videos on Computation
  • PI PICO (CIRCUITPYTHON)
    • Getting Started
    • Pin Out Diagram
    • Breadboards
    • 1. Led Blink
    • 2. RGB
    • 3. OLED
    • 4. Sensors
    • 5. Wifi
    • 6. Servos
  • Arduino
    • Getting Started
    • Pin Out Diagrams
      • Mega2560 R3
    • Programming
      • Arduino C - Cheat Sheet
    • Buttons
      • Momentary Switches
    • Display
      • LEDs
      • 7 Segment Displays
      • LCD Displays (GPIO)
      • LCD Displays (SPI)
      • OLEDs
    • Communication
      • Antenna Theory
      • Lora
      • Wifi
        • Boards
    • Project Ideas
    • Motion
      • DC Motors
      • Servo Motors
      • Stepper Motors
  • Microsoft Office
    • Word
    • Powerpoint
    • Excel
  • The Terminal
    • Basics
    • Cheat Sheet
    • Games
      • Level 1 - Bashcrawl
      • Level 2 - Bandit
  • TinkerCad
    • Gallery
    • Getting Started
    • Basic Operations
    • Basic Skills
    • Projects
      • Locking Container
  • Python
    • Hello World
    • Turtle Graphics
      • Strings in Turtle Graphics
      • Cheat Sheet
    • Variables
    • Loops
    • If Statements
    • Functions
    • Games
      • Pong
  • Raspberry Pi
    • Setup
      • Changing The Hostname
      • Headless Setup
      • Kiosk Mode
    • Remote Connections
    • Displays
      • Memory
        • External HD
      • HyperPixel 4.0
  • Ultimaker 3D Printing
    • The Thingiverse
    • Preparing the File
    • Printing
    • Calibration Prints
    • Print Set
  • Fusion 360
    • Getting Started
    • Design Tutorials
      • Tweezers
      • Mars Rover Wheel
    • Surface Modeling
  • Electronics
    • References
    • Antenna Theory
    • LoRa
  • PCB Milling
    • FlatCam
    • Candle
    • PCB Milling
  • Projects
  • Projects
    • Star Map Necklace
    • Ideas Respository
  • Latex
    • What is LaTeX?
    • Getting Started
    • Structure
    • Page Size & Margins
    • Styling
    • Images
    • Lists
    • Tables
    • Mathematics
      • Superscript and Subscripts
      • List of Symbols
      • Fractions and Binomials
      • Integrals, Sums & Limits
    • Colors
  • Web Development
    • The Internet
    • Intro to HTML
    • Basic Elements
    • Basic Styling
Powered by GitBook
On this page

Was this helpful?

  1. PI PICO (CIRCUITPYTHON)

1. Led Blink

Out first project will blink both the onboard LED and an LED connected external LED

This is our code:

#LED Blink
import board
import digitalio
import time

#Tell Circuitpython that we want to control the output of the onboard LED Pin
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT

print('hello world')

while True:
    print('off')
    led.value = False
    time.sleep(1)
    
    led.value = True
    time.sleep(1)
    print('on')
    
    
#TASK 1: Change the 'Hello World' message to "LED Blink"

#TASK 2: Change the speed of the blinking.
# How fast can you go before you can't see it blinking
```

To Get Started, open the Circuit Python folder from the Desktop

Navigate to the 1_LED folder and double click 1_blinkOnboard.py to open it in Thonny

Make sure that your PICO is plugged into the PI

In Thonny, make sure that the Pi Pico (Circuit Python) is selected in the bottom right hand corner

Now click RUN to start the program

External LED

Next, we will connect an external LED to GP1 and the ground pin next to it.

LEDs have polarity. This means they will not work if connected the wrong way around. The longer leg is positive and goes into GP1, and the shorter leg is negative (Ground)

Make sure you unplug your PICO from the PI before making changes to the circuit or you could brink your PICO

Open the file 2_BlinkExternal.py in Thonny. Make sure that you click Stop to shut down the previous program.

import board
import digitalio
import time

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

print('hello world')

while True:
    print('on')
    led.value = False
    time.sleep(1)
    
    print('off')
    led.value = True
    time.sleep(1)

#TASK: Modify your circuit and code to blink a second LED
# so that when one is off, the other is on
```

PreviousBreadboardsNext2. RGB

Last updated 6 months ago

Was this helpful?