Raspberry Pi Pico: Difference between revisions

From Sketching with Hardware at LMU Wiki
Jump to navigation Jump to search
Created page with "200px Here are some links for the Raspberry Pi Pico board: The starting page: * https://www.raspberrypi.org/documentation/pico/getting-started/ Board..."
 
No edit summary
 
(11 intermediate revisions by one other user not shown)
Line 1: Line 1:
[[File:Pipico01.PNG|200px]]
[[File:Pipico01.PNG|300px]]
 
= Links =


Here are some links for the Raspberry Pi Pico board:
Here are some links for the Raspberry Pi Pico board:
Line 13: Line 15:
* https://www.raspberrypi.org/documentation/pico/getting-started/#getting-started-with-micropython
* https://www.raspberrypi.org/documentation/pico/getting-started/#getting-started-with-micropython
* https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-python-sdk.pdf
* https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-python-sdk.pdf
= Related Video =
  <youtube>fnzKTF7lrZ8</youtube>
<!--
[[File:Pipico02.PNG|800px|link=https://www.sketching-with-hardware.org/video/pipico01/pipico01_player.html]]
-->
= Code Example =
== Control the internal LED with MicroPython ==
The internal LED is connected to Pin 25.
<syntaxhighlight lang="python" line='line'>
from machine import Pin
# the internal LED is connected to Pin 25, we use it as output
myLED = Pin(25, Pin.OUT)
# this switches the LED on
myLED.on()
# this switches the LED off
myLED.off()
</syntaxhighlight>
=== blinking the LED ===
<syntaxhighlight lang="python" line='line'>
from machine import Pin
from time import sleep
# assume our LED is connected to Pin 26, we use it as output
myLED = Pin(25, Pin.OUT)
while True:
      # this switches the LED on for 1 second
      myLED.on()
      sleep(1)
      # this switches the LED off for 500 ms
      myLED.off()
      sleep(0.5)
</syntaxhighlight>
[[Category:Raspberry Pi]]

Latest revision as of 15:06, 12 June 2024

Links[edit]

Here are some links for the Raspberry Pi Pico board:

The starting page:

Board pinout

MicroPython on the Raspberry Pi Pico

Related Video[edit]

  

Code Example[edit]

Control the internal LED with MicroPython[edit]

The internal LED is connected to Pin 25.

from machine import Pin
# the internal LED is connected to Pin 25, we use it as output 
myLED = Pin(25, Pin.OUT)
# this switches the LED on
myLED.on()
# this switches the LED off
myLED.off()

blinking the LED[edit]

from machine import Pin
from time import sleep 

# assume our LED is connected to Pin 26, we use it as output 
myLED = Pin(25, Pin.OUT)

while True:
      # this switches the LED on for 1 second
      myLED.on()
      sleep(1)
      # this switches the LED off for 500 ms
      myLED.off()
      sleep(0.5)