1. 普通的流水燈
import time
import sys
fresh_time = 0.3
length = 7
mod = 1
if mod == 1:
print("flowing light:")
while mod == 1:
for i in range(length):
bar = ['['] + [' '] * length + [']']
bar[i + 1] = '*'
bar_show = ''.join(bar)
print('\r{}'.format(bar_show), end='')
time.sleep(fresh_time)
2. 積累效果的流水燈
elif mod == 2:
print("accumulated flowing light:")
while mod == 2:
for j in range(length):
for i in range(length - j):
bar = ['['] + [' '] * (length - j) + ['*'] * j + [']']
bar[i + 1] = '*'
bar_show = ''.join(bar)
print('\r{}'.format(bar_show), end='')
time.sleep(fresh_time)
time.sleep(fresh_time)
3. 來回效果的流水燈
elif mod == 3:
print("round flowing light:")
while mod == 3:
for j in range(2):
for i in range(length):
bar = ['['] + [' '] * length + [']']
if j == 0:
bar[i + 1] = '*'
else:
bar[-(i + 2)] = '*'
bar_show = ''.join(bar)
print('\r{}'.format(bar_show), end='')
time.sleep(fresh_time)
4. 文字流水燈
elif mod == 4:
print("flowing word light:")
word = "i love u"
while mod == 4:
bar = ['['] + ['*'] * len(word) + [']']
bar_show = ''.join(bar)
print('\r{}'.format(bar_show), end='')
time.sleep(fresh_time)
for i in range(len(word)):
bar[i + 1] = word[i]
bar_show = ''.join(bar)
print('\r{}'.format(bar_show), end='')
time.sleep(fresh_time)
5. 進度條(更完善的進度條python中製作帶數字的進度條)
elif mod == 5:
print("process bar:")
while mod == 5:
for i in range(length):
bar = ['['] + [' '] * length + [']']
for j in range(i + 1):
bar[j + 1] = '*'
bar_show = ''.join(bar)
print('\r{}'.format(bar_show), end='')
time.sleep(fresh_time)
還有一些有趣的想法,以後更新.. 流水燈製作
今天的電路和昨天的led1一樣,只是多了幾個,好像不是幾個,是好幾個。電路分析就不做了,就是給高電平導通,二極體發光就行了。沒有太大的可說性。直接上程式了。include sbit led1 pa0 sbit led2 pa1 sbit led3 pa2 sbit led4 pa3 sbit led...
python流水燈簡單程式 簡單流水燈的實現程式
微控制器流水燈程式如下 1 流水燈的組合語言實現 org 0000h 程式從0位址開始 start mov a,0feh acc賦值為11111110 loop mov p1,a 將累加器a的值賦值給p1 rr a acc的內容右移 call delay 呼叫延時子程式 ljmp loop 跳到lo...
可控的花樣流水燈
其實,上文中的電路,並不是實際的硬體電路,其中的數碼顯示器,是使用了 proteus 中的 元件。如果想要製作硬體電路,這個 的元件就必須更換為七段解碼器晶元,選用 cd4511 74ls48 這些解碼器都可以。如果採用軟體解碼,也可以省掉解碼晶元,這更體現了微控制器的智慧型特點。下面就是採用軟體解...