当前SAKSHAT为我们提供的方法参考:http://wiki.nxez.com/saks:sdk:libraries:led74hc595
这里就直接摘录了,以下是创百科的内容:
74HC595 芯片驱动下的 LED 灯组类,控制一组 LED 工作。 方法
初始化对象,设置引脚和触发电平(高电平或低电平触发)。pins 为 IO 引脚数组。
返回当前驱动数码管的IC对象。
返回当前 LED 的工作状态。true 或 false。index 为 LED 编号,从 0 开始。
返回当前 LED 灯组的工作状态的数组。
设置 LED 灯组为全部点亮状态。
设置 LED 灯组为全部熄灭状态。
设置当前 LED 灯组的第 index+1 个 LED 的状态为点亮。index 为 LED 编号,从 0 开始。
设置当前 LED 灯组的第 index+1 个 LED 的状态为熄灭。index 为 LED 编号,从 0 开始。
设置当前 LED 灯组的点亮状态。status 为布尔型数组。status 中的元素也可以为 None,表示不改变该元素位置的 LED 状态。
#点亮所有LED灯
from sakshat import SAKSHAT
from sakspins import SAKSPins as PINS
if __name__ == "__main__":
try:
#Declare the SAKS Board
SAKS = SAKSHAT()
#点亮所有LED灯
SAKS.ledrow.on()
except KeyboardInterrupt:
print("任务被终止了")
#熄灭所有LED灯
from sakshat import SAKSHAT
from sakspins import SAKSPins as PINS
if __name__ == "__main__":
try:
#Declare the SAKS Board
SAKS = SAKSHAT()
#熄灭所有LED灯
SAKS.ledrow.off()
except KeyboardInterrupt:
print("任务被终止了")
#返回当前LED灯组状态。
import time
from sakshat import SAKSHAT
from sakspins import SAKSPins as PINS
led_status = []
if __name__ == "__main__":
try:
#Declare the SAKS Board
SAKS = SAKSHAT()
#点亮所有灯并输出所有灯状态
for i in range(0, 8):
SAKS.ledrow.on_for_index(i)
led_status = SAKS.ledrow.row_status
print("点亮所有灯状态" + str(led_status))
time.sleep(5)
#关闭所有灯并输出等状态
for i in range(0, 8):
SAKS.ledrow.off_for_index(i)
led_status = SAKS.ledrow.row_status
print("关闭所有灯状态" + str(led_status))
time.sleep(5)
#熄灭所有LED灯
SAKS.ledrow.off()
#间隔点亮LED灯模式1
for i in range(0, 8, 2):
SAKS.ledrow.on_for_index(i)
led_status = SAKS.ledrow.row_status
print("间隔点亮LED灯模式1" + str(led_status))
time.sleep(5)
#熄灭所有LED灯
SAKS.ledrow.off()
#间隔点亮LED灯模式2
for i in range(1, 8, 2):
SAKS.ledrow.on_for_index(i)
led_status = SAKS.ledrow.row_status
print("间隔点亮LED灯模式2" + str(led_status))
except KeyboardInterrupt:
print("任务被终止了")
#返回当前LED单个灯状态。
import time
from sakshat import SAKSHAT
from sakspins import SAKSPins as PINS
led_status = []
if __name__ == "__main__":
try:
#Declare the SAKS Board
SAKS = SAKSHAT()
#熄灭所有LED灯
SAKS.ledrow.off()
#关闭所有灯并输出等状态
for i in range(0, 8, 2):
SAKS.ledrow.on_for_index(i)
led_status = SAKS.ledrow.row_status
print("关闭所有灯状态" + str(led_status))
for i in range(0, 8):
led_one_status = SAKS.ledrow.is_on(i)
print("第" + str(i) + "个LED灯状态为" + str(led_one_status))
except KeyboardInterrupt:
print("任务被终止了")
#逐一点亮LED灯,然后逐一熄灭LED灯
import time
from sakshat import SAKSHAT
from sakspins import SAKSPins as PINS
if __name__ == "__main__":
try:
#Declare the SAKS Board
SAKS = SAKSHAT()
for i in range(0, 8):
SAKS.ledrow.on_for_index(i)
time.sleep(1)
for i in range(0, 8):
SAKS.ledrow.off_for_index(i)
time.sleep(1)
except KeyboardInterrupt:
print("任务被终止了")
#设置LED灯族状态
import time
from sakshat import SAKSHAT
from sakspins import SAKSPins as PINS
if __name__ == "__main__":
try:
#Declare the SAKS Board
SAKS = SAKSHAT()
SAKS.ledrow.set_row([True, False, True, False, True, False, True, False])
time.sleep(5)
SAKS.ledrow.set_row([None, True, None, True, None, None, None, None])
time.sleep(5)
SAKS.ledrow.set_row([None, None, None, None, None, True, None, True])
time.sleep(5)
SAKS.ledrow.set_row([False, None, False, None, False, None, False, None])
time.sleep(5)
SAKS.ledrow.set_row([False, False, False, False, False, False, False, False])
except KeyboardInterrupt:
print("任务被终止了")
#流水灯走起
import time
from sakshat import SAKSHAT
from sakspins import SAKSPins as PINS
if __name__ == "__main__":
try:
#Declare the SAKS Board
SAKS = SAKSHAT()
while True:
for i in range(0, 8):
SAKS.ledrow.on_for_index(i)
time.sleep(0.1)
SAKS.ledrow.off_for_index(i)
except KeyboardInterrupt:
print("任务被终止了")
课程 bilibili 视频地址:https://www.bilibili.com/video/av71878718/?p=18
编码器是一种用来测量机械旋转或位移的传感器。它能够测量机械部件在旋转或直线运动时的位移位置或速度等信息,并将其转换成一系列电信号。
本章将创建一个应用,将Android手机变成LEGO MINDSTORMS NXT 机器人的遥控器。
报告分析了少儿编程行业政策演变过程和发展趋势、中美少儿编程差异点、行业现状和主流模式、当前痛点及应对方式,并测算市场规模,梳理代表性企业及其亮点,预测未来少儿编程行业趋势及格局。
少儿编程被越来越多的家长关注,很多媒体和机构也在宣传学习少儿编程的好处,部分宣传比较夸张,诸如“未来人工智能时代,不学习编程就会”导致家长更容易陷入焦虑,到底要不要孩子去学编程呢?
学习 C 是宝贵的经验,非常值得。即便不作为第一门语言,也应该作为第二、第三或第四门编程语言进行学习。C 有很多优点,但也有一些缺点。至少学习C 编程没有任何损失。所以,请给自己一个机会,尝试一下,也许你会像我一样爱上它。
“蓝桥杯”白名单比赛和蓝桥STEMA考试,到底是什么?有什么关系?本文为大家揭晓!
为大家准备了全国复赛精选赛题解析,一起来看看吧。
就像人类需要记忆一样,应用需要存储。本章将探究如何在应用中实现信息的存储。
Pillow在PIL的基础上,为Python3增加了更多功能和支持。我们将看到如何在图像上执行各种操作,例如裁剪,调整大小,添加文本到图像,旋转,灰阶转换。
鉴于GESP最高两级7-8级大纲与CSP-J/S大纲基本吻合, GESP向CSP-J/S衔接办法如下