{"id":1090,"date":"2015-12-29T12:09:48","date_gmt":"2015-12-29T12:09:48","guid":{"rendered":"http:\/\/www.horter.de\/blog\/?p=1090"},"modified":"2023-01-14T18:33:08","modified_gmt":"2023-01-14T18:33:08","slug":"i2c-module-mit-python-und-tkinter-auf-raspberry-py","status":"publish","type":"post","link":"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/","title":{"rendered":"I2C-Digital-Output-Modul mit Python und TkInter am Raspberry"},"content":{"rendered":"<p>In diesem Beitrag\u00a0wollen wir zeigen wie man die I2C-Module mit Python ansteuern kann.<\/p>\n<p>Als Visualisierung bzw. zum Bedienen wird TkInter benutzt.<\/p>\n<p>&nbsp;<\/p>\n<h1>Ausg\u00e4nge\u00a0vom I2HA-Modul mit Button-Tasten EIN und AUS schalten<\/h1>\n<p>Unsere Demo-Bedienoberfl\u00e4che hat acht EIN- und acht AUS-Tasten. Diese werden im Programm hinter den Kommentaren<\/p>\n<blockquote><p><span style=\"color: #696969;\">#EIN-Button-Layout<\/span><\/p><\/blockquote>\n<p>und<\/p>\n<blockquote><p><span style=\"color: #696969;\">#AUS-Button-Layout<\/span><\/p><\/blockquote>\n<p>definiert.<\/p>\n<p>So sieht&#8217;s aus:<\/p>\n<div id=\"attachment_1228\" style=\"width: 183px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.horter.de\/blog\/pythontkinter_digout\/\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1228\" class=\"size-full wp-image-1228\" src=\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_DigOut.jpg\" alt=\"I2C-Output Modul mit Tasten steuern\" width=\"173\" height=\"259\" \/><\/a><p id=\"caption-attachment-1228\" class=\"wp-caption-text\">I2C-Output Modul mit Tasten steuern<\/p><\/div>\n<p>&nbsp;<\/p>\n<h3>Module importieren und Globale Variable definieren<\/h3>\n<p>im Hauptprogramm werden einige\u00a0 Module\u00a0importiert.<\/p>\n<p>Au\u00dferdem braucht jede Ausgabekarte eine globale Variable\u00a0die wir einfach mal o1 f\u00fcr die erste Output-karte nennen<\/p>\n<blockquote><p><span style=\"color: #800000; font-weight: bold;\">import<\/span> tkinter<br \/>\n<span style=\"color: #800000; font-weight: bold;\">from<\/span> tkinter <span style=\"color: #800000; font-weight: bold;\">import<\/span> <span style=\"color: #44aadd;\">*<\/span><br \/>\n<span style=\"color: #800000; font-weight: bold;\">from<\/span> tkinter <span style=\"color: #800000; font-weight: bold;\">import<\/span> ttk<br \/>\n<span style=\"color: #800000; font-weight: bold;\">import<\/span> smbus<\/p>\n<p>bus <span style=\"color: #808030;\">=<\/span> smbus<span style=\"color: #808030;\">.<\/span>SMBus<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">)<\/span><br \/>\nmainWin <span style=\"color: #808030;\">=<\/span> Tk<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><br \/>\nmainWin<span style=\"color: #808030;\">.<\/span>title<span style=\"color: #808030;\">(<\/span><span style=\"color: #0000e6;\">&#8218;LED_TEST&#8216;<\/span><span style=\"color: #808030;\">)<\/span><\/p>\n<p>o1 <span style=\"color: #808030;\">=<\/span> <span style=\"color: #008c00;\">0<\/span><\/p><\/blockquote>\n<p>diese Variable wird dann in den Unterprogrammen der Tasten\u00a0manipuliert.<\/p>\n<p>Falls der Import vom SM-Bus nicht funktioniert muss dieser erst noch auf dem Raspberry-Pi installiert werden. Diese Anleitung hilft dabei recht gut. <a href=\"https:\/\/pypi.python.org\/pypi\/smbus-cffi\" target=\"_blank\" rel=\"noopener\">https:\/\/pypi.python.org\/pypi\/smbus-cffi<\/a><\/p>\n<p>&nbsp;<\/p>\n<h3>Funktion Bit setzten \/ r\u00fccksetzten in Variable<\/h3>\n<p>Das Setzten und das R\u00fccksetzten eines einzelnen Bits in einer Variable haben wir in Funktionen gepackt.<br \/>\nDie Ausgabe in die Python Shell kann auch weg gelassen werden.<\/p>\n<blockquote><p><span style=\"color: #800000;\"><span style=\"color: #808030;\">#Funktion Setze Bit in Variable \/ <span class=\"hps\">Function<\/span> <span class=\"hps\">Set<\/span> <span class=\"hps\">Bit<\/span> <span class=\"hps\">in<\/span> <span class=\"hps\">byte<\/span><\/span><br \/>\ndef<\/span> set_bit<span style=\"color: #808030;\">(<\/span>value<span style=\"color: #808030;\">,<\/span> bit<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span><br \/>\n<span style=\"color: #800000;\">print<\/span><span style=\"color: #808030;\">(<\/span>value <span style=\"color: #44aadd;\">|<\/span> <span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #44aadd;\">&lt;&lt;<\/span>bit<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">)\u00a0\u00a0\u00a0 #Ausgabe in der Python Shell<\/span><br \/>\n<span style=\"color: #800000;\">return<\/span> value <span style=\"color: #44aadd;\">|<\/span> <span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #44aadd;\">&lt;&lt;<\/span>bit<span style=\"color: #808030;\">)<\/span><\/p>\n<p><span style=\"color: #800000;\"><span style=\"color: #808030;\">#Funktion r\u00fccksetzte Bit in Variable \/ <span class=\"hps\">Function<\/span> <span class=\"hps\">reset <\/span><span class=\"hps\">Bit<\/span> <span class=\"hps\">in<\/span> <span class=\"hps\">byte<\/span><\/span><br \/>\ndef<\/span> clear_bit<span style=\"color: #808030;\">(<\/span>value<span style=\"color: #808030;\">,<\/span> bit<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span><br \/>\n<span style=\"color: #800000;\">print<\/span><span style=\"color: #808030;\">(<\/span>value <span style=\"color: #44aadd;\">&amp;<\/span> <span style=\"color: #44aadd;\">~<\/span><span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #44aadd;\">&lt;&lt;<\/span>bit<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">)\u00a0\u00a0\u00a0 <span style=\"color: #808030;\">#Ausgabe in der Python Shell<\/span><\/span><br \/>\n<span style=\"color: #800000;\">return<\/span> value <span style=\"color: #44aadd;\">&amp;<\/span> <span style=\"color: #44aadd;\">~<\/span><span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #44aadd;\">&lt;&lt;<\/span>bit<span style=\"color: #808030;\">)<\/span><\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<h3>Schaltbefehl der Ausg\u00e4nge auf Button<\/h3>\n<p>Wird z.B. die EIN-Taste\u00a0gedr\u00fcckt, ruft sich das Unterprogramm der entsprechenden Taste auf.<\/p>\n<p>Beispiel Taste 1 EIN<\/p>\n<blockquote><p><span style=\"color: #800000; font-weight: bold;\">def<\/span> button_1e<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span><br \/>\n<span style=\"color: #800000; font-weight: bold;\">global<\/span> o1<br \/>\no1 <span style=\"color: #808030;\">=<\/span> set_bit<span style=\"color: #808030;\">(<\/span>o1<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">0<\/span><span style=\"color: #808030;\">)<\/span><br \/>\nbus<span style=\"color: #808030;\">.<\/span>write_byte<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">0x20<\/span><span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">255<\/span><span style=\"color: #44aadd;\">&#8211;<\/span>set_bit<span style=\"color: #808030;\">(<\/span>o1<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">0<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">)<\/span><\/p><\/blockquote>\n<p>In der zweiten Zeile wird angegeben, dass im Unterprogramm die globale Variable o1 verwendet werden soll.<\/p>\n<p>In der dritten Zeile wird in der globalen Variable das Bit null gesetzt<\/p>\n<p>In der vierten Zeile wird die Variable invertiert\u00a0und auf den I2C-Bus zum Slave an Adresse <span style=\"color: #008c00;\">0x20<\/span>\u00a0\u00fcbertragen.<\/p>\n<p>&nbsp;<\/p>\n<h3>Programmcode<\/h3>\n<pre style=\"color: #000000; background: #EEEEEE;\"><span style=\"color: #800000; font-weight: bold;\">import<\/span> tkinter\r\n<span style=\"color: #800000; font-weight: bold;\">from<\/span> tkinter <span style=\"color: #800000; font-weight: bold;\">import<\/span> <span style=\"color: #44aadd;\">*<\/span>\r\n<span style=\"color: #800000; font-weight: bold;\">from<\/span> tkinter <span style=\"color: #800000; font-weight: bold;\">import<\/span> ttk\r\n<span style=\"color: #800000; font-weight: bold;\">import<\/span> smbus\r\n\r\nbus <span style=\"color: #808030;\">=<\/span> smbus<span style=\"color: #808030;\">.<\/span>SMBus<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">)<\/span>\r\nmainWin <span style=\"color: #808030;\">=<\/span> Tk<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span>\r\nmainWin<span style=\"color: #808030;\">.<\/span>title<span style=\"color: #808030;\">(<\/span><span style=\"color: #0000e6;\">'LED_TEST'<\/span><span style=\"color: #808030;\">)<\/span>\r\n\r\no1 <span style=\"color: #808030;\">=<\/span> <span style=\"color: #008c00;\">0\r\n<\/span>\r\n<span style=\"color: #696969;\">#Funktion Setze Bit in Variable \/ Function Set Bit in byte<\/span>\r\n<span style=\"color: #800000;\">def<\/span> set_bit<span style=\"color: #808030;\">(<\/span>value<span style=\"color: #808030;\">,<\/span> bit<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>\r\n    <span style=\"color: #800000;\">print<\/span><span style=\"color: #808030;\">(<\/span>value <span style=\"color: #44aadd;\">|<\/span> <span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #44aadd;\">&lt;&lt;<\/span>bit<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">)<\/span>\r\n    <span style=\"color: #800000;\">return<\/span> value <span style=\"color: #44aadd;\">|<\/span> <span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #44aadd;\">&lt;&lt;<\/span>bit<span style=\"color: #808030;\">)<\/span>\r\n\r\n<span style=\"color: #696969;\">#Funktion r\u00fccksetzte Bit in Variable \/ Function reset Bit in byte<\/span>\r\n<span style=\"color: #800000;\">def<\/span> clear_bit<span style=\"color: #808030;\">(<\/span>value<span style=\"color: #808030;\">,<\/span> bit<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>\r\n    <span style=\"color: #800000;\">print<\/span><span style=\"color: #808030;\">(<\/span>value <span style=\"color: #44aadd;\">&amp;<\/span> <span style=\"color: #44aadd;\">~<\/span><span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #44aadd;\">&lt;&lt;<\/span>bit<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">)<\/span>\r\n    <span style=\"color: #800000;\">return<\/span> value <span style=\"color: #44aadd;\">&amp;<\/span> <span style=\"color: #44aadd;\">~<\/span><span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #44aadd;\">&lt;&lt;<\/span>bit<span style=\"color: #808030;\">)<\/span>\r\n\r\n\r\n<span style=\"color: #696969;\">#Buttonbefehle<\/span>\r\n<span style=\"color: #800000;\">def<\/span> button_1e<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>\r\n    <span style=\"color: #800000;\">global<\/span> o1\r\n    o1 <span style=\"color: #808030;\">=<\/span> set_bit<span style=\"color: #808030;\">(<\/span>o1<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">0<\/span><span style=\"color: #808030;\">)<\/span>\r\n    bus<span style=\"color: #808030;\">.<\/span>write_byte<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">0x20<\/span><span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">255<\/span><span style=\"color: #44aadd;\">-<\/span>o1<span style=\"color: #808030;\">)<\/span>\r\n<span style=\"color: #800000;\">def<\/span> button_2e<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>\r\n    <span style=\"color: #800000;\">global<\/span> o1\r\n    o1 <span style=\"color: #808030;\">=<\/span> set_bit<span style=\"color: #808030;\">(<\/span>o1<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">)<\/span>\r\n    bus<span style=\"color: #808030;\">.<\/span>write_byte<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">0x20<\/span><span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">255<\/span><span style=\"color: #44aadd;\">-<\/span>o1<span style=\"color: #808030;\">)<\/span>\r\n<span style=\"color: #800000;\">def<\/span> button_3e<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>\r\n    <span style=\"color: #800000;\">global<\/span> o1\r\n    o1 <span style=\"color: #808030;\">=<\/span> set_bit<span style=\"color: #808030;\">(<\/span>o1<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">)<\/span>\r\n    bus<span style=\"color: #808030;\">.<\/span>write_byte<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">0x20<\/span><span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">255<\/span><span style=\"color: #44aadd;\">-<\/span>o1<span style=\"color: #808030;\">)<\/span>\r\n<span style=\"color: #800000;\">def<\/span> button_4e<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>\r\n    <span style=\"color: #800000;\">global<\/span> o1\r\n    o1 <span style=\"color: #808030;\">=<\/span> set_bit<span style=\"color: #808030;\">(<\/span>o1<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">3<\/span><span style=\"color: #808030;\">)<\/span>\r\n    bus<span style=\"color: #808030;\">.<\/span>write_byte<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">0x20<\/span><span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">255<\/span><span style=\"color: #44aadd;\">-<\/span>o1<span style=\"color: #808030;\">)<\/span>\r\n<span style=\"color: #800000;\">def<\/span> button_5e<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>\r\n    <span style=\"color: #800000;\">global<\/span> o1\r\n    o1 <span style=\"color: #808030;\">=<\/span> set_bit<span style=\"color: #808030;\">(<\/span>o1<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">4<\/span><span style=\"color: #808030;\">)<\/span>\r\n    bus<span style=\"color: #808030;\">.<\/span>write_byte<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">0x20<\/span><span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">255<\/span><span style=\"color: #44aadd;\">-<\/span>o1<span style=\"color: #808030;\">)<\/span>\r\n<span style=\"color: #800000;\">def<\/span> button_6e<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>\r\n    <span style=\"color: #800000;\">global<\/span> o1\r\n    o1 <span style=\"color: #808030;\">=<\/span> set_bit<span style=\"color: #808030;\">(<\/span>o1<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">5<\/span><span style=\"color: #808030;\">)<\/span>\r\n    bus<span style=\"color: #808030;\">.<\/span>write_byte<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">0x20<\/span><span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">255<\/span><span style=\"color: #44aadd;\">-<\/span>o1<span style=\"color: #808030;\">)<\/span>\r\n<span style=\"color: #800000;\">def<\/span> button_7e<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>\r\n    <span style=\"color: #800000;\">global<\/span> o1\r\n    o1 <span style=\"color: #808030;\">=<\/span> set_bit<span style=\"color: #808030;\">(<\/span>o1<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">6<\/span><span style=\"color: #808030;\">)<\/span>\r\n    bus<span style=\"color: #808030;\">.<\/span>write_byte<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">0x20<\/span><span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">255<\/span><span style=\"color: #44aadd;\">-<\/span>o1<span style=\"color: #808030;\">)<\/span>\r\n<span style=\"color: #800000;\">def<\/span> button_8e<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>\r\n    <span style=\"color: #800000;\">global<\/span> o1\r\n    o1 <span style=\"color: #808030;\">=<\/span> set_bit<span style=\"color: #808030;\">(<\/span>o1<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">7<\/span><span style=\"color: #808030;\">)<\/span>\r\n    bus<span style=\"color: #808030;\">.<\/span>write_byte<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">0x20<\/span><span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">255<\/span><span style=\"color: #44aadd;\">-<\/span>o1<span style=\"color: #808030;\">)<\/span>\r\n\r\n\r\n<span style=\"color: #800000;\">def<\/span> button_1a<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>\r\n    <span style=\"color: #800000;\">global<\/span> o1\r\n    o1 <span style=\"color: #808030;\">=<\/span> clear_bit<span style=\"color: #808030;\">(<\/span>o1<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">0<\/span><span style=\"color: #808030;\">)<\/span>\r\n    bus<span style=\"color: #808030;\">.<\/span>write_byte<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">0x20<\/span><span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">255<\/span><span style=\"color: #44aadd;\">-<\/span>o1<span style=\"color: #808030;\">)<\/span>\r\n<span style=\"color: #800000;\">def<\/span> button_2a<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>\r\n    <span style=\"color: #800000;\">global<\/span> o1\r\n    o1 <span style=\"color: #808030;\">=<\/span> clear_bit<span style=\"color: #808030;\">(<\/span>o1<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">)<\/span>\r\n    bus<span style=\"color: #808030;\">.<\/span>write_byte<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">0x20<\/span><span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">255<\/span><span style=\"color: #44aadd;\">-<\/span>o1<span style=\"color: #808030;\">)<\/span>\r\n<span style=\"color: #800000;\">def<\/span> button_3a<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>\r\n    <span style=\"color: #800000;\">global<\/span> o1\r\n    o1 <span style=\"color: #808030;\">=<\/span> clear_bit<span style=\"color: #808030;\">(<\/span>o1<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">)<\/span>\r\n    bus<span style=\"color: #808030;\">.<\/span>write_byte<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">0x20<\/span><span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">255<\/span><span style=\"color: #44aadd;\">-<\/span>o1<span style=\"color: #808030;\">)<\/span>\r\n<span style=\"color: #800000;\">def<\/span> button_4a<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>\r\n    <span style=\"color: #800000;\">global<\/span> o1\r\n    o1 <span style=\"color: #808030;\">=<\/span> clear_bit<span style=\"color: #808030;\">(<\/span>o1<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">3<\/span><span style=\"color: #808030;\">)<\/span>\r\n    bus<span style=\"color: #808030;\">.<\/span>write_byte<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">0x20<\/span><span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">255<\/span><span style=\"color: #44aadd;\">-<\/span>o1<span style=\"color: #808030;\">)<\/span>\r\n<span style=\"color: #800000;\">def<\/span> button_5a<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>\r\n    <span style=\"color: #800000;\">global<\/span> o1\r\n    o1 <span style=\"color: #808030;\">=<\/span> clear_bit<span style=\"color: #808030;\">(<\/span>o1<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">4<\/span><span style=\"color: #808030;\">)<\/span>\r\n    bus<span style=\"color: #808030;\">.<\/span>write_byte<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">0x20<\/span><span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">255<\/span><span style=\"color: #44aadd;\">-<\/span>o1<span style=\"color: #808030;\">)<\/span>\r\n<span style=\"color: #800000;\">def<\/span> button_6a<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>\r\n    <span style=\"color: #800000;\">global<\/span> o1\r\n    o1 <span style=\"color: #808030;\">=<\/span> clear_bit<span style=\"color: #808030;\">(<\/span>o1<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">5<\/span><span style=\"color: #808030;\">)<\/span>\r\n    bus<span style=\"color: #808030;\">.<\/span>write_byte<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">0x20<\/span><span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">255<\/span><span style=\"color: #44aadd;\">-<\/span>o1<span style=\"color: #808030;\">)<\/span>\r\n<span style=\"color: #800000;\">def<\/span> button_7a<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>\r\n    <span style=\"color: #800000;\">global<\/span> o1\r\n    o1 <span style=\"color: #808030;\">=<\/span> clear_bit<span style=\"color: #808030;\">(<\/span>o1<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">6<\/span><span style=\"color: #808030;\">)<\/span>\r\n    bus<span style=\"color: #808030;\">.<\/span>write_byte<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">0x20<\/span><span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">255<\/span><span style=\"color: #44aadd;\">-<\/span>o1<span style=\"color: #808030;\">)<\/span>\r\n<span style=\"color: #800000;\">def<\/span> button_8a<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">:<\/span>\r\n    <span style=\"color: #800000;\">global<\/span> o1\r\n    o1 <span style=\"color: #808030;\">=<\/span> clear_bit<span style=\"color: #808030;\">(<\/span>o1<span style=\"color: #808030;\">,<\/span> <span style=\"color: #008c00;\">7<\/span><span style=\"color: #808030;\">)<\/span>\r\n    bus<span style=\"color: #808030;\">.<\/span>write_byte<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">0x20<\/span><span style=\"color: #808030;\">,<\/span><span style=\"color: #008c00;\">255<\/span><span style=\"color: #44aadd;\">-<\/span>o1<span style=\"color: #808030;\">)<\/span>\r\n\r\n\r\n<span style=\"color: #696969;\">#EIN-Button-Layout<\/span>\r\nlabel_1 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Label<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'Ein'<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">,<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">)<\/span>\r\nButton_1 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Button<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'LED 1'<\/span><span style=\"color: #808030;\">,<\/span> command <span style=\"color: #808030;\">=<\/span> button_1e<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">,<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">)<\/span>\r\nButton_2 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Button<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'LED 2'<\/span><span style=\"color: #808030;\">,<\/span> command <span style=\"color: #808030;\">=<\/span> button_2e<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">,<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">3<\/span><span style=\"color: #808030;\">)<\/span>\r\nButton_3 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Button<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'LED 3'<\/span><span style=\"color: #808030;\">,<\/span> command <span style=\"color: #808030;\">=<\/span> button_3e<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">,<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">4<\/span><span style=\"color: #808030;\">)<\/span>\r\nButton_4 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Button<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'LED 4'<\/span><span style=\"color: #808030;\">,<\/span> command <span style=\"color: #808030;\">=<\/span> button_4e<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">,<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">5<\/span><span style=\"color: #808030;\">)<\/span>\r\nButton_5 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Button<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'LED 5'<\/span><span style=\"color: #808030;\">,<\/span> command <span style=\"color: #808030;\">=<\/span> button_5e<span style=\"color: #808030;\">).<\/span>grid<span style=\"color: #808030;\">(<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">,<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">6<\/span><span style=\"color: #808030;\">)<\/span>\r\nButton_6 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Button<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'LED 6'<\/span><span style=\"color: #808030;\">,<\/span> command <span style=\"color: #808030;\">=<\/span> button_6e<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">,<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">7<\/span><span style=\"color: #808030;\">)<\/span>\r\nButton_7 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Button<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'LED 7'<\/span><span style=\"color: #808030;\">,<\/span> command <span style=\"color: #808030;\">=<\/span> button_7e<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">,<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">8<\/span><span style=\"color: #808030;\">)<\/span>\r\nButton_8 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Button<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'LED 8'<\/span><span style=\"color: #808030;\">,<\/span> command <span style=\"color: #808030;\">=<\/span> button_8e<span style=\"color: #808030;\">).<\/span>grid<span style=\"color: #808030;\">(<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">,<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">9<\/span><span style=\"color: #808030;\">)<\/span>\r\n\r\n<span style=\"color: #696969;\">#AUS-<span style=\"color: #696969;\">Button-Layout<\/span><\/span>\r\nlabel_1 <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Label<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'Aus'<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">,<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">1<\/span><span style=\"color: #808030;\">)<\/span>\r\nButton_1a <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Button<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'LED 1'<\/span><span style=\"color: #808030;\">,<\/span> command <span style=\"color: #808030;\">=<\/span> button_1a<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">,<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">)<\/span>\r\nButton_2a <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Button<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'LED 2'<\/span><span style=\"color: #808030;\">,<\/span> command <span style=\"color: #808030;\">=<\/span> button_2a<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">,<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">3<\/span><span style=\"color: #808030;\">)<\/span>\r\nButton_3a <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Button<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'LED 3'<\/span><span style=\"color: #808030;\">,<\/span> command <span style=\"color: #808030;\">=<\/span> button_3a<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">,<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">4<\/span><span style=\"color: #808030;\">)<\/span>\r\nButton_4a <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Button<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'LED 4'<\/span><span style=\"color: #808030;\">,<\/span> command <span style=\"color: #808030;\">=<\/span> button_4a<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">,<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">5<\/span><span style=\"color: #808030;\">)<\/span>\r\nButton_5a <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Button<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'LED 5'<\/span><span style=\"color: #808030;\">,<\/span> command <span style=\"color: #808030;\">=<\/span> button_5a<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">,<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">6<\/span><span style=\"color: #808030;\">)<\/span>\r\nButton_6a <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Button<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'LED 6'<\/span><span style=\"color: #808030;\">,<\/span> command <span style=\"color: #808030;\">=<\/span> button_6a<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">,<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">7<\/span><span style=\"color: #808030;\">)<\/span>\r\nButton_7a <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Button<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'LED 7'<\/span><span style=\"color: #808030;\">,<\/span> command <span style=\"color: #808030;\">=<\/span> button_7a<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">,<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">8<\/span><span style=\"color: #808030;\">)<\/span>\r\nButton_8a <span style=\"color: #808030;\">=<\/span> ttk<span style=\"color: #808030;\">.<\/span>Button<span style=\"color: #808030;\">(<\/span>mainWin<span style=\"color: #808030;\">,<\/span> text<span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">'LED 8'<\/span><span style=\"color: #808030;\">,<\/span> command <span style=\"color: #808030;\">=<\/span> button_8a<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>grid<span style=\"color: #808030;\">(<\/span>column<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">,<\/span>row<span style=\"color: #808030;\">=<\/span><span style=\"color: #008c00;\">9<\/span><span style=\"color: #808030;\">)\r\n<\/span>\r\nmainWin.mainloop<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)\r\n\r\n<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In diesem Beitrag\u00a0wollen wir zeigen wie man die I2C-Module mit Python ansteuern kann. Als Visualisierung bzw. zum Bedienen wird TkInter benutzt. &nbsp; Ausg\u00e4nge\u00a0vom I2HA-Modul mit Button-Tasten EIN und AUS schalten Unsere Demo-Bedienoberfl\u00e4che hat acht EIN- und acht AUS-Tasten. Diese werden&#8230; <a class=\"continue-reading-link\" href=\"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/\">mehr lesen<\/a><\/p>\n","protected":false},"author":3,"featured_media":1228,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[254],"tags":[277,7,114,161,108],"class_list":["post-1090","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-digitale-ausgaenge","tag-i2c","tag-i2c-bus","tag-python","tag-raspberry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>I2C-Digital-Output-Modul mit Python und TkInter am Raspberry - Horter &amp; Kalb Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"I2C-Digital-Output-Modul mit Python und TkInter am Raspberry - Horter &amp; Kalb Blog\" \/>\n<meta property=\"og:description\" content=\"In diesem Beitrag\u00a0wollen wir zeigen wie man die I2C-Module mit Python ansteuern kann. Als Visualisierung bzw. zum Bedienen wird TkInter benutzt. &nbsp; Ausg\u00e4nge\u00a0vom I2HA-Modul mit Button-Tasten EIN und AUS schalten Unsere Demo-Bedienoberfl\u00e4che hat acht EIN- und acht AUS-Tasten. Diese werden... mehr lesen\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/\" \/>\n<meta property=\"og:site_name\" content=\"Horter &amp; Kalb Blog\" \/>\n<meta property=\"article:published_time\" content=\"2015-12-29T12:09:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-14T18:33:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_DigOut.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"173\" \/>\n\t<meta property=\"og:image:height\" content=\"259\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"JH\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Verfasst von\" \/>\n\t<meta name=\"twitter:data1\" content=\"JH\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"4\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/\"},\"author\":{\"name\":\"JH\",\"@id\":\"https:\/\/www.horter.de\/blog\/#\/schema\/person\/a8a4c3c5d3167dce7c7d31df6088b5d2\"},\"headline\":\"I2C-Digital-Output-Modul mit Python und TkInter am Raspberry\",\"datePublished\":\"2015-12-29T12:09:48+00:00\",\"dateModified\":\"2023-01-14T18:33:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/\"},\"wordCount\":367,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/www.horter.de\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_DigOut.jpg\",\"keywords\":[\"Digitale Ausg\u00e4nge\",\"I2C\",\"I2C-Bus\",\"Python\",\"Raspberry\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/\",\"url\":\"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/\",\"name\":\"I2C-Digital-Output-Modul mit Python und TkInter am Raspberry - Horter &amp; Kalb Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.horter.de\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_DigOut.jpg\",\"datePublished\":\"2015-12-29T12:09:48+00:00\",\"dateModified\":\"2023-01-14T18:33:08+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/#primaryimage\",\"url\":\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_DigOut.jpg\",\"contentUrl\":\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_DigOut.jpg\",\"width\":173,\"height\":259,\"caption\":\"I2C-Output Modul mit Tasten steuern\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Start\",\"item\":\"https:\/\/www.horter.de\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"I2C-Digital-Output-Modul mit Python und TkInter am Raspberry\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.horter.de\/blog\/#website\",\"url\":\"https:\/\/www.horter.de\/blog\/\",\"name\":\"Horter & Kalb Blog\",\"description\":\"SPS, I2C und mehr\",\"publisher\":{\"@id\":\"https:\/\/www.horter.de\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.horter.de\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"de\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.horter.de\/blog\/#organization\",\"name\":\"Horter & Kalb Blog\",\"url\":\"https:\/\/www.horter.de\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/www.horter.de\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2026\/01\/hoka_Icon_400x400.png\",\"contentUrl\":\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2026\/01\/hoka_Icon_400x400.png\",\"width\":400,\"height\":400,\"caption\":\"Horter & Kalb Blog\"},\"image\":{\"@id\":\"https:\/\/www.horter.de\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.horter.de\/blog\/#\/schema\/person\/a8a4c3c5d3167dce7c7d31df6088b5d2\",\"name\":\"JH\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/www.horter.de\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2015\/07\/jhfb.jpg\",\"contentUrl\":\"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2015\/07\/jhfb.jpg\",\"caption\":\"JH\"},\"url\":\"https:\/\/www.horter.de\/blog\/author\/j-horter\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"I2C-Digital-Output-Modul mit Python und TkInter am Raspberry - Horter &amp; Kalb Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/","og_locale":"de_DE","og_type":"article","og_title":"I2C-Digital-Output-Modul mit Python und TkInter am Raspberry - Horter &amp; Kalb Blog","og_description":"In diesem Beitrag\u00a0wollen wir zeigen wie man die I2C-Module mit Python ansteuern kann. Als Visualisierung bzw. zum Bedienen wird TkInter benutzt. &nbsp; Ausg\u00e4nge\u00a0vom I2HA-Modul mit Button-Tasten EIN und AUS schalten Unsere Demo-Bedienoberfl\u00e4che hat acht EIN- und acht AUS-Tasten. Diese werden... mehr lesen","og_url":"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/","og_site_name":"Horter &amp; Kalb Blog","article_published_time":"2015-12-29T12:09:48+00:00","article_modified_time":"2023-01-14T18:33:08+00:00","og_image":[{"width":173,"height":259,"url":"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_DigOut.jpg","type":"image\/jpeg"}],"author":"JH","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"JH","Gesch\u00e4tzte Lesezeit":"4\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/#article","isPartOf":{"@id":"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/"},"author":{"name":"JH","@id":"https:\/\/www.horter.de\/blog\/#\/schema\/person\/a8a4c3c5d3167dce7c7d31df6088b5d2"},"headline":"I2C-Digital-Output-Modul mit Python und TkInter am Raspberry","datePublished":"2015-12-29T12:09:48+00:00","dateModified":"2023-01-14T18:33:08+00:00","mainEntityOfPage":{"@id":"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/"},"wordCount":367,"commentCount":1,"publisher":{"@id":"https:\/\/www.horter.de\/blog\/#organization"},"image":{"@id":"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/#primaryimage"},"thumbnailUrl":"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_DigOut.jpg","keywords":["Digitale Ausg\u00e4nge","I2C","I2C-Bus","Python","Raspberry"],"articleSection":["Python"],"inLanguage":"de","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/","url":"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/","name":"I2C-Digital-Output-Modul mit Python und TkInter am Raspberry - Horter &amp; Kalb Blog","isPartOf":{"@id":"https:\/\/www.horter.de\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/#primaryimage"},"image":{"@id":"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/#primaryimage"},"thumbnailUrl":"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_DigOut.jpg","datePublished":"2015-12-29T12:09:48+00:00","dateModified":"2023-01-14T18:33:08+00:00","breadcrumb":{"@id":"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/"]}]},{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/#primaryimage","url":"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_DigOut.jpg","contentUrl":"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2016\/04\/PythonTkInter_DigOut.jpg","width":173,"height":259,"caption":"I2C-Output Modul mit Tasten steuern"},{"@type":"BreadcrumbList","@id":"https:\/\/www.horter.de\/blog\/i2c-module-mit-python-und-tkinter-auf-raspberry-py\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Start","item":"https:\/\/www.horter.de\/blog\/"},{"@type":"ListItem","position":2,"name":"I2C-Digital-Output-Modul mit Python und TkInter am Raspberry"}]},{"@type":"WebSite","@id":"https:\/\/www.horter.de\/blog\/#website","url":"https:\/\/www.horter.de\/blog\/","name":"Horter & Kalb Blog","description":"SPS, I2C und mehr","publisher":{"@id":"https:\/\/www.horter.de\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.horter.de\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"de"},{"@type":"Organization","@id":"https:\/\/www.horter.de\/blog\/#organization","name":"Horter & Kalb Blog","url":"https:\/\/www.horter.de\/blog\/","logo":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/www.horter.de\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2026\/01\/hoka_Icon_400x400.png","contentUrl":"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2026\/01\/hoka_Icon_400x400.png","width":400,"height":400,"caption":"Horter & Kalb Blog"},"image":{"@id":"https:\/\/www.horter.de\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.horter.de\/blog\/#\/schema\/person\/a8a4c3c5d3167dce7c7d31df6088b5d2","name":"JH","image":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/www.horter.de\/blog\/#\/schema\/person\/image\/","url":"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2015\/07\/jhfb.jpg","contentUrl":"https:\/\/www.horter.de\/blog\/wp-content\/uploads\/2015\/07\/jhfb.jpg","caption":"JH"},"url":"https:\/\/www.horter.de\/blog\/author\/j-horter\/"}]}},"_links":{"self":[{"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/posts\/1090","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/comments?post=1090"}],"version-history":[{"count":29,"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/posts\/1090\/revisions"}],"predecessor-version":[{"id":28287,"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/posts\/1090\/revisions\/28287"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/media\/1228"}],"wp:attachment":[{"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/media?parent=1090"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/categories?post=1090"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.horter.de\/blog\/wp-json\/wp\/v2\/tags?post=1090"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}