<?xml version="1.0"?>
<rss version="2.0">
   <channel>
      <title>My fancy padlet by Samuel Arnold</title>
      <link>https://padlet.com/samuel_creepers/3o72a4wtyxuywbxs</link>
      <description></description>
      <language>en-us</language>
      <pubDate>2024-09-14 14:01:16 UTC</pubDate>
      <lastBuildDate>2024-09-14 14:02:45 UTC</lastBuildDate>
      <webMaster>hello@padlet.com</webMaster>
      <image>
         <url></url>
      </image>
      <item>
         <title></title>
         <author>samuel_creepers</author>
         <link>https://padlet.com/samuel_creepers/3o72a4wtyxuywbxs/wish/3119696295</link>
         <description><![CDATA[<p>import RPi.GPIO as GPIO</p><p>from time import sleep</p><p># Define GPIO pins for the 74HC595 module</p><p>dataPin = 17   # GPIO pin connected to DS (data)</p><p>latchPin = 27  # GPIO pin connected to ST_CP (latch)</p><p>clockPin = 22  # GPIO pin connected to SH_CP (clock)</p><p># Define GPIO pin for the button</p><p>buttonPin = 18</p><p># Seven-segment digit encoding (common cathode)</p><p># Segment order: a, b, c, d, e, f, g</p><p>digits = {</p><p>    '0': 0b00111111, '1': 0b00000110, '2': 0b01011011, '3': 0b01001111,</p><p>    '4': 0b01100110, '5': 0b01101101, '6': 0b01111101, '7': 0b00000111,</p><p>    '8': 0b01111111, '9': 0b01101111</p><p>}</p><p># Setup GPIO</p><p>GPIO.setmode(GPIO.BCM)</p><p>GPIO.setup(dataPin, GPIO.OUT)</p><p>GPIO.setup(latchPin, GPIO.OUT)</p><p>GPIO.setup(clockPin, GPIO.OUT)</p><p>GPIO.setup(buttonPin, <a rel="noopener noreferrer nofollow" href="http://GPIO.IN">GPIO.IN</a>, pull_up_down=GPIO.PUD_UP)  # Button with pull-up</p><p># Function to shift out the data to 74HC595</p><p>def shift_out(data):</p><p>    GPIO.output(latchPin, GPIO.LOW)  # Begin the latch</p><p>    for i in range(8):</p><p>        GPIO.output(clockPin, GPIO.LOW)</p><p>        GPIO.output(dataPin, GPIO.HIGH if data &amp; (1 &lt;&lt; (7 - i)) else GPIO.LOW)</p><p>        GPIO.output(clockPin, GPIO.HIGH)</p><p>    GPIO.output(latchPin, GPIO.HIGH)  # Latch the output</p><p># Function to display a number on the 7-segment display</p><p>def display_number(num):</p><p>    num_str = str(num).zfill(4)  # Pad the number to 4 digits</p><p>    for digit in num_str:</p><p>        shift_out(digits[digit])  # Send each digit to the display</p><p>        sleep(0.001)  # Small delay to avoid flickering</p><p># Button press detection with debouncing</p><p>def button_pressed():</p><p>    if GPIO.input(buttonPin) == GPIO.LOW:</p><p>        sleep(0.2)  # Debounce delay</p><p>        if GPIO.input(buttonPin) == GPIO.LOW:</p><p>            return True</p><p>    return False</p><p># Main loop</p><p>current_number = 0</p><p>try:</p><p>    while True:</p><p>        display_number(current_number)</p><p>        if button_pressed():</p><p>            current_number += 1</p><p>            if current_number &gt; 9999:  # Roll over after 9999</p><p>                current_number = 0</p><p>        sleep(0.1)</p><p>except KeyboardInterrupt:</p><p>    GPIO.cleanup()</p>]]></description>
         <enclosure url="" />
         <pubDate>2024-09-14 14:02:45 UTC</pubDate>
         <guid>https://padlet.com/samuel_creepers/3o72a4wtyxuywbxs/wish/3119696295</guid>
      </item>
   </channel>
</rss>
