Shop

I sell on Tindie
Showing posts with label Raspberry Pi Pico W. Show all posts
Showing posts with label Raspberry Pi Pico W. Show all posts

Friday, July 1, 2022

Raspberry Pi Pico W - 2 Quick Projects to Get You Started

July 1st 2022

💖We love new arrivals! Here are two quick projects to get you started with the Raspberry Pi Pico W.

Tips
Make sure you Pi Pico W is set to the correct USB Serial Device (COM)
Select your board.


Optional: Install MicroPython firmware from Thonny IDE link. 














Blink an LED
Code:

#Blink LED on GPIO 0 - Connect an LED on Pin 1(GPIO 0) and Pin 3 (GND)

from machine import Pin, Timer

inbuiltLed = 0
led = Pin(0, Pin.OUT)
timer = Timer()
def ledblink(timer):
    led.toggle()
timer.init(freq=2.5, mode=Timer.PERIODIC, callback=ledblink)
  1. Web Server Ping

Code:
# Web Server Ping

import network
import socket
 
ssid = 'Your Router'
password = 'Your Password'
 
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
 
 
addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
 
s = socket.socket()
s.bind(addr)
s.listen(1)
 
print('listening on', addr)
status = wlan.ifconfig()
print(status[0])
 
#Listen for Connections
while True:
    try:
        cl, addr = s.accept()
        print('client connected from', addr)
        request = cl.recv(1024)
        print(request)
        
        response = "Hello"
        
        cl.send('HTTP/1.0 200 OK/r/nContent-type: text/html\r\n\r\n')
        cl.send(response)
        cl.close()
    
    except OSError as e:
        cl.close()
        print('connection closed')

Raspberry Pi Pico W - 2 Quick Projects to Get You Started

July 1st 2022 💖We love new arrivals! Here are two quick projects to get you started with the Raspberry Pi Pico W. Tips :  Get the latest fi...

Popular Post