TM1637 LED Display ansteuern - Only 4 PIN Red Common Anode 4-Segment Digital Tube Display For Arduino Raspberry: Unterschied zwischen den Versionen

Aus www.electronic-man.randschtoischlotzer.de
Wechseln zu: Navigation, Suche
(Anschlußschema am BananaPiPro)
(Anschlußschema am BananaPiPro)
Zeile 67: Zeile 67:
 
  @reboot /root/47digitclock.py &
 
  @reboot /root/47digitclock.py &
  
<div class="toccolours mw-collapsible" style="width:400px; overflow:auto;">
+
 
47digitclock.py {{47digitclock.py}}
+
<div class="mw-collapsible mw-collapsed" data-expandtext="47digitclock.py" data-collapsetext="zuklapppen">
 +
<pre>
 +
#!/usr/bin/env python
 +
# -*- coding: utf-8 -*-
 +
 
 +
# https://raspberrytips.nl/tm1637-4-digit-led-display-raspberry-pi/
 +
 
 +
import sys
 +
import time
 +
import datetime
 +
import RPi.GPIO as GPIO
 +
import tm1637
 +
 
 +
#CLK -> GPIO20 (Pin 38)
 +
#DI0 -> GPIO21 (Pin 40)
 +
 
 +
Display = tm1637.TM1637(20,21,tm1637.BRIGHT_TYPICAL)
 +
 
 +
Display.Clear()
 +
Display.SetBrightnes(1)
 +
 
 +
while(True):
 +
  now = datetime.datetime.now()
 +
  hour = now.hour
 +
  minute = now.minute
 +
  second = now.second
 +
  currenttime = [ int(hour / 10), hour % 10, int(minute / 10), minute % 10 ]
 +
 
 +
  Display.Show(currenttime)
 +
  Display.ShowDoublepoint(second % 2)
 +
 
 +
  time.sleep(1)
 +
 
 +
</pre>
 
</div>
 
</div>
  
 
[https://raspberrytips.nl/tm1637-4-digit-led-display-raspberry-pi/ Quelle:]
 
[https://raspberrytips.nl/tm1637-4-digit-led-display-raspberry-pi/ Quelle:]
 
[https://github.com/timwaizenegger/raspberrypi-examples/tree/master/actor-led-7segment-4numbers Quelle 2:]
 
[https://github.com/timwaizenegger/raspberrypi-examples/tree/master/actor-led-7segment-4numbers Quelle 2:]

Version vom 28. Januar 2018, 11:58 Uhr

Anschlußschema am BananaPiPro

Raspberry-Pi-GPIO-Layout-190x600.png

TM1637 Board Pin Funktion    RPi PIN RPi Funktion
GND Ground 39 GND
VCC +3,3V Power 1 3,3V
DIO Data In 38 GPIO 20
CLK Clock 40 GPIO 21
  • Python Scripte:
    • downloaden:
wget https://raspberrytips.nl/files/tm1637.py
wget https://raspberrytips.nl/files/47digitclock.py
  • 4747digitclock.py für obige Schaltung anpassen:
  • GPIO 23 auf GPIO 20 (RPi-Pin 16 auf 38)
  • GPIO 24 auf GPIO 21 (RPi-Pin 18 auf 40)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# https://raspberrytips.nl/tm1637-4-digit-led-display-raspberry-pi/

import sys
import time
import datetime
import RPi.GPIO as GPIO
import tm1637

#CLK -> GPIO20 (Pin 38)
#DI0 -> GPIO21 (Pin 40)

Display = tm1637.TM1637(20,21,tm1637.BRIGHT_TYPICAL)

Display.Clear()
Display.SetBrightnes(1)

while(True):
   now = datetime.datetime.now()
   hour = now.hour
   minute = now.minute
   second = now.second
   currenttime = [ int(hour / 10), hour % 10, int(minute / 10), minute % 10 ]

   Display.Show(currenttime)
   Display.ShowDoublepoint(second % 2)

   time.sleep(1)
  • ausführbar machen:
chmod +x *.py
  • automatsich beim Booten starten:
sudo crontab -e
  • Zeile einfügen:
@reboot /root/47digitclock.py &


#!/usr/bin/env python
# -*- coding: utf-8 -*-

# https://raspberrytips.nl/tm1637-4-digit-led-display-raspberry-pi/

import sys
import time
import datetime
import RPi.GPIO as GPIO
import tm1637

#CLK -> GPIO20 (Pin 38)
#DI0 -> GPIO21 (Pin 40)

Display = tm1637.TM1637(20,21,tm1637.BRIGHT_TYPICAL)

Display.Clear()
Display.SetBrightnes(1)

while(True):
   now = datetime.datetime.now()
   hour = now.hour
   minute = now.minute
   second = now.second
   currenttime = [ int(hour / 10), hour % 10, int(minute / 10), minute % 10 ]

   Display.Show(currenttime)
   Display.ShowDoublepoint(second % 2)

   time.sleep(1)

Quelle: Quelle 2: