Skip to content

Instantly share code, notes, and snippets.

@tadeubas
Created February 7, 2023 01:15
Show Gist options
  • Save tadeubas/96443b817af2be4a30a949f537ca76c4 to your computer and use it in GitHub Desktop.
Save tadeubas/96443b817af2be4a30a949f537ca76c4 to your computer and use it in GitHub Desktop.
Square bounces on the LEFT if NO SD card detected, otherwise it bounces on the RIGHT
import image
import lcd
import sensor
import os
import time
from machine import SDCard
lcd.init(freq=15000000)
sensor.reset() # Reset and initialize the sensor. It will
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240)
sensor.skip_frames(time = 2000) # Wait for settings take effect.
# mostra ["flash", "sd"] se disponivel
print(os.listdir("/"))
def sd_check():
try:
os.listdir("/sd/.")
except Exception as e:
return False
return True
i = 0
dir = 1
img = sensor.snapshot()
while(True):
img.clear()
img.draw_rectangle(i, 50, 50, 50)
lcd.display(img)
SDCard.remount()
time.sleep(2)
if sd_check():
if i == 270:
i=250
else:
i=270
else:
if i == 0:
i=20
else:
i=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment