<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[ByteBerzerker: Pi Pico Projects]]></title><description><![CDATA[Projects specific to the Pi Pico Microcontroller]]></description><link>https://www.byteberzerker.com/s/pi-pico-projects</link><image><url>https://substackcdn.com/image/fetch/$s_!SaKV!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5be7fb19-3857-4c95-818e-5eb12cdc00b3_600x600.png</url><title>ByteBerzerker: Pi Pico Projects</title><link>https://www.byteberzerker.com/s/pi-pico-projects</link></image><generator>Substack</generator><lastBuildDate>Sat, 11 Apr 2026 07:50:27 GMT</lastBuildDate><atom:link href="https://www.byteberzerker.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[ByteBerzerker]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[byteberzerker@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[byteberzerker@substack.com]]></itunes:email><itunes:name><![CDATA[ByteBerzerker]]></itunes:name></itunes:owner><itunes:author><![CDATA[ByteBerzerker]]></itunes:author><googleplay:owner><![CDATA[byteberzerker@substack.com]]></googleplay:owner><googleplay:email><![CDATA[byteberzerker@substack.com]]></googleplay:email><googleplay:author><![CDATA[ByteBerzerker]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Fourth Project: Adding a Stepper Motor]]></title><description><![CDATA[Hi Folks,]]></description><link>https://www.byteberzerker.com/p/fourth-project-adding-a-stepper-motor</link><guid isPermaLink="false">https://www.byteberzerker.com/p/fourth-project-adding-a-stepper-motor</guid><dc:creator><![CDATA[ByteBerzerker]]></dc:creator><pubDate>Tue, 30 Jul 2024 01:10:59 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!XNrR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec75f20d-df0d-42e3-a05d-46678133467f_2025x2061.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hi Folks,</p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.byteberzerker.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption"></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>We are back in action with the Pi Pico project. Now let&#8217;s add a stepper motor to our project and ask ChatGPT to generate some code that will work with our current project (Project Three).</p><p></p><p>My ChatGPT query:</p><p></p><p>Now add a dc motor, include the code, the electronic components needed, and how to connect the motor to the current code.</p><p></p><p>ChatGPT Response:</p><p></p><p>Integrating a 5V DC stepper motor with five wires into your Raspberry Pi Pico setup involves using a stepper motor driver. These types of motors are typically unipolar stepper motors. Here&#8217;s a detailed guide on the electronic components needed, how to connect the stepper motor, and the necessary code changes.</p><h3>Components Needed</h3><ol><li><p><strong>5V DC Stepper Motor</strong>: With five wires, typically a unipolar stepper motor.</p></li><li><p><strong>ULN2003 Stepper Motor Driver</strong>: Suitable for driving unipolar stepper motors.</p></li><li><p><strong>Power Supply</strong>: A 5V power supply for the stepper motor.</p></li><li><p><strong>Jumper Wires</strong>: For connections.</p></li><li><p><strong>Breadboard</strong>: For prototyping connections.</p></li></ol><h3>Circuit Connections</h3><ol><li><p><strong>Connecting the Stepper Motor to ULN2003 Driver</strong>:</p><ul><li><p>The ULN2003 driver is designed for easy connection with a unipolar stepper motor.</p></li><li><p>Connect the motor wires to the driver board in the order specified in the motor&#8217;s datasheet or according to the colors typically matched on the driver board.</p></li></ul></li><li><p><strong>Connections from ULN2003 Driver to Raspberry Pi Pico</strong>:</p><ul><li><p><strong>Motor Driver IN Pins</strong>: Connect these to GPIO pins on the Pico.</p></li><li><p><strong>VCC (5V) and GND</strong>: Connect to the 5V and ground on the Pico or an external 5V supply with a common ground.</p></li></ul></li><li><p><strong>Circuit Schematic</strong>:</p><ul><li><p>Connect the stepper motor wires to the driver.</p></li><li><p>Connect the driver input pins (IN1, IN2, IN3, IN4) to Pico GPIO pins (e.g., GPIO 6, GPIO 7, GPIO 8, GPIO 9).</p></li><li><p>Connect the <code>VCC</code> of the ULN2003 to the Pico's 5V pin.</p></li><li><p>Connect <code>GND</code> of the ULN2003 to the Pico's ground.</p></li></ul></li></ol><h3>Updated Code</h3><p>Here&#8217;s the updated code with stepper motor control added:</p><p></p><pre><code>import machine
import utime
from i2c_lcd import I2cLcd

# Define the I2C address of the LCD (use the address detected by the I2C scanner)
I2C_ADDR = 0x27  # Replace with your LCD's I2C address
I2C_NUM_ROWS = 2
I2C_NUM_COLS = 16

