【功能需求】
1.自动识别书本是否被取出。
2.收集学生或家庭成员的学号或编号,并生成EXCEL表格。
3.触屏输入输出相关数据。
4.可扩展性强,成本低。
【功能原理】
1.光敏传感器识别对应格子中书本是否取出。
2.通过python的xlwt库收集取书者信息。
3.基于行空板,编辑触屏按键输入个人学号或者编号,并输出对应颜色区域代表书本是否取出。
【详细步骤】
步骤1 材料准备
材料清单
- 光敏传感器 X若干
- 纸书架 X1组
- 行空板 X1个
- 各类书本 X若干
- 杜邦线 X若干
步骤2 设计并连接硬件
步骤3 设计程序
代码
# -*- coding: UTF-8 -*-
# MindPlus
# Python
from pinpong.extension.unihiker import *
from pinpong.board import Board,Pin
from pinpong.board import Board
from pinpong.board import Pin
from unihiker import GUI
import time
# 事件回调函数
def button_clickq():
global hang
global n1
global GuangZhi01
global GuangZhi02
global GuangZhi03
global GuangZhi04
global GuangZhi05
global GuangZhi06
while True:
if (((int(float(n1))) > 50) or ((int(float(n1))) == 0)):
tishi.config(text="请重新输入:")
n1 = " "
xh.config(text=n1)
else:
xh.config(text="")
tishi.config(text="登记成功,请取书!")
thread1=u_gui.start_thread(u_thread1_function)
table.write(hang, 0, n1, style=mindStyle)
fp.save("jieyuejilu.xls")
hang = (hang + 1)
break
def button_clickd():
global n1
n1 = (int(float(n1)))//10
xh.config(text=n1)
def u_thread1_function():
time.sleep(2)
tishi.config(text="请输入你的学号:")
def button_click2():
global n1
n1 = (str(n1) + str("2"))
xh.config(text=n1)
def button_click1():
global n1
n1 = (str(n1) + str("1"))
xh.config(text=n1)
def button_click3():
global n1
n1 = (str(n1) + str("3"))
xh.config(text=n1)
def button_click7():
global n1
n1 = (str(n1) + str("7"))
xh.config(text=n1)
def button_click6():
global n1
n1 = (str(n1) + str("6"))
xh.config(text=n1)
def button_click5():
global n1
n1 = (str(n1) + str("5"))
xh.config(text=n1)
def button_click4():
global n1
n1 = (str(n1) + str("4"))
xh.config(text=n1)
def button_click8():
global n1
n1 = (str(n1) + str("8"))
xh.config(text=n1)
def button_click0():
global n1
n1 = (str(n1) + str("0"))
xh.config(text=n1)
def button_click9():
global n1
n1 = (str(n1) + str("9"))
xh.config(text=n1)
Board().begin()
u_gui=GUI()
import xlwt
p_p21_analog=Pin(Pin.P21, Pin.ANALOG)
p_p22_analog=Pin(Pin.P22, Pin.ANALOG)
global hang
hang = 0
fp = xlwt.Workbook(encoding="ascii")
table = fp.add_sheet(sheetname="Mind+", cell_overwrite_ok=False)
mindStyle = xlwt.XFStyle()
mindAlignment = xlwt.Alignment()
mindAlignment.horz = 0x02
pin1 = Pin(Pin.P1, Pin.ANALOG)
pin2 = Pin(Pin.P2, Pin.ANALOG)
pin3 = Pin(Pin.P0, Pin.ANALOG)
pin16 = Pin(Pin.P16, Pin.ANALOG)
title=u_gui.draw_text(text="X(X)班 图书角",x=120,y=10,font_size=10, color="#000000")
title.config(origin="center")
for xn in range(0, 201, 40):
shujia_1=u_gui.draw_rect(x=xn,y=30,w=40,h=50,width=2,color="#0000FF")
book_01=u_gui.fill_rect(x=0,y=31,w=38,h=48,color="#00FF00")
book_02=u_gui.fill_rect(x=41,y=31,w=38,h=48,color="#00FF00")
book_03=u_gui.fill_rect(x=81,y=31,w=38,h=48,color="#00FF00")
book_04=u_gui.fill_rect(x=121,y=31,w=38,h=48,color="#00FF00")
book_05=u_gui.fill_rect(x=161,y=31,w=38,h=48,color="#00FF00")
book_06=u_gui.fill_rect(x=201,y=31,w=38,h=48,color="#00FF00")
tishi=u_gui.draw_text(text="请输入你的学号:",x=0,y=80,font_size=15, color="#000000")
global GuangZhi01
global GuangZhi02
global GuangZhi03
global GuangZhi04
global GuangZhi05
global GuangZhi06
GuangZhi01 = " "
global n1
n1 = " "
srk=u_gui.draw_rect(x=0,y=120,w=240,h=28,width=1,color="#0000FF")
xh=u_gui.draw_text(text=n1,x=0,y=125,font_size=10, color="#000000")
button_1=u_gui.add_button(text="1",x=10,y=150,w=55,h=55,onclick=button_click1)
button_2=u_gui.add_button(text="2",x=65,y=150,w=55,h=55,onclick=button_click2)
button_3=u_gui.add_button(text="3",x=120,y=150,w=55,h=55,onclick=button_click3)
button_0=u_gui.add_button(text="0",x=175,y=150,w=55,h=55,onclick=button_click0)
button_4=u_gui.add_button(text="4",x=10,y=205,w=55,h=55,onclick=button_click4)
button_5=u_gui.add_button(text="5",x=65,y=205,w=55,h=55,onclick=button_click5)
button_6=u_gui.add_button(text="6",x=120,y=205,w=55,h=55,onclick=button_click6)
button_7=u_gui.add_button(text="7",x=10,y=260,w=55,h=55,onclick=button_click7)
button_8=u_gui.add_button(text="8",x=65,y=260,w=55,h=55,onclick=button_click8)
button_9=u_gui.add_button(text="9",x=120,y=260,w=55,h=55,onclick=button_click9)
button_d=u_gui.add_button(text="⬅",x=175,y=205,w=55,h=55,onclick=button_clickd)
button_q=u_gui.add_button(text="确认",x=175,y=260,w=55,h=55,onclick=button_clickq)
while True:
GuangZhi01 = pin1.read_analog()
GuangZhi02 = pin2.read_analog()
GuangZhi03 = pin3.read_analog()
GuangZhi04 = p_p21_analog.read_analog()
GuangZhi05 = p_p22_analog.read_analog()
GuangZhi06 = pin16.read_analog()
if (GuangZhi01 > 500):
book_01.config(color="#CC0000")
else:
book_01.config(color="#00FF00")
if (GuangZhi02 > 500):
book_02.config(color="#CC0000")
else:
book_02.config(color="#00FF00")
if (GuangZhi03 > 500):
book_03.config(color="#CC0000")
else:
book_03.config(color="#00FF00")
if (GuangZhi04 > 500):
book_04.config(color="#CC0000")
else:
book_04.config(color="#00FF00")
if (GuangZhi05 > 500):
book_05.config(color="#CC0000")
else:
book_05.config(color="#00FF00")
if (GuangZhi06 > 500):
book_06.config(color="#CC0000")
else:
book_06.config(color="#00FF00")
步骤4 验证设计
【优化的方向】
1、精简程序,优化占用内存。
2、增大触摸屏,方便学生使用。
3、将数据上传物联网平台,反馈给手机APP。
花生编程2023.01.21
赞
三春牛-创客2023.01.03
不错,有用的项目
三春牛-创客2023.01.03
厉害厉害
糖醋花生2022.12.07
不太建议from import*建议用import
老曾2022.11.21
程序是空白的
白凡2022.11.22
额,我晚上回家重新传一份试试。。。。