{"id":10,"date":"2015-10-31T18:50:14","date_gmt":"2015-10-31T17:50:14","guid":{"rendered":"http:\/\/schnasseldag.lima-city.de\/wordpress\/?page_id=10"},"modified":"2015-11-13T09:18:38","modified_gmt":"2015-11-13T08:18:38","slug":"meine-3-seite","status":"publish","type":"page","link":"https:\/\/schnasseldag.lima-city.de\/wordpress\/meine-3-seite\/","title":{"rendered":"Meine 3. Seite"},"content":{"rendered":"<p>Das ist meine 3. Seite.<\/p>\n<p>Analoges Lesen<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n#!\/usr\/bin\/python\r\nimport spidev\r\nimport time\r\n# Hubo MCP3208 Demo - simple reading of the MCP3208 analog input.\r\ndef Open_SPI_ADC ():\r\n    spiADC = spidev.SpiDev()\r\n    spiADC.open(0, 0)\r\n    spiADC.max_speed_hz = (50000)\r\n    return spiADC\r\n    \r\ndef Get_AI_Channel (spiADC, channel):\r\n    if ((channel &gt; 7) or (channel &lt; 0)): print 'Illegal channel number (0 through 7)' return 0.0 result = spiADC.xfer2([6 + (channel &gt;&gt; 2), channel &lt;&lt; 6, 0])\r\n    count = ((result[1] &amp; 0x0F) &lt;&lt; 8) + (result[2])\r\n    # Use a reference voltage of 2.53V.\r\n    voltage = (2.53 * count) \/ 4096\r\n    return voltage\r\n    \r\n# Read 10 values from analog input 0.\r\nspiADC = Open_SPI_ADC()\r\nfor i in range(0, 9):\r\n    print Get_AI_Channel (spiADC, 0)\r\n    time.sleep(1)\r\nspiADC.close();\r\n<\/pre>\n<p>Digitales Lesen und Schreiben<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n#!\/usr\/bin\/python\r\nimport smbus\r\nimport time\r\n# Hubo MCP23017 Demo - simple reading and writing of the MCP23017 digital IO.\r\nIODIRA = 0x00\r\nIODIRB = 0x01\r\nGPPUB  = 0x0D\r\nGPIOA  = 0x12\r\nGPIOB  = 0x13\r\nglobal g_ioaddress\r\ng_ioaddress = 0x20  # I2C address - Hubo master modules use 0x20\r\ndef Initialize_MCP23017 ():\r\n    i2cbus = smbus.SMBus(1)                            # Use 1 for the model B variants.\r\n    i2cbus.write_byte_data (g_ioaddress, IODIRA, 0x00) # Configure port A as output\r\n    i2cbus.write_byte_data (g_ioaddress, IODIRB, 0xFF) # Configure port B as input\r\n    i2cbus.write_byte_data (g_ioaddress, GPPUB,  0xFF) # Activate  port B's internal pull up resistors\r\n    return i2cbus\r\n    \r\ndef Get_DI_Channels (i2cbus):\r\n    return i2cbus.read_byte_data(g_ioaddress, GPIOB)\r\ndef Set_DI_Channels (i2cbus, value):\r\n    return i2cbus.write_byte_data(g_ioaddress, GPIOA, value)\r\n    \r\n    \r\n# Read values from the digital input port and output the value on the digital output port.\r\ni2cbus = Initialize_MCP23017()\r\nwhile True:\r\n    value = Get_DI_Channels (i2cbus)\r\n    Set_DI_Channels(i2cbus, value)\r\n    print value\r\n    time.sleep(0.1)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Das ist meine 3. Seite. Analoges Lesen Digitales Lesen und Schreiben<\/p>\n<p> <a class=\"continue-reading-link\" href=\"https:\/\/schnasseldag.lima-city.de\/wordpress\/meine-3-seite\/\"><span>Continue reading<\/span><i class=\"crycon-right-dir\"><\/i><\/a> <\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/schnasseldag.lima-city.de\/wordpress\/wp-json\/wp\/v2\/pages\/10"}],"collection":[{"href":"https:\/\/schnasseldag.lima-city.de\/wordpress\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/schnasseldag.lima-city.de\/wordpress\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/schnasseldag.lima-city.de\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/schnasseldag.lima-city.de\/wordpress\/wp-json\/wp\/v2\/comments?post=10"}],"version-history":[{"count":3,"href":"https:\/\/schnasseldag.lima-city.de\/wordpress\/wp-json\/wp\/v2\/pages\/10\/revisions"}],"predecessor-version":[{"id":69,"href":"https:\/\/schnasseldag.lima-city.de\/wordpress\/wp-json\/wp\/v2\/pages\/10\/revisions\/69"}],"wp:attachment":[{"href":"https:\/\/schnasseldag.lima-city.de\/wordpress\/wp-json\/wp\/v2\/media?parent=10"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}