Created
September 23, 2018 13:43
-
-
Save shikarunochi/6c991570173568f1ecc6d04a9efeb652 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from m5stack import lcd | |
import machine, time | |
#lcd.compileFont('x12y20pxScanLine.c') | |
hexString="0123456789ABCDEF" | |
wordString="HOWALIVE" | |
lcd.clear() | |
lcd.setCursor(0, 0) | |
lcd.setColor(lcd.WHITE) | |
servo = machine.PWM(21) | |
servo.freq(500) | |
servo.duty(50) | |
time.sleep_ms(10000) | |
#lcd.font('x12y20pxScanLine.fon') | |
for index in range(len(wordString)): | |
lcd.clear() | |
lcd.setCursor(0, 0) | |
lcd.print(wordString[0:index+1] + "\n\n") | |
lcd.print(wordString[index] + "\n") | |
hexValue = hex(ord(wordString[index])) | |
lcd.print(hexValue) | |
offset = 90 - 80 * int(hexValue[2],16) / 17 | |
if offset >= 90: | |
offset = 90 | |
if offset <= 20: | |
offset = 20 | |
servo.duty(offset) | |
print(offset) | |
time.sleep_ms(2000) | |
offset = 90 - 80 * int(hexValue[3],16) / 17 | |
if offset >= 90: | |
offset = 90 | |
if offset <= 20: | |
offset = 20 | |
servo.duty(offset) | |
print(offset) | |
time.sleep_ms(2000) | |
servo.deinit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment