ESP32(MicroPython) 几个动画

news/2024/10/21 9:30:49/

ESP32(MicroPython)几个动画

本次发布的动画程序如下

矩形缩放

'''
接线:OLED(IIC)SCL-->(18)SDA-->(23)         
'''#导入Pin模块
from machine import Pin
import time
from machine import SoftI2C
from ssd1306 import SSD1306_I2C  #I2C的oled选该方法
import random#创建硬件I2C对象
#i2c=I2C(0,sda=Pin(19), scl=Pin(18), freq=400000)#创建软件I2C对象
i2c = SoftI2C(sda=Pin(23), scl=Pin(18))
#创建OLED对象,OLED分辨率、I2C接口
oled = SSD1306_I2C(128, 64, i2c)#程序入口
if __name__=="__main__":while True:a=60b=30c=8d=4 oled.rect(a,b,c,d,1)  #画矩形oled.show()  #执行显示while a>2 :oled.fill(0)  #清空屏幕a-=2b-=1c+=4d+=2oled.rect(a,b,c,d,1)  #画矩形oled.show()  #执行显示while a<60 :oled.fill(1)  #清空屏幕a+=2b+=1c-=4d-=2oled.fill_rect(a,b,c,d,0)  #画矩形oled.show()  #执行显示

矩形下落(改版)

'''
接线:OLED(IIC)SCL-->(18)SDA-->(23)         
'''#导入Pin模块
from machine import Pin
import time
from machine import SoftI2C
from ssd1306 import SSD1306_I2C  #I2C的oled选该方法
import random#创建硬件I2C对象
#i2c=I2C(0,sda=Pin(19), scl=Pin(18), freq=400000)#创建软件I2C对象
i2c = SoftI2C(sda=Pin(23), scl=Pin(18))
#创建OLED对象,OLED分辨率、I2C接口
oled = SSD1306_I2C(128, 64, i2c)#程序入口
if __name__=="__main__":while True:a=random.randint(2,110)b=random.randint(5,25)c=random.randint(5,20)d=random.randint(2,10)oled.rect(a,1,b,c,1)  #画矩形oled.show()  #执行显示oled.hline(0,0,128,0)  #清除移动前显示区oled.scroll(0,1)  #指定像素X轴移动time.sleep_ms(2)

矩形移动

'''
接线:OLED(IIC)SCL-->(18)SDA-->(23)         
'''#导入Pin模块
from machine import Pin
import time
from machine import SoftI2C
from ssd1306 import SSD1306_I2C  #I2C的oled选该方法
import random#创建硬件I2C对象
#i2c=I2C(0,sda=Pin(19), scl=Pin(18), freq=400000)#创建软件I2C对象
i2c = SoftI2C(sda=Pin(23), scl=Pin(18))
#创建OLED对象,OLED分辨率、I2C接口
oled = SSD1306_I2C(128, 64, i2c)#程序入口
if __name__=="__main__":while True:a=random.randint(5,15)b=random.randint(5,15)c=random.randint(8,23)d=random.randint(8,23) oled.rect(a,b,c,d,1)  #画矩形oled.show()  #执行显示while a<100 :oled.fill(0)  #清空屏幕a+=3oled.rect(a,b,c,d,1)  #画矩形oled.show()  #执行显示while b<40 :oled.fill(1)  #清空屏幕b+=2oled.fill_rect(a,b,c,d,0)  #画矩形oled.show()  #执行显示while a>5 :oled.fill(0)  #清空屏幕a-=3oled.rect(a,b,c,d,1)  #画矩形oled.show()  #执行显示while b>5 :oled.fill(1)  #清空屏幕b-=2oled.fill_rect(a,b,c,d,0)  #画矩形oled.show()  #执行显示   

同心矩形放大

'''
接线:OLED(IIC)SCL-->(18)SDA-->(23)         
'''#导入Pin模块
from machine import Pin
import time
from machine import SoftI2C
from ssd1306 import SSD1306_I2C  #I2C的oled选该方法
import random#创建硬件I2C对象
#i2c=I2C(0,sda=Pin(19), scl=Pin(18), freq=400000)#创建软件I2C对象
i2c = SoftI2C(sda=Pin(23), scl=Pin(18))
#创建OLED对象,OLED分辨率、I2C接口
oled = SSD1306_I2C(128, 64, i2c)#程序入口
if __name__=="__main__":while True:a=60b=30c=8d=4e=60f=30g=8h=4oled.rect(a,b,c,d,1)  #画矩形oled.show()  #执行显示while a>50 :e-=2f-1g+=4h+=2oled.fill(0)  #清空屏幕while a>2 :    a-=8b-=4c+=16d+=8oled.rect(a,b,c,d,1)  #画矩形oled.show()  #执行显示a=eb=fc=gd=h


http://www.ppmy.cn/news/283579.html

相关文章

摄像机产生“拖影”、“重影”的原因

摄像机产生“拖影”、“重影”的原因&#xff1a; 快门时间较短&#xff1a;对于25帧的视频&#xff0c;如果快门时间为1/12&#xff0c;自然两帧图像叠加在一起降噪算法&#xff1a;使用3D降噪时&#xff0c;需要前后帧参与运算&#xff0c;可能导致此现象增益过大&#xff1…

有史以来最漂亮的游戏机

The recent reveal of the PlayStation 5’s design has divided the gaming world. There are those who appreciate its bold, daring industrial design and those who would have preferred something a little less outlandish; perhaps a little more traditional. 吨 他…

PM42L-048 步进电机

原文地址::http://www.doc88.com/p-007903494027.html 相关文章 1、日本NMB电机PM42L-048----https://www.kuyibu.com/c_gw1122/p4474960.html 2、步进电机"pm42l-048-syh2"代表什么意思----https://zhidao.baidu.com/question/166351370.html 3、JX-2R-05系列微…

Panasonic Lumix GH5: Tips, Tricks, and Techniques 松下Lumix GH5使用技巧 Lynda课程中文字幕

Panasonic Lumix GH5: Tips, Tricks, and Techniques 中文字幕 松下Lumix GH5使用技巧 中文字幕Panasonic Lumix GH5: Tips, Tricks, and Techniques 松下Lumix GH5是一款功能强大的相机&#xff0c;内含各种酷炫功能 在本课程中&#xff0c;您将学习如何充分利用GH5&#xff…

二十年前,我们认为的“聪明手机”,现在来看是否是聪明了?

时光飞逝&#xff0c;我们只能体会到一分一秒的流逝&#xff0c;却很难感受到科技发展带来的巨大变化。很多时候&#xff0c;我们以为的变化是理所当然&#xff0c;甚至觉得智能手机没有什么改进。但是当你将视野放到十年二十年时&#xff0c;你就知道&#xff0c;这么短的时间…

相机工作原理

导读&#xff1a; 一、摄像头模组CCM 二、摄像头工作原理 一、摄像头模组&#xff08;CCM&#xff09; 1、camera特写 摄像头模组&#xff0c;Camera Compact Module&#xff0c;简写为CCM&#xff0c;是影响捕捉的重要元器件&#xff0c;我的理解就是硬件上的摄像头。如下图&a…

主流相机RTSP地址格式

https://blog.csdn.net/qq_34654240/article/details/79924390转载来自 佳能/Canon: rtsp://192.168.100.1/ 佳能/Canon: rtsp://192.168.100.1/stream/profile1u 佳能/Canon: rtsp://192.168.100.1/profile1r 佳能/Canon: rtsp://192.168.100.1/profile1u 海康威视rtsp://…

【vue3】09-vue组件化额外知识补充(上)-生命周期-ref引用

组件化-额外知识补充&#xff08;上&#xff09; 生命周期认识生命周期生命周期函数的演练 refs引用 生命周期 认识生命周期 什么是生命周期呢? 生物学上&#xff0c;生物生命周期指得是一个生物体在生命开始到结束周而复始所历经的一系列变化过程;每个组件都可能会经历从创…