# Initialize I2C on bus 1 with SDA on Pin 2 and SCL on Pin 3
i2c = machine.I2C(1, scl=machine.Pin(3), sda=machine.Pin(2), freq=100000)

# Initialize the LCD
lcd = I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS)

# Define GP0 as an output pin for the LED
led_pin = machine.Pin(0, machine.Pin.OUT)

# Define GP1 as an input pin with a pull-up resistor for the button
button_pin = machine.Pin(1, machine.Pin.IN, machine.Pin.PULL_UP)

# Stepper motor control pins
stepper_pins = [
    machine.Pin(6, machine.Pin.OUT),  # IN1
    machine.Pin(7, machine.Pin.OUT),  # IN2
    machine.Pin(8, machine.Pin.OUT),  # IN3
    machine.Pin(9, machine.Pin.OUT)   # IN4
]

# Stepper motor steps for one revolution
step_sequence = [
    [1, 0, 0, 0],
    [1, 1, 0, 0],
    [0, 1, 0, 0],
    [0, 1, 1, 0],
    [0, 0, 1, 0],
    [0, 0, 1, 1],
    [0, 0, 0, 1],
    [1, 0, 0, 1]
]

# Variables to track button states
button_state = button_pin.value()
prev_button_state = button_state

# Function to display LED and motor state on the LCD
def update_lcd(led_state, motor_state):
    lcd.clear()  # Clear the LCD before writing new text
    utime.sleep_ms(100)  # Give a small delay to ensure clearing completes
    
    if led_state:
        lcd.move_to(0, 0)
        lcd.putstr("LED: ON")
    else:
        lcd.move_to(0, 0)
        lcd.putstr("LED: OFF")
        
    if motor_state:
        lcd.move_to(0, 1)
        lcd.putstr("Motor: RUNNING")
    else:
        lcd.move_to(0, 1)
        lcd.putstr("Motor: STOPPED")

# Function to control stepper motor steps
def step_motor(steps, direction=1, delay=10):
    for _ in range(steps):
        for step in step_sequence[::direction]:
            for pin, value in zip(stepper_pins, step):
                pin.value(value)
            utime.sleep_ms(delay)

# Display initial states
update_lcd(led_pin.value(), False)

# Main loop
while True:
    # Read the state of the button
    button_state = button_pin.value()
    
    # Check if the button state has changed (active low)
    if button_state != prev_button_state:
        # Debounce delay
        utime.sleep_ms(20)
        # Confirm the state change
        if button_state == button_pin.value():
            # If the button is pressed
            if button_state == 0:
                # Toggle the LED
                led_pin.toggle()
                # Update the LCD with the new LED state
                motor_running = led_pin.value() == 1
                update_lcd(led_pin.value(), motor_running)
                
                # If LED is ON, run the stepper motor
                if motor_running:
                    step_motor(512, direction=1, delay=5)  # Run motor for 512 steps (one revolution)
                else:
                    for pin in stepper_pins:
                        pin.value(0)  # Stop the motor by setting all pins to low
    
    # Update the previous button state
    prev_button_state = button_state
    
    # Short delay to reduce CPU usage
    utime.sleep_ms(50)
</code></pre><h3>Notes</h3><ul><li><p><strong>Power Supply</strong>: Ensure the motor driver and motor are powered correctly. If using the Pico's 5V output, ensure it can supply sufficient current. A separate 5V power supply might be needed for the motor, with common ground.</p></li><li><p><strong>Stepper Motor Steps</strong>: Adjust the <code>steps</code> parameter in the <code>step_motor</code> function to match the number of steps per revolution of your stepper motor.</p></li><li><p><strong>Delay Adjustment</strong>: The <code>delay</code> parameter in <code>step_motor</code> can be adjusted to control the speed of the motor. Reducing the delay will increase the motor speed.</p></li></ul><p>This setup provides a way to control a 5V unipolar stepper motor, adding stepper motor functionality to the existing LED and LCD system.</p><p></p><p>Alright, let&#8217;s give this a shot and see what happens.</p><p></p><p>Videos:</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;90418fea-c1f9-48de-8783-1ae4d81b867e&quot;,&quot;duration&quot;:null}"></div><p></p><p>It works!</p><p>Another successful ChatGPT generated code for our project.</p><p></p><p>Fritzing Schematic:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XNrR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec75f20d-df0d-42e3-a05d-46678133467f_2025x2061.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XNrR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec75f20d-df0d-42e3-a05d-46678133467f_2025x2061.jpeg 424w, https://substackcdn.com/image/fetch/$s_!XNrR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec75f20d-df0d-42e3-a05d-46678133467f_2025x2061.jpeg 848w, https://substackcdn.com/image/fetch/$s_!XNrR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec75f20d-df0d-42e3-a05d-46678133467f_2025x2061.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!XNrR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec75f20d-df0d-42e3-a05d-46678133467f_2025x2061.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XNrR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec75f20d-df0d-42e3-a05d-46678133467f_2025x2061.jpeg" width="1456" height="1482" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ec75f20d-df0d-42e3-a05d-46678133467f_2025x2061.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1482,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1043817,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!XNrR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec75f20d-df0d-42e3-a05d-46678133467f_2025x2061.jpeg 424w, https://substackcdn.com/image/fetch/$s_!XNrR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec75f20d-df0d-42e3-a05d-46678133467f_2025x2061.jpeg 848w, https://substackcdn.com/image/fetch/$s_!XNrR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec75f20d-df0d-42e3-a05d-46678133467f_2025x2061.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!XNrR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec75f20d-df0d-42e3-a05d-46678133467f_2025x2061.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p></p><p></p><p></p><p>Links:</p><ol><li><p><a href="https://github.com/TheDumbEngineer/TheDumbEngineer/blob/main/ProjectFour.py">GitHub Code</a></p></li><li><p><a href="https://github.com/TheDumbEngineer/TheDumbEngineer/blob/main/FourthProject.fzz">Fritzing File</a></p></li></ol><p></p><p></p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.byteberzerker.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption"></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Third Project: Adding an I2C 1602 LCD Screen]]></title><description><![CDATA[Alright folks!]]></description><link>https://www.byteberzerker.com/p/third-project-adding-an-i2c-1602</link><guid isPermaLink="false">https://www.byteberzerker.com/p/third-project-adding-an-i2c-1602</guid><dc:creator><![CDATA[ByteBerzerker]]></dc:creator><pubDate>Sat, 08 Jun 2024 00:29:47 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Ul_e!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7eabe0dc-955c-4998-bdec-0043ca52f4d5_1767x963.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Alright folks! here we are again. Adding a screen to the project! I had to do a bit of research on i2c and the 1602 module which led me to the library needed. Link to the library i2c_lcd.py is at the bottom and is included in my GitHub repo. The library needs to be saved to the pi pico, this can be done in Thonny. Just upload the i2c_lcd.py code into Thonny and click save as &gt; save to RP2040 as i2c_lcd.py. This will ensure our code will be able to import code needed from the Library. Let&#8217;s get started!</p><p><em>This is what I told ChatGPT to do:</em> </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.byteberzerker.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption"></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Now add a i2c lcd 1602 screen that displays when the led is on or off. Use pin 2 for SDA and pin 3 for SCL. Make sure to use the libraries i2c_lcd.py in the program.</p><p><em>ChatGPTs Answer:</em></p><p>To add an I2C LCD 1602 screen to the existing code and display whether the LED is on or off, you need to incorporate the necessary libraries and initialize the LCD screen. Below is the modified code including the LCD initialization and displaying the LED state:</p><p></p><pre><code>import machine
import utime
from i2c_lcd import I2cLcd  # Ensure i2c_lcd.py is on the Pico

# Define the I2C address of the LCD (use the address detected by the I2C scanner)
I2C_ADDR = 0x27  # Replace with your LCD's I2C address
I2C_NUM_ROWS = 2
I2C_NUM_COLS = 16

# Initialize I2C on bus 1 with SDA on Pin 2 and SCL on Pin 3
i2c = machine.I2C(1, scl=machine.Pin(3), sda=machine.Pin(2), freq=100000)

# Initialize the LCD
lcd = I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS)

# Define GP0 as an output pin for the LED
led_pin = machine.Pin(0, machine.Pin.OUT)

# Define GP1 as an input pin with a pull-up resistor for the button
button_pin = machine.Pin(1, machine.Pin.IN, machine.Pin.PULL_UP)

# Variables to track button states
button_state = button_pin.value()
prev_button_state = button_state

# Function to display LED state on the LCD
def update_lcd(led_state):
    lcd.clear()  # Clear the LCD before writing new text
    utime.sleep_ms(100)  # Give a small delay to ensure clearing completes
    
    if led_state:
        lcd.move_to(0, 0)
        lcd.putstr("LED: ON")
    else:
        lcd.move_to(0, 0)
        lcd.putstr("LED: OFF")

# Display initial state
update_lcd(led_pin.value())

# Main loop
while True:
    # Read the state of the button
    button_state = button_pin.value()
    
    # Check if the button state has changed (active low)
    if button_state != prev_button_state:
        # Debounce delay
        utime.sleep_ms(20)
        # Confirm the state change
        if button_state == button_pin.value():
            # If the button is pressed
            if button_state == 0:
                # Toggle the LED
                led_pin.toggle()
                # Update the LCD with the new LED state
                update_lcd(led_pin.value())
    
    # Update the previous button state
    prev_button_state = button_state
    
    # Short delay to reduce CPU usage
    utime.sleep_ms(50)

</code></pre><h3>Explanation</h3><ol><li><p><strong>I2C Initialization:</strong></p><ul><li><p><code>i2c = machine.I2C(1, scl=machine.Pin(3), sda=machine.Pin(2), freq=100000)</code>: Initializes I2C on bus 1 with SDA on Pin 2 and SCL on Pin 3, operating at a frequency of 100 kHz.</p></li></ul></li><li><p><strong>LCD Initialization:</strong></p><ul><li><p><code>lcd = I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS)</code>: Initializes the LCD with the specified I2C address and dimensions (2 rows, 16 columns).</p></li></ul></li><li><p><strong>LED and Button Setup:</strong></p><ul><li><p>The LED is connected to GPIO0, configured as an output.</p></li><li><p>The button is connected to GPIO1, configured as an input with an internal pull-up resistor.</p></li></ul></li><li><p><strong>Display Update Function:</strong></p><ul><li><p><code>update_lcd(led_state)</code>: Clears the LCD, waits for a short delay to ensure clearing, and then writes the current state of the LED ("LED: ON" or "LED: OFF").</p></li></ul></li><li><p><strong>Initial Display State:</strong></p><ul><li><p><code>update_lcd(led_pin.value())</code>: Displays the initial state of the LED on the LCD when the program starts.</p></li></ul></li><li><p><strong>Main Loop:</strong></p><ul><li><p>The main loop continuously reads the button state, toggles the LED when the button is pressed, and updates the LCD with the new LED state.</p></li><li><p>The button state is debounced with a delay to prevent false triggers.</p></li></ul></li></ol><p></p><p>We have success!</p><p></p><p><em>Videos:</em></p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;350ff731-8141-4219-af40-ca2759d770c6&quot;,&quot;duration&quot;:null}"></div><p>Because it was hard to see the lcd in the first video, I created a separate video for an up-close of the lcd during operation.</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;e77afb3e-43b8-4d75-a6db-3080aa01a741&quot;,&quot;duration&quot;:null}"></div><p></p><p><em>Fritzing Design:</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Ul_e!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7eabe0dc-955c-4998-bdec-0043ca52f4d5_1767x963.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Ul_e!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7eabe0dc-955c-4998-bdec-0043ca52f4d5_1767x963.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Ul_e!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7eabe0dc-955c-4998-bdec-0043ca52f4d5_1767x963.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Ul_e!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7eabe0dc-955c-4998-bdec-0043ca52f4d5_1767x963.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Ul_e!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7eabe0dc-955c-4998-bdec-0043ca52f4d5_1767x963.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Ul_e!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7eabe0dc-955c-4998-bdec-0043ca52f4d5_1767x963.jpeg" width="1456" height="794" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7eabe0dc-955c-4998-bdec-0043ca52f4d5_1767x963.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:794,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:522395,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Ul_e!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7eabe0dc-955c-4998-bdec-0043ca52f4d5_1767x963.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Ul_e!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7eabe0dc-955c-4998-bdec-0043ca52f4d5_1767x963.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Ul_e!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7eabe0dc-955c-4998-bdec-0043ca52f4d5_1767x963.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Ul_e!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7eabe0dc-955c-4998-bdec-0043ca52f4d5_1767x963.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p></p><p>That&#8217;s it, now for the links.</p><p><em>GitHub Links:</em></p><p>GitHub Pi Pico Code: https://github.com/TheDumbEngineer/TheDumbEngineer/blob/main/ProjectThree.py</p><p>GitHub i2c_lcd.py Library: https://github.com/TheDumbEngineer/TheDumbEngineer/blob/main/i2c_lcd.py</p><p>GitHub Fritzing: https://github.com/TheDumbEngineer/TheDumbEngineer/blob/main/ThirdProject.fzz</p><p></p><p><em>Components Link: </em>(since I provided links in the previous posts for the components needed leading up to this, I will just add a link to the 1602 I2C LCD screen)</p><p>1602 I2C LCD Screen: https://amzn.to/3XgVQbg</p><p></p>]]></content:encoded></item><item><title><![CDATA[Second Project: Adding a Button!]]></title><description><![CDATA[Building on what we already have, I told ChatGPT this:]]></description><link>https://www.byteberzerker.com/p/second-project-adding-a-button</link><guid isPermaLink="false">https://www.byteberzerker.com/p/second-project-adding-a-button</guid><dc:creator><![CDATA[ByteBerzerker]]></dc:creator><pubDate>Thu, 16 May 2024 22:27:21 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!nL8o!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e4ced3-aeb3-48d8-a709-ae4394c5b76a_750x521.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Building on what we already have, I told ChatGPT this: </p><p>Now build on this project by adding something. Include code, code explanation, electronic components, and how to connect it all.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.byteberzerker.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption"></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p><p>This is the answer ChatGPT gave me:</p><p>Let's enhance the project by adding a push button that controls the blinking of the LED. When the button is pressed, the LED will toggle its state, and when the button is released, it will stop toggling. For this enhancement, you'll need the following additional electronic component:</p><ol start="5"><li><p>Push button switch</p></li></ol><p>Here's how to connect the push button switch to the existing setup:</p><ol><li><p><strong>Push Button Switch</strong>:</p><ul><li><p>Place the push button switch on the breadboard.</p></li><li><p>Connect one leg of the push button to a GPIO pin on the Raspberry Pi Pico. Let's use GPIO pin 1 (GP1).</p></li><li><p>Connect the other leg of the push button to a GND (ground) pin on the Raspberry Pi Pico. You can choose any ground pin.</p></li><li><p>Optionally, you can add a pull-up resistor between the GPIO pin and the button's leg connected to it to ensure stable readings. A resistor of 10k ohms is commonly used.</p></li></ul></li></ol><p>Here's the modified MicroPython code to incorporate the push button functionality:</p><p></p><pre><code># MicroPython code to toggle an LED connected to GPIO pin 0 (GP0) on Raspberry Pi Pico
# using a push button connected to GPIO pin 1 (GP1)

import machine
import utime

led_pin = machine.Pin(0, machine.Pin.OUT)  # Define GP0 as an output pin
button_pin = machine.Pin(1, machine.Pin.IN, machine.Pin.PULL_UP)  # Define GP1 as an input pin with pull-up resistor

button_state = 0  # Variable to track button state
prev_button_state = 0  # Variable to track previous button state

while True:
    button_state = button_pin.value()  # Read the state of the button
    
    if button_state != prev_button_state:  # If button state changes
        if button_state == 0:  # If button is pressed
            led_pin.toggle()  # Toggle the state of the LED
            
    prev_button_state = button_state  # Update previous button state
    utime.sleep_ms(20)  # Add a small delay to debounce the button
</code></pre><p>Explanation of the code:</p><ul><li><p>We add a new pin definition <code>button_pin</code> for the push button connected to GPIO pin 1 (GP1). We specify it as an input pin with a pull-up resistor.</p></li><li><p>We introduce two variables <code>button_state</code> and <code>prev_button_state</code> to track the current and previous states of the button.</p></li><li><p>In the <code>while</code> loop, we continuously read the state of the button using <code>button_pin.value()</code>.</p></li><li><p>If the button state changes (indicating a press or release), we toggle the LED state only when the button is pressed (<code>button_state == 0</code>).</p></li><li><p>We add a small delay of 20 milliseconds to debounce the button.</p></li></ul><p>Connect the push button switch as described above, upload the modified code to your Raspberry Pi Pico, and you should now be able to control the blinking of the LED using the push button!</p><p></p><p>Ok, so it mentions a pull-up resistor, realizing some of folks reading this might not understand what a pull-up resistor is or does, or how to connect it to the project. I asked ChatGPT a follow up question of:</p><p>What is a pull up resistor and how do I connect it to the project?</p><p>ChatGPTs Answer:</p><p>A pull-up resistor is a resistor connected between a signal line and a positive voltage (typically Vcc or the supply voltage). It ensures that the signal line is pulled to a logical high state (usually the same voltage as the positive supply) when no other active device is driving the line to a low state. This configuration helps prevent floating or undefined states, providing a stable reference voltage when the line is not being actively driven.</p><p>In the context of a push button switch, a pull-up resistor is used to ensure that the input pin reads a logical high state when the button is not pressed. When the button is pressed, it connects the input pin to ground, overriding the pull-up resistor and causing the input pin to read a logical low state.</p><p>Here's how to connect a pull-up resistor to your project:</p><p></p><pre><code>   1. Choose the resistor value: A commonly used value for pull-up resistors is around 10k ohms (10,000 ohms). However, depending on your specific requirements and components, you can adjust this value if needed.

   2. Connect the resistor: Connect one end of the resistor to the GPIO pin to which the push button is connected.Connect the other end of the resistor to the positive voltage supply (Vcc), which is typically the 3.3V pin on the Raspberry Pi Pico.</code></pre><p>I also wanted to mention that there is such thing as a pull-down resistor as well. Both have there place, but for this project we are going to use a pull-up resistor.</p><p>Image of a circuit the pull-up on the left and pull-down on the right:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nL8o!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e4ced3-aeb3-48d8-a709-ae4394c5b76a_750x521.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nL8o!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e4ced3-aeb3-48d8-a709-ae4394c5b76a_750x521.png 424w, https://substackcdn.com/image/fetch/$s_!nL8o!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e4ced3-aeb3-48d8-a709-ae4394c5b76a_750x521.png 848w, https://substackcdn.com/image/fetch/$s_!nL8o!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e4ced3-aeb3-48d8-a709-ae4394c5b76a_750x521.png 1272w, https://substackcdn.com/image/fetch/$s_!nL8o!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e4ced3-aeb3-48d8-a709-ae4394c5b76a_750x521.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nL8o!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e4ced3-aeb3-48d8-a709-ae4394c5b76a_750x521.png" width="750" height="521" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/52e4ced3-aeb3-48d8-a709-ae4394c5b76a_750x521.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:521,&quot;width&quot;:750,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;What is Pull Up and Pull Down Resistor and Where to Use them?&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="What is Pull Up and Pull Down Resistor and Where to Use them?" title="What is Pull Up and Pull Down Resistor and Where to Use them?" srcset="https://substackcdn.com/image/fetch/$s_!nL8o!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e4ced3-aeb3-48d8-a709-ae4394c5b76a_750x521.png 424w, https://substackcdn.com/image/fetch/$s_!nL8o!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e4ced3-aeb3-48d8-a709-ae4394c5b76a_750x521.png 848w, https://substackcdn.com/image/fetch/$s_!nL8o!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e4ced3-aeb3-48d8-a709-ae4394c5b76a_750x521.png 1272w, https://substackcdn.com/image/fetch/$s_!nL8o!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e4ced3-aeb3-48d8-a709-ae4394c5b76a_750x521.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Fritzing:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!aJWr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81101903-fe64-4b80-b775-f03b38c27440_498x519.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!aJWr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81101903-fe64-4b80-b775-f03b38c27440_498x519.png 424w, https://substackcdn.com/image/fetch/$s_!aJWr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81101903-fe64-4b80-b775-f03b38c27440_498x519.png 848w, https://substackcdn.com/image/fetch/$s_!aJWr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81101903-fe64-4b80-b775-f03b38c27440_498x519.png 1272w, https://substackcdn.com/image/fetch/$s_!aJWr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81101903-fe64-4b80-b775-f03b38c27440_498x519.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!aJWr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81101903-fe64-4b80-b775-f03b38c27440_498x519.png" width="498" height="519" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/81101903-fe64-4b80-b775-f03b38c27440_498x519.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:519,&quot;width&quot;:498,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:213285,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!aJWr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81101903-fe64-4b80-b775-f03b38c27440_498x519.png 424w, https://substackcdn.com/image/fetch/$s_!aJWr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81101903-fe64-4b80-b775-f03b38c27440_498x519.png 848w, https://substackcdn.com/image/fetch/$s_!aJWr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81101903-fe64-4b80-b775-f03b38c27440_498x519.png 1272w, https://substackcdn.com/image/fetch/$s_!aJWr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81101903-fe64-4b80-b775-f03b38c27440_498x519.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p></p><p>Now, let&#8217;s get to work!</p><p></p><p></p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;87a0b151-6175-4e3b-bae3-b6db5bcb048f&quot;,&quot;duration&quot;:null}"></div><p></p><p>And just like that, ChatGPT code works again folks!</p><p></p><p>Links!</p><p>Code:</p><p>GitHub: <a href="https://github.com/TheDumbEngineer/TheDumbEngineer">https://github.com/TheDumbEngineer/TheDumbEngineer</a></p><p></p><p>Electronic Components Needed:</p><p>Pi Pico: <a href="https://amzn.to/3yigkWC">https://amzn.to/3yigkWC</a></p><p>LED Assortment: <a href="https://amzn.to/3UNoiyM">https://amzn.to/3UNoiyM</a></p><p>Pi Pico Programming Cable: <a href="https://amzn.to/3UNoAWo">https://amzn.to/3UNoAWo</a></p><p>Jumper Cables: <a href="https://amzn.to/3K3QmZx">https://amzn.to/3K3QmZx</a></p><p>Breadboard: <a href="https://amzn.to/4blRwvs">https://amzn.to/4blRwvs</a></p><p>Resistor: <a href="https://amzn.to/4bJpQjV">https://amzn.to/4bJpQjV</a></p><p>Button: <a href="https://amzn.to/3WF9Hbb">https://amzn.to/3WF9Hbb</a></p><p></p><p></p><p></p><p>Stay tuned!</p><p></p><p></p><p></p><p></p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.byteberzerker.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption"></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[First Pi Pico Project!]]></title><description><![CDATA[Hi Folks!]]></description><link>https://www.byteberzerker.com/p/first-pi-pico-project</link><guid isPermaLink="false">https://www.byteberzerker.com/p/first-pi-pico-project</guid><dc:creator><![CDATA[ByteBerzerker]]></dc:creator><pubDate>Thu, 09 May 2024 01:10:54 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!90Ob!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e26756-944d-4ade-9cfb-2dee890b21b8_652x583.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hi Folks!</p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.byteberzerker.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption"></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>I want to provide you all with a plan on this project and what I am going to be doing. So, the plan is to add different functionality and components to the same project as we progress, so by the end we will have something complex. Maybe we can get a couple of Pi Picos to communicate with each other. The instructions and code will be provided entirely by ChatGPT. The only thing we need to do is flash the MicroPython code and assemble the components.</p><p>Let&#8217;s get back to work!</p><p>Now that we have MicroPython flashed onto the Pi Pico we are ready to jump into the first project. So to start, I asked ChatGPT this: Create a basic Pi Pico project with MicroPython code and tell me the electronic components I need to use. Also, tell me how to connect the electronic components.</p><p>Answer:</p><p>Sure! Let's create a basic project using a Raspberry Pi Pico and MicroPython to blink an LED. For this project, you'll need the following electronic components:</p><p>1. Raspberry Pi Pico</p><p>2. LED (any color)</p><p>3. Resistor (220 ohms is a common value)</p><p>4. Breadboard</p><p>5. Jumper wires</p><p>Here's how to connect the components:</p><p>1. **Raspberry Pi Pico**:</p><p>   - Connect the Raspberry Pi Pico to your computer using a micro USB cable for power and programming.</p><p>2. **LED**:</p><p>   - Place the LED on the breadboard. The longer leg of the LED (the anode) should be connected to a GPIO pin on the Pi Pico. For this example, let's use GPIO pin 0 (GP0).</p><p>   - Connect the shorter leg of the LED (the cathode) to one leg of the resistor.</p><p>3. **Resistor**:</p><p>   - Connect the other leg of the resistor to a GND (ground) pin on the Raspberry Pi Pico. You can choose any ground pin.</p><p>4. **Breadboard and Jumper wires**:</p><p>   - Use jumper wires to make the connections between the Raspberry Pi Pico, LED, and resistor on the breadboard. Make sure the connections are secure.</p><p>Once you have all the components connected, you can proceed with the MicroPython code. Here's a simple code to blink the LED:</p><pre><code># MicroPython code to blink an LED connected to GPIO pin 0 (GP0) on Raspberry Pi Pico

import machine
import utime

led_pin = machine.Pin(0, machine.Pin.OUT)  # Define GP0 as an output pin

while True:
    led_pin.toggle()  # Toggle the state of the LED
    utime.sleep_ms(500)  # Wait for 500 milliseconds (0.5 seconds)
</code></pre><p>Explanation of the code:</p><p>- We import the `machine` module to interact with hardware.</p><p>- We import the `utime` module for adding time delays.</p><p>- We define `led_pin` as an output pin connected to GPIO pin 0 (GP0) using `machine.Pin`.</p><p>- In the `while` loop, we toggle the state of the LED using `led_pin.toggle()` which turns it on and off alternatively.</p><p>- We add a delay of 500 milliseconds (0.5 seconds) between each toggle using `utime.sleep_ms(500)`.</p><p>Upload this code to your Raspberry Pi Pico using your preferred method (e.g., Thonny IDE, rshell, etc.), and you should see the LED blinking!</p><p></p><p>Video: </p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;c6c8611c-26c1-4a4a-b470-7cef68fd92ba&quot;,&quot;duration&quot;:null}"></div><p></p><p></p><p>Fritzing Design:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!90Ob!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e26756-944d-4ade-9cfb-2dee890b21b8_652x583.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!90Ob!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e26756-944d-4ade-9cfb-2dee890b21b8_652x583.png 424w, https://substackcdn.com/image/fetch/$s_!90Ob!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e26756-944d-4ade-9cfb-2dee890b21b8_652x583.png 848w, https://substackcdn.com/image/fetch/$s_!90Ob!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e26756-944d-4ade-9cfb-2dee890b21b8_652x583.png 1272w, https://substackcdn.com/image/fetch/$s_!90Ob!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e26756-944d-4ade-9cfb-2dee890b21b8_652x583.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!90Ob!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e26756-944d-4ade-9cfb-2dee890b21b8_652x583.png" width="652" height="583" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/96e26756-944d-4ade-9cfb-2dee890b21b8_652x583.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:583,&quot;width&quot;:652,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:296585,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!90Ob!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e26756-944d-4ade-9cfb-2dee890b21b8_652x583.png 424w, https://substackcdn.com/image/fetch/$s_!90Ob!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e26756-944d-4ade-9cfb-2dee890b21b8_652x583.png 848w, https://substackcdn.com/image/fetch/$s_!90Ob!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e26756-944d-4ade-9cfb-2dee890b21b8_652x583.png 1272w, https://substackcdn.com/image/fetch/$s_!90Ob!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96e26756-944d-4ade-9cfb-2dee890b21b8_652x583.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>**Note**</p><p>I used pin 23 for the ground in the video, pin 3 will work as ground too.</p><p></p><p>Github link: <a href="https://github.com/TheDumbEngineer/TheDumbEngineer/blob/main/ProjectOne.py">https://github.com/TheDumbEngineer/TheDumbEngineer/blob/main/ProjectOne.py</a></p><p>Components:</p><p>Pi Pico - <a href="https://amzn.to/4btgvgh">https://amzn.to/4btgvgh</a></p><p>Pi Pico Programming Cable - <a href="https://amzn.to/3yeGWYN">https://amzn.to/3yeGWYN</a></p><p>220 Ohm Resistor - <a href="https://amzn.to/3Uw7uMF">https://amzn.to/3Uw7uMF</a></p>]]></content:encoded></item><item><title><![CDATA[Starting with the Pi Pico!]]></title><description><![CDATA[First things first, we need to flash the the MicroPython firmware onto the Pi Pico.]]></description><link>https://www.byteberzerker.com/p/starting-with-the-pi-pico</link><guid isPermaLink="false">https://www.byteberzerker.com/p/starting-with-the-pi-pico</guid><dc:creator><![CDATA[ByteBerzerker]]></dc:creator><pubDate>Mon, 29 Apr 2024 22:06:04 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!SaKV!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5be7fb19-3857-4c95-818e-5eb12cdc00b3_600x600.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hi Folks! As promised I am going to do this experiment entirely with ChatGPT. The first thing I am going to test are the instructions on how to flash the MicroPython firmware onto the Pi Pico board using the Thonny IDE. Let&#8217;s go!</p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.byteberzerker.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption"></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Flashing MicroPython onto a Raspberry Pi Pico using Thonny IDE is a straightforward process. Here's a step-by-step guide:</p><p>1. **Install Thonny**: If you haven't already, download and install Thonny IDE from their official website: https://thonny.org/</p><p>2. **Install MicroPython Firmware**: Before you can flash MicroPython onto your Pi Pico, you need to download the MicroPython firmware. You can get the latest firmware from the official MicroPython website: https://micropython.org/download/rp2-pico/</p><p>3. **Connect Pi Pico**: Plug your Raspberry Pi Pico into your computer using a micro USB cable. Make sure it's properly connected and detected by your computer.</p><p>4. **Open Thonny**: Launch Thonny IDE on your computer.</p><p>5. **Select Interpreter**: In Thonny, go to the "Interpreter" menu and select "MicroPython (Raspberry Pi Pico)".</p><p>6. **Check Connection**: Once you've selected the MicroPython interpreter, Thonny will try to connect to your Pi Pico. If everything is set up correctly, you should see a REPL prompt in the Shell pane at the bottom.</p><p>7. **Flash MicroPython Firmware**: To flash MicroPython firmware onto your Pi Pico, click on "Run" in the menu bar and select "Flash mode" from the dropdown menu. Thonny will prompt you to select the firmware file you downloaded earlier.</p><p>8. **Select Firmware**: Navigate to the directory where you downloaded the MicroPython firmware and select the appropriate file. It typically has a `.uf2` extension.</p><p>9. **Flash Firmware**: After selecting the firmware file, Thonny will initiate the flashing process. Follow any on-screen instructions, and the firmware will be flashed onto your Pi Pico.</p><p>10. **Verify**: Once the flashing process is complete, you should see the Pi Pico restart, and you'll be back at the REPL prompt in Thonny. You can now start writing and executing MicroPython code on your Pi Pico.</p><p>That's it! You've successfully flashed MicroPython onto your Raspberry Pi Pico using Thonny IDE. You can now start exploring the capabilities of MicroPython on your device.</p><p></p><p>And it works, the instructions provided by ChatGPT on how to flash MicroPython on to a Pi Pico was successful!</p><p></p><p>Flashing and checking connection:</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;74a9d4c3-5799-47fd-8d4f-4ce317f2939f&quot;,&quot;duration&quot;:null}"></div><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;26ffc387-08ac-4c36-a0a7-2133c023d8cf&quot;,&quot;duration&quot;:null}"></div><p>Stay tuned!</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.byteberzerker.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption"></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item></channel></rss>