{"id":23194,"date":"2023-05-24T00:00:58","date_gmt":"2023-05-23T16:00:58","guid":{"rendered":"https:\/\/techclass.wfjydl.com\/?p=23194"},"modified":"2026-04-27T15:26:41","modified_gmt":"2026-04-27T07:26:41","slug":"%e4%bd%bf%e7%94%a8raspberry-pi%e5%88%b6%e4%bd%9c%e5%92%96%e5%95%a1%e6%9c%ba%e6%8e%a7%e5%88%b6%e8%a3%85%e7%bd%ae-%e7%ac%ac3%e9%83%a8%e5%88%86%ef%bc%9a%e4%bd%bf%e7%94%a8python%e5%ae%8c%e6%88%90","status":"publish","type":"post","link":"https:\/\/techclass.wfjydl.com\/knowledge\/hobby\/coffee-maker-with-raspberry-pi-03\/","title":{"rendered":"\u4f7f\u7528Raspberry Pi\u5236\u4f5c\u5496\u5561\u673a\u63a7\u5236\u88c5\u7f6e  \u7b2c3\u90e8\u5206\uff1a\u4f7f\u7528Python\u5b8c\u6210\u63a7\u5236\u8f6f\u4ef6"},"content":{"rendered":"<p>\u7b2c1\u90e8\u5206\uff1a<a href=\"https:\/\/techclass.wfjydl.com\/knowledge\/tech-info\/raspberry\/coffee-maker-with-raspberry-pi-01\">\u88c5\u7f6e\u6982\u51b5\u548c\u5496\u5561\u8403\u53d6<\/a><br \/>\n\u7b2c2\u90e8\u5206\uff1a<a href=\"https:\/\/techclass.wfjydl.com\/knowledge\/tech-info\/raspberry\/coffee-maker-with-raspberry-pi-02\">\u786c\u4ef6\u5236\u4f5c<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>\u672c\u7cfb\u5217\u8fde\u8f7d\u5c06\u4e3a\u60a8\u4ecb\u7ecd\u4f7f\u7528Raspberry Pi\u5236\u4f5c\u5496\u5561\u673a\u63a7\u5236\u88c5\u7f6e\u7684\u65b9\u6cd5\u3002\u672c\u7cfb\u5217\u4e3a\u6211\u4eec\u5206\u4eab\u7684\u5609\u5bbe\u662f\u963f\u77e2\u8c37\u5145\u5148\u751f\uff0c\u4ed6\u8fc4\u4eca\u4e3a\u6b62\u5728\u5404\u79cd\u5a92\u4f53\u4e0a\uff0c\u9762\u5411\u559c\u6b22\u81ea\u5df1\u52a8\u624b\u5236\u4f5c\u7684\u7fa4\u4f53\u53d1\u8868\u8fc7\u5f88\u591a\u7535\u5b50\u4f5c\u54c1\u5236\u4f5c\u7c7b\u7684\u6587\u7ae0\u3002\u5728\u8fde\u8f7d\u7684<a href=\"https:\/\/techclass.wfjydl.com\/knowledge\/tech-info\/raspberry\/coffee-maker-with-raspberry-pi-01\">\u7b2c1\u90e8\u5206<\/a>\u4e2d\uff0c\u4ecb\u7ecd\u4e86\u88c5\u7f6e\u7684\u6982\u51b5\uff1b\u5728<a href=\"https:\/\/techclass.wfjydl.com\/knowledge\/tech-info\/raspberry\/coffee-maker-with-raspberry-pi-02\">\u7b2c2\u90e8\u5206<\/a>\u4e2d\uff0c\u4ecb\u7ecd\u4e86\u786c\u4ef6\u7684\u5236\u4f5c\u548c\u5b89\u88c5\u65b9\u6cd5\uff1b\u5728\u7b2c3\u90e8\u5206\u4e2d\uff0c\u5c06\u4e3a\u60a8\u4ecb\u7ecd\u63a7\u5236\u7a0b\u5e8f\u7684\u7f16\u5199\u65b9\u6cd5\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-28386\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2026\/04\/coffee-maker-with-raspberry-pi-03-01.jpg\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2026\/04\/coffee-maker-with-raspberry-pi-03-01.jpg 750w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2026\/04\/coffee-maker-with-raspberry-pi-03-01.jpg 300w\" alt=\"coffee-maker-with-raspberry-pi-03-01\" width=\"750\" height=\"351\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>\u76ee\u5f55<\/h2>\n<ol>\n<li><a href=\"#01\">\u73af\u5883\u8bbe\u7f6e<\/a><\/li>\n<li><a href=\"#02\">Python\u7684\u5f00\u53d1\u548c\u8fd0\u884c\u73af\u5883<\/a><\/li>\n<li><a href=\"#03\">I2C\u6db2\u6676\u5de5\u4f5c\u786e\u8ba4\u6a21\u5757<\/a><\/li>\n<li><a href=\"#04\">\u5496\u5561\u673a\u63a7\u5236\u4e3b\u7a0b\u5e8f\uff08\u6574\u4f53\u7ed3\u6784\uff09<\/a><\/li>\n<li><a href=\"#05\">\u4f7f\u7528Python\u5b8c\u6210\u63a7\u5236\u7a0b\u5e8f<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h2 id=\"01\">1.\u73af\u5883\u8bbe\u7f6e<\/h2>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u6765\u4e86\u89e3\u4e00\u4e0b\u8fd0\u884c\u73af\u5883\u3002\u64cd\u4f5c\u7cfb\u7edf\u662fRaspberry Pi\u6807\u51c6\u7684Raspbian\uff0c\u6211\u4f7f\u7528\u7684\u662fRelease10\uff1abuster\u3002\u5728\u8fd9\u91cc\u6211\u4eec\u4e0d\u4f1a\u6d89\u53ca\u5b83\u4eec\u7684\u5b89\u88c5\u65b9\u6cd5\u3002<\/p>\n<p>\u5148\u4e3a\u60a8\u4ecb\u7ecd\u5fc5\u8981\u7684\u8bbe\u7f6e\u3002\u901a\u8fc7\u83dc\u5355\u6253\u5f00\u201cRaspberry pi\u8bbe\u7f6e\u201d\u9875\u9762\uff0c\u70b9\u5f00\u201c\u63a5\u53e3\u201d\u9009\u9879\u5361\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-28385\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2023\/05\/coffee-maker-with-raspberry-pi-03-02.png\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2023\/05\/coffee-maker-with-raspberry-pi-03-02.png 750w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2023\/05\/coffee-maker-with-raspberry-pi-03-02-300x154.png 300w\" alt=\"coffee-maker-with-raspberry-pi-03-02\" width=\"750\" height=\"385\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u8fd9\u91cc\u5fc5\u987b\u542f\u7528\u7684\u9879\u76ee\u662fSSH\u3001VNC\u548cI2C\u3002\u6b64\u6b21\u5236\u4f5c\u7684\u88c5\u7f6e\u4e2d\u6ca1\u6709\u4f7f\u7528SPI\uff0c\u4f46\u56e0\u5176\u662f\u4e00\u4e2a\u50cfI2C\u4e00\u6837\u5e38\u7528\u7684\u5916\u90e8\u63a5\u53e3\uff0c\u6240\u4ee5\u6211\u5c06\u5176\u8bbe\u4e3a\u201c\u542f\u7528\u201d\u72b6\u6001\u3002\u4e32\u884c\u7aef\u53e3\u548c\u4e32\u884c\u63a7\u5236\u53f0\u4e5f\u4e0d\u4f1a\u7528\u5230\uff0c\u4f46\u56e0\u4e3a\u5b83\u4eec\u53ef\u5728\u53d1\u751fWi-Fi\u7b49\u6545\u969c\u65f6\u7528\u6765\u8fdb\u884c\u8bbe\u7f6e\uff0c\u6240\u4ee5\u6211\u4e5f\u5c06\u5b83\u4eec\u8bbe\u4e3a\u201c\u542f\u7528\u201d\u4e86\u3002<\/p>\n<p>\u5173\u4e8eSSH\u548cVNC\uff0c\u7531\u4e8e\u672c\u88c5\u7f6e\u4e00\u65e6\u5c06\u96f6\u90e8\u4ef6\u6536\u7eb3\u8fdb\u5916\u58f3\u540e\uff0c\u5c31\u65e0\u6cd5\u518d\u63a5\u5165HDMI\u7b49\u5916\u90e8\u7aef\u53e3\uff0c\u56e0\u6b64\uff0c\u5b83\u4eec\u5bf9\u4e8e\u901a\u8fc7\u8fdc\u7a0b\u8fdb\u884c\u6240\u6709\u8bbe\u7f6e\u800c\u8a00\u81f3\u5173\u91cd\u8981\u3002VNC\u9700\u8981\u5728PC\u7aef\u6216Mac\u7aef\u5b89\u88c5\u201cVNC Viewer\u201d\u7b49\u5ba2\u6237\u7aef\u8f6f\u4ef6\uff0c\u6240\u4ee5\u8bf7\u5b89\u88c5\u6240\u9700\u8f6f\u4ef6\u3002\u8981\u60f3\u901a\u8fc7VNC\u8fdb\u884c\u8fdc\u7a0b\u64cd\u4f5c\uff0c\u5f53\u7136\u9700\u8981\u901a\u8fc7Wi-Fi\u8fdb\u884cIP\u8fde\u63a5\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2 id=\"02\">2.Python\u7684\u5f00\u53d1\u548c\u8fd0\u884c\u73af\u5883<\/h2>\n<p>\u6211\u4f7f\u7528\u201cPython\u201d\u4f5c\u4e3a\u63a7\u5236\u8f6f\u4ef6\uff0c\u5e76\u9009\u62e9\u4e86\u6700\u5e38\u7528\u7684RPi.GPIO\u5e93\u6765\u63a7\u5236GPIO\u3002\u5173\u4e8e\u8fd9\u4e2aRPi.GPIO\u7684\u57fa\u7840\u77e5\u8bc6\uff0c\u8bf7\u53c2\u8003Dvice Plus\u66fe\u7ecf\u53d1\u8868\u8fc7\u7684\u4e00\u7bc7\u975e\u5e38\u901a\u4fd7\u6613\u61c2\u7684\u4ecb\u7ecd\u6587\u7ae0\u300a\u901a\u8fc7RPi.GPIO Python\u5e93\u4f7f\u7528Raspberry Pi GPIO\u5f15\u811a\u300b\u3002<\/p>\n<p><a href=\"https:\/\/techclass.wfjydl.com\/knowledge\/tech-info\/how-tos\/raspberry\/using-raspberry-pi-gpio-pins-with-the-rpi-gpio-python-library\">\u901a\u8fc7RPi.GPIO Python\u5e93\u4f7f\u7528Raspberry Pi GPIO\u5f15\u811a<\/a><\/p>\n<p>\u5982\u679c\u60a8\u8fd8\u4e0d\u4e86\u89e3RPi.GPIO\uff0c\u5efa\u8bae\u60a8\u52a1\u5fc5\u5148\u9605\u8bfb\u6b64\u6587\u3002<\/p>\n<p>\u4f7f\u7528Python\u5f00\u53d1Raspberry Pi\u7528\u7684\u7a0b\u5e8f\u65f6\uff0c\u65b9\u6cd5\u6709\u5f88\u591a\u3002\u7f16\u5199\u6e90\u4ee3\u7801\u65f6\uff0c\u4e5f\u6709\u591a\u79cd\u65b9\u6cd5\u53ef\u9009\uff0c\u6bd4\u5982\u662f\u5728Raspberry Pi\u7aef\u7f16\u5199\u8fd8\u662f\u5728PC\u6216Mac\u4e0a\u4f7f\u7528\u719f\u6089\u7684\u7f16\u8f91\u5668\u7f16\u5199\u3002<\/p>\n<p>\u6b64\u6b21\uff0c\u6211\u5c1d\u8bd5\u4f7f\u7528\u4e86\u4e00\u4e2a\u5728Raspberry Pi\u4e0a\u8fd0\u884c\u7684\u540d\u4e3a\u201cThonny\u201d\u7684\u8f6f\u4ef6\u3002Thonny\u662f\u4e00\u4e2a\u96c6\u6210\u4e86\u7f16\u8f91\u5668\u3001\u6267\u884c\u73af\u5883\u548c\u8c03\u8bd5\u73af\u5883\u7684IDE\uff08\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff09\u3002Thonny\u5728Raspbian\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u5df2\u7ecf\u9ed8\u8ba4\u5b89\u88c5\u597d\u4e86\uff0c\u5c5e\u4e8e\u5f00\u7bb1\u5373\u7528\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u901a\u8fc7\u83dc\u5355\u76f4\u63a5\u8c03\u7528\u3002Thonny\u7684GUI\u5982\u4e0b\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-28384\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2023\/05\/coffee-maker-with-raspberry-pi-03-03.png\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2023\/05\/coffee-maker-with-raspberry-pi-03-03.png 750w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2023\/05\/coffee-maker-with-raspberry-pi-03-03-300x203.png 300w\" alt=\"coffee-maker-with-raspberry-pi-03-03\" width=\"750\" height=\"508\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u9996\u5148\uff0c\u5173\u4e8e\u7f16\u8f91\u5668\uff0cThonny\u662fPython\u4e13\u7528\u7684\u8f6f\u4ef6\uff0c\u5177\u6709\u91cd\u8981\u7684\u7f29\u8fdb\u529f\u80fd\uff0c\u4f1a\u81ea\u52a8\u7f29\u8fdb\uff0c\u53ef\u4ee5\u653e\u5fc3\u4f7f\u7528\u3002\u8fd8\u6709\uff0c\u4fdd\u7559\u5b57\u662f\u7528\u4e0d\u540c\u989c\u8272\u533a\u5206\u7684\uff0cCTRL+Space\u652f\u6301\u81ea\u52a8\u8865\u5168\uff08\u663e\u793a\u4fdd\u7559\u5b57\u5019\u9009\uff09\uff0c\u7528\u8d77\u6765\u975e\u5e38\u65b9\u4fbf\u3002<\/p>\n<p>Thonny\u8fd8\u914d\u6709\u8c03\u8bd5\u5668\uff0c\u53ef\u4ee5\u5355\u6b65\u6267\u884c\u548c\u663e\u793a\u53d8\u91cf\u7684\u503c\u3002Thonny\u7684\u529f\u80fd\u4ec5\u9650\u4e8e\u521d\u5b66\u8005\u7684\u57fa\u672c\u9700\u8981\uff0c\u6240\u4ee5\u4f7f\u7528\u65b9\u6cd5\u5f88\u7b80\u5355\uff0c\u4e0d\u8fc7\u6211\u8ba4\u4e3a\u5b83\u8db3\u4ee5\u5e94\u5bf9\u4e2d\u5c0f\u578b\u7a0b\u5e8f\u7684\u9700\u6c42\u3002<\/p>\n<p>\u6211\u662f\u7528VNC\u8fde\u63a5Raspberry Pi\u4e0a\u7684Thonny\u6765\u7f16\u8f91\u548c\u8fd0\u884c\u7a0b\u5e8f\u7684\u3002\u7528VNC\u8fde\u63a5\u540e\uff0cRaspbian\u7684GUI\u53ea\u662f\u865a\u62df\u7684\uff0c\u56e0\u6b64\u5373\u4f7f\u60a8\u65ad\u5f00\u8fde\u63a5\uff0c\u6b63\u5728\u6267\u884c\u7684\u4efb\u52a1\u548c\u73af\u5883\u4e5f\u4f1a\u7ee7\u7eed\u4fdd\u6301\u3002\u672c\u88c5\u7f6e\u7684Python\u63a7\u5236\u7a0b\u5e8f\u4e5f\u662f\u901a\u8fc7Thonny\u6267\u884c\u7684\uff0c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u3002<\/p>\n<p>\u5173\u4e8eRaspberry Pi\u7684VNC\u8fde\u63a5\uff0c\u8bf7\u53c2\u8003\u4ee5\u4e0b\u94fe\u63a5\u4e2d\u4ecb\u7ecd\u7684\u8be6\u7ec6\u8bbe\u7f6e\u65b9\u6cd5\u3002<\/p>\n<p><a href=\"https:\/\/www.indoorcorgielec.com\/resources\/raspberry-pi\/raspberry-pi-vnc\/\" target=\"_blank\" rel=\"noopener\">VNC\u8fdc\u7a0b\u684c\u9762\u8fde\u63a5Raspberry Pi\uff08\u517c\u5bb9Windows\/Mac\/Linux\uff09<\/a><\/p>\n<p>&nbsp;<\/p>\n<h2 id=\"03\">3.I2C\u6db2\u6676\u5de5\u4f5c\u786e\u8ba4\u6a21\u5757<\/h2>\n<p>\u5728\u7b2c2\u90e8\u5206\u4e2d\uff0c\u6211\u4eec\u4e86\u89e3\u4e86\u786c\u4ef6\u76f8\u5173\u7684\u5185\u5bb9\uff0c\u5728\u8fd9\u91cc\u6211\u4eec\u5148\u6765\u786e\u8ba4\u4e00\u4e0bI2C\u6db2\u6676\u7684\u5de5\u4f5c\u60c5\u51b5\u3002\u6d4b\u8bd5\u662f\u4f7f\u7528Raspberry Pi\u547d\u4ee4\u548c\u901a\u8fc7Python\u7f16\u5199\u7684\u7a0b\u5e8f\u8fdb\u884c\u7684\u3002\u53e6\u5916\uff0c\u7531\u4e8e\u8be5\u6d4b\u8bd5\u7a0b\u5e8f\u662f\u6a21\u5757\u5316\u7684\uff0c\u56e0\u6b64\u53ef\u4ee5\u901a\u8fc7\u5496\u5561\u673a\u63a7\u5236\u7a0b\u5e8f\u6765\u5bfc\u5165\u548c\u4f7f\u7528\u3002<\/p>\n<p>\u9996\u5148\uff0c\u4f7f\u7528Raspberry Pi\u547d\u4ee4\u786e\u8ba4I2C\u7684\u8fde\u63a5\u662f\u5426\u6b63\u5e38\u3002\u901a\u8fc7Raspbian\u4e0a\u7684LXTerminal\u6216\u901a\u8fc7SSH\u8fde\u63a5\u7684\u7ec8\u7aef\u4e0a\u7684shell\u8f93\u5165\u201ci2cdetect -y 1\u201d\u547d\u4ee4\u3002<\/p>\n<pre class=\"brush: cpp; title: Code-Example; notranslate\" title=\"Code-Example\">pi@raspberrypi:~ $ i2cdetect -y 1\r\n     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f\r\n00:          -- -- -- -- -- -- -- -- -- -- -- -- -- \r\n10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \r\n20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \r\n30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 3e -- \r\n40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \r\n50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \r\n60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \r\n70: -- -- -- -- -- -- -- --\r\n<\/pre>\n<p>\u5982\u679cI2C\u8fde\u63a5\u6b63\u5e38\uff0c\u4f1a\u663e\u793aLCD\u6a21\u5757\u7684\u5730\u5740\uff1a3e\u3002\u5982\u679c\u4e0d\u663e\u793a\uff0c\u9700\u8981\u68c0\u67e5\u4e00\u4e0b\u770b\u770b\u662f\u5426\u6709\u63a5\u7ebf\u9519\u8bef\u7b49\u95ee\u9898\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u4f7f\u7528Thonny\u521b\u5efa\u4ee5\u4e0b\u5de5\u4f5c\u786e\u8ba4\u6a21\u5757\u3002\u6211\u5728\/home\/pi\u4e0b\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a\u201cpython\u201d\u7684\u76ee\u5f55\uff0c\u7528\u6765\u4fdd\u5b58\u7a0b\u5e8f\uff0c\u8fd9\u65b9\u9762\u60a8\u53ef\u4ee5\u81ea\u7531\u51b3\u5b9a\u3002\u7a0b\u5e8f\u540d\u79f0\u4e3a\u201clcdtest_2x8.py\u201d\u3002<\/p>\n<pre class=\"brush: cpp; title: Code-Example; notranslate\" title=\"Code-Example\">import smbus\r\nimport time\r\n\r\ni2c = smbus.SMBus(1)\r\naddr = 0x3e\r\n\r\ndef initlcd():\r\n    data = [0x38, 0x39, 0x14, 0x78, 0x5f, 0x6a, 0x0c, 0x01, 0x06]\r\n    i2c.write_i2c_block_data(addr, 0, data)\r\n    time.slee p(0.3)\r\n\r\ndef write_data_to_lcd(upper,lower):\r\n    #write upper\r\n    i2c.write_byte_data(addr, 0, 0x80)\r\n    data1 =[\"\" for j in range(len(upper))]\r\n    for i in range(len(upper)):\r\n        data1[i] = ord(upper[i])\r\n    i2c.write_byte_data(addr, 0, 0x80)\r\n    i2c.write_i2c_block_data(addr, 0x40, data1)\r\n    #write lower\r\n    data2 =[\"\" for j in range(len(lower))]\r\n    for i in range(len(lower)):\r\n        data2[i] = ord(lower[i])\r\n    i2c.write_byte_data(addr, 0, 0xc0)\r\n    i2c.write_i2c_block_data(addr, 0x40, data2)\r\n\r\ndef clsc():\r\n    i2c.write_byte_data(addr, 0, 0x01)\r\n    time.slee p(0.3)\r\n\r\nif __name__ == '__main__':\r\n    initlcd()\r\n    write_data_to_lcd(\"line1\",\"line2\")\r\n    time.slee p(2)\r\n    clsc()\r\n    write_data_to_lcd(\"--LCD---\",\"**Test**\")\r\n    time.slee p(2)\r\n    clsc()\r\n    write_data_to_lcd(\"Test\",\"==end===\")\r\n<\/pre>\n<p>\u8fd0\u884c\u7a0b\u5e8f\uff0c\u5982\u679c\u7a0b\u5e8f\u6b63\u5e38\u5de5\u4f5c\uff0c\u4f1a\u5728\u6db2\u6676\u663e\u793a\u5c4f\u4e0a\u663e\u793a\u4e09\u4e2a\u6d4b\u8bd5\u4fe1\u606f\u3002\u8fd9\u4e2a\u7a0b\u5e8f\u4e2d\u5bfc\u5165\u4e86python\u7684I2C\u63a7\u5236\u7528\u7684\u201csmbus\u201d\u548c\u65f6\u95f4\u7528\u7684\u201ctime\u201d\u4e24\u4e2a\u6a21\u5757\u3002\u53e6\u5916\uff0c\u8fd8\u8bbe\u7f6e\u4e86\u4ee5\u4e0b\u4e09\u4e2a\u51fd\u6570\uff1a<\/p>\n<p><strong>initlcd()<\/strong>\u7528\u6765\u521d\u59cb\u5316LCD\u6a21\u5757\u3002\u8be5\u51fd\u6570\u5728\u7a0b\u5e8f\u5f00\u59cb\u65f6\u4f1a\u8fd0\u884c\u4e00\u6b21\uff0c\u53d1\u9001\u6a21\u5757\u4e2d\u4f7f\u7528\u7684\u201cAQM0802A\u201d\u82af\u7247\u7684\u63a7\u5236\u547d\u4ee4\u3002<\/p>\n<p><strong>write_data_to_lcd(upper,lower)<\/strong>\u7528\u6765\u5c06\u5b57\u7b26\u4e32\u5199\u5165LCD\u6a21\u5757\u3002\u8fd9\u4e2a\u7a0b\u5e8f\u7528\u4e8e8\u4e2a\u5b57\u7b26\u00d72\u884c\u7684LCD\uff0c\u53c2\u6570upper\u663e\u793a\u4e0a\u4e00\u884c\uff0c\u53c2\u6570upper\u663e\u793a\u4e0b\u4e00\u884c\u3002\u4f7f\u7528ord()\u51fd\u6570\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3aASCII\u7801\u5e76\u53d1\u9001\u7ed9\u6a21\u5757\u3002<\/p>\n<p><strong>clsc()<\/strong>\u7528\u6765\u6e05\u9664LCD\u663e\u793a\u3002\u5c06\u8fd9\u4e9b\u51fd\u6570\u4f5c\u4e3a\u6a21\u5757\u5bfc\u5165\u53e6\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u5373\u53ef\u5f15\u7528\u548c\u4f7f\u7528\u8fd9\u4e9b\u51fd\u6570\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2 id=\"04\">4. \u5496\u5561\u673a\u63a7\u5236\u4e3b\u7a0b\u5e8f\uff08\u6574\u4f53\u7ed3\u6784\uff09<\/h2>\n<p>\u9996\u5148\uff0c\u63a7\u5236\u7a0b\u5e8f\u7684\u6574\u4f53\u7ed3\u6784\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-28383\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2023\/05\/coffee-maker-with-raspberry-pi-03-04.png\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2023\/05\/coffee-maker-with-raspberry-pi-03-04.png 750w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2023\/05\/coffee-maker-with-raspberry-pi-03-04-300x169.png 300w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2023\/05\/coffee-maker-with-raspberry-pi-03-04-640x360.png 640w\" alt=\"coffee-maker-with-raspberry-pi-03-04\" width=\"750\" height=\"422\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u5de6\u4fa7\u7684\u84dd\u8272\u90e8\u5206\u662f\u5728\u5f00\u59cb\u65f6\u53ea\u8fd0\u884c\u4e00\u6b21\u7684\u521d\u59cb\u8bbe\u7f6e\u6a21\u5757\u3002\u7eff\u8272\u90e8\u5206\u662f\u4e0e\u786e\u5b9a\u676f\u6570\u7684\u4e2d\u65ad\u4f8b\u7a0b\u76f8\u5173\u7684\u6a21\u5757\u3002\u8fd9\u4e5f\u5c31\u662f\u5728\u7b2c2\u90e8\u5206\u4e2d\u63d0\u5230\u7684\u786c\u4ef6\u2014\u2014\u9ed1\u8272\u5fae\u52a8\u5f00\u5173\u6309\u94ae\uff0c\u901a\u8fc7\u5b83\u6765\u51b3\u5b9a\u8981\u8403\u53d6\u591a\u5c11\u676f\u5496\u5561\u3002\u6bcf\u6309\u4e00\u6b21\u5f00\u5173\uff0c\u5c31\u4f1a\u901a\u8fc7\u4e2d\u65ad\u5904\u7406\u66f4\u6539\u676f\u6570\u3002<\/p>\n<p>\u53f3\u4fa7\u7684\u6a59\u8272\u90e8\u5206\u662f\u4e3b\u4f8b\u7a0b\u3002\u9996\u5148\u662f\u7b49\u5f85\u542f\u52a8\u6309\u94ae\uff08\u7ea2\u8272\u5fae\u52a8\u5f00\u5173\uff09\u8f93\u5165\uff0c\u7136\u540e\u662f\u7531\u7b2c\u4e00\u6b65\u3001\u7b2c\u4e8c\u6b65\u3001\u7b2c\u4e09\u6b65\u7ec4\u6210\u7684\u5b9a\u65f6\u5668\u5faa\u73af\u3002<\/p>\n<p>\u7b2c\u4e00\u6b65\u662f\u201c\u521d\u6b21\u6ce8\u6c34\u201d\u3002\u5728\u8fdb\u5165\u7b2c\u4e8c\u6b65\u201c\u95f7\u84b8\u201d\u4e4b\u524d\uff0c\u8ba9\u70ed\u6c34\u6d78\u6da6\u5496\u5561\u7c89\u3002\u5496\u5561\u673a\u5c06\u53ea\u5728\u8fd9\u4e2a\u8bbe\u7f6e\u65f6\u95f4\u5185\u5904\u4e8eON\uff08\u901a\u7535\uff09\u72b6\u6001\u3002<br \/>\n\u7b2c\u4e8c\u6b65\u662f\u201c\u95f7\u84b8\u201d\u3002\u70ed\u6c34\u6d78\u6da6\u5496\u5561\u7c89\u540e\uff0c\u4fdd\u6301\u4e00\u6bb5\u65f6\u95f4\u3002\u6b64\u65f6\uff0c\u5496\u5561\u673a\u5904\u4e8eOFF\uff08\u65ad\u7535\uff09\u72b6\u6001\u3002<br \/>\n\u7b2c\u4e09\u6b65\u662f\u201c\u8403\u53d6\u201d\u3002\u6b64\u65f6\uff0c\u5496\u5561\u673a\u57fa\u672c\u4e0a\u662fON\uff08\u901a\u7535\uff09\u72b6\u6001\u3002\u4f5c\u4e3a\u9644\u52a0\u529f\u80fd\uff0c\u6211\u589e\u52a0\u4e86\u57fa\u4e8ePWM\u7684ON\/OFF\u63a7\u5236\u529f\u80fd\u3002\u8fd9\u53ef\u4ee5\u5206\u522b\u8bbe\u7f6e\u5496\u5561\u673aON\u7684\u65f6\u95f4\uff08\u79d2\uff09\u548cOFF\u7684\u65f6\u95f4\uff08\u79d2\uff09\u3002\u6211\u5e0c\u671b\u7528\u8fd9\u4e2a\u529f\u80fd\u5c1d\u8bd5\u901a\u8fc7\u8f6f\u4ef6\u5b9e\u73b0\u4e00\u79cd\u53eb\u505a\u201c\u8282\u594f\u8403\u53d6\u201d\uff08\u52a0\u5165\u4e00\u5b9a\u91cf\u7684\u70ed\u6c34\u7136\u540e\u6682\u505c\uff0c\u53cd\u590d\u6b64\u64cd\u4f5c\uff09\u7684\u65b9\u6cd5\u3002\u5173\u4e8ePWM\u529f\u80fd\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u5c06\u5728python\u7a0b\u5e8f\u4ecb\u7ecd\u90e8\u5206\u4e2d\u8fdb\u884c\u8bf4\u660e\u3002<\/p>\n<p>\u4e0b\u88681\u4e2d\u6c47\u603b\u4e86\u4e0a\u8ff0\u8bbe\u7f6e\u53c2\u6570\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-28382\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2023\/05\/coffee-maker-with-raspberry-pi-03-05.png\" sizes=\"auto, (max-width: 575px) 100vw, 575px\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2023\/05\/coffee-maker-with-raspberry-pi-03-05.png 575w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2023\/05\/coffee-maker-with-raspberry-pi-03-05-300x115.png 300w\" alt=\"coffee-maker-with-raspberry-pi-03-05\" width=\"575\" height=\"221\" \/><\/p>\n<p class=\"wp-caption-text\">\u88681 \u8bbe\u7f6e\u53c2\u6570\u4e00\u89c8\u8868<\/p>\n<p>&nbsp;<\/p>\n<p>\u8bbe\u7f6e\u65f6\u95f4\u5355\u4f4d\u4e3a\u201c\u79d2\u201d\u3002\u6b64\u6b21\u4f7f\u7528\u7684\u5496\u5561\u673a\u4e3aKalita ET-102\uff0c\u6700\u5927\u5bb9\u91cf\u4e3a5\u676f\u3002\u6211\u8ba9\u8be5\u7a0b\u5e8f\u6700\u591a\u5141\u8bb8\u8bbe\u7f6e6\u676f\uff0c\u8bbe\u7f6e\u4e3a6\u676f\u65f6\uff0c\u662f\u5c06\u95f7\u84b8\u65f6\u95f4\u8bbe\u7f6e\u4e3a\u201c0\u201d\uff0c\u5feb\u901f\u51b2\u6ce1\u5496\u5561\u7684\u201c\u6700\u5feb\u6a21\u5f0f\u201d\u3002<\/p>\n<p>\u76ee\u524d\uff0c\u6211\u4eec\u5df2\u7ecf\u53ef\u4ee5\u4f7f\u7528\u88681\u4e2d\u7684\u53c2\u6570\u901a\u8fc7\u7535\u8111\u6216\u667a\u80fd\u624b\u673a\u4e0a\u7684Web\u6d4f\u89c8\u5668\u6765\u8bbe\u7f6e\u53c2\u6570\u4e86\uff0c\u5177\u4f53\u8bbe\u7f6e\u65b9\u6cd5\u5c06\u5728\u672c\u7cfb\u5217\u8fde\u8f7d\u7684\u7b2c4\u90e8\u5206\u8fdb\u884c\u4ecb\u7ecd\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2 id=\"05\">5.\u4f7f\u7528Python\u5b8c\u6210\u63a7\u5236\u7a0b\u5e8f<\/h2>\n<p>\u9488\u5bf9\u5728\u7b2c2\u90e8\u5206\u4e2d\u63d0\u5230\u7684\u529f\u80fd\uff0c\u6211\u7528Raspberry Pi\u7684Python\u7f16\u5199\u4e86\u7a0b\u5e8f\uff0c\u4e0b\u9762\u5bf9\u8be5\u7a0b\u5e8f\u8fdb\u884c\u8bf4\u660e\u3002<br \/>\n\u7a0b\u5e8f\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre class=\"brush: cpp; title: Code-Example; notranslate\" title=\"Code-Example\"># -*- coding: utf-8 -*-\r\n#\u5496\u5561\u673a\u63a7\u5236\u7a0b\u5e8f rev 1.0\r\n\r\n#\u5bfc\u5165\u5e93\r\nimport RPi.GPIO as GPIO\r\nimport time\r\nimport lcdtest_2x8\r\n\r\n#\u8bbe\u7f6e\u53d8\u91cf\r\nBUTTON1 = 24\r\nBUTTON2 = 25\r\nSTART_STOP_LED = 23\r\nAC_OUT_LED = 17\r\nSSR = 18\r\nCUPIDX = 1\r\n\r\n#Parameters:\u521d\u6b21\u6ce8\u6c34\u65f6\u95f4\u3001\u95f7\u84b8\u65f6\u95f4\u3001\u8403\u53d6\u65f6\u95f4\u3001ON\u65f6\u95f4\u3001OFF\u65f6\u95f4\r\nwtimer = [[60,40,360,60,10],[68,50,480,60,20],[70,50,600,60,20],[74,50,600,60,20],[0,0,600,60,0]]\r\n#GPIO Setup\r\nGPIO.setmode(GPIO.BCM)\r\nGPIO.setup(BUTTON1,GPIO.IN, pull_up_down=GPIO.PUD_DOWN)\r\nGPIO.setup(BUTTON2,GPIO.IN, pull_up_down=GPIO.PUD_DOWN)\r\n\r\nGPIO.setup(START_STOP_LED,GPIO.OUT,initial=GPIO.LOW)\r\nGPIO.setup(AC_OUT_LED,GPIO.OUT,initial=GPIO.LOW)\r\nGPIO.setup(SSR,GPIO.OUT)\r\nssr_pwm=GPIO.PWM(SSR,1)\r\nssr_pwm.start(0)\r\n#\u676f\u6570\u8bbe\u7f6e\u4e2d\u65ad\u4f8b\u7a0b\r\ndef button_pushed1(BUTTON1):\r\n    GPIO.remove_event_detect(BUTTON1)\r\n    global CUPIDX\r\n    if CUPIDX == 1:\r\n        print(\"Pressed!! Cups=3\")\r\n        lcdtest_2x8.write_data_to_lcd(\"Cups=3\",\"\")\r\n        CUPIDX = CUPIDX+1\r\n    elif CUPIDX == 2:\r\n        print(\"Pressed!! Cups=4\")\r\n        lcdtest_2x8.write_data_to_lcd(\"Cups=4\",\"\")\r\n        CUPIDX = CUPIDX+1\r\n    elif CUPIDX == 3:\r\n        print(\"Pressed!! Cups=5\")\r\n        lcdtest_2x8.write_data_to_lcd(\"Cups=5\",\"\")\r\n        CUPIDX = CUPIDX+1\r\n    elif CUPIDX == 4:\r\n        print(\"Pressed!! Cups=6\")\r\n        lcdtest_2x8.write_data_to_lcd(\"Cups=6\",\"\")\r\n        CUPIDX = CUPIDX+1\r\n    elif CUPIDX == 5:\r\n        print(\"Pressed!! Cups=2\")\r\n        lcdtest_2x8.write_data_to_lcd(\"Cups=2\",\"\")\r\n        CUPIDX = 1\r\n    time.slee p(0.3)\r\n    GPIO.add_event_detect(BUTTON1, GPIO.RISING, callback=button_pushed1, bouncetime=200)\r\n#\u521d\u59cb\u8bbe\u7f6e\r\nGPIO.add_event_detect(BUTTON1, GPIO.RISING, callback=button_pushed1, bouncetime=200)\r\nlcdtest_2x8.initlcd()\r\nlcdtest_2x8.write_data_to_lcd(\"Coffee\",\"Timer\")\r\ntime.slee p(2)\r\nlcdtest_2x8.clsc()\r\nlcdtest_2x8.write_data_to_lcd(\"Cups=2\",\"\")\r\n\r\n#\u4e3b\u5faa\u73af\r\ntry:\r\n    while True:\r\n        print(\"Waiting for rising edge on BUTTON2\")\r\n        GPIO.wait_for_edge(BUTTON2, GPIO.RISING)\r\n        print(\"Rising edge detected on BUTTON2.\")\r\n        GPIO.remove_event_detect(BUTTON1)\r\n        #Set Freqency and DutyCycle\r\n        freq_int = 1\/(wtimer[CUPIDX-1][3] + wtimer[CUPIDX-1][4])\r\n        duty = wtimer[CUPIDX-1][3]\/(wtimer[CUPIDX-1][3] + wtimer[CUPIDX-1][4])*100\r\n        print(\"Frequency(Hz) =\",freq_int)\r\n        print(\"Duty cycle(%) =\",duty)\r\n        \r\n        #1st step\r\n        current_time = time.time()\r\n        stop_time = current_time + wtimer[CUPIDX-1][0]\r\n        ssr_pwm.ChangeDutyCycle(100)\r\n        GPIO.output(AC_OUT_LED,1)\r\n        ledflag = True\r\n        while time.time() &lt; stop_time:\r\n            ctime = int(stop_time - time.time())\r\n            print(ctime)\r\n            GPIO.output(START_STOP_LED,ledflag)\r\n            lcdtest_2x8.write_data_to_lcd(\"\",\"1st:\"+str(ctime)+\"   \")\r\n            ledflag = not ledflag\r\n            time.slee p(1)\r\n\r\n        print(\"Timer1 out\")\r\n        print('Time: ' + str(time.time() - current_time))\r\n\r\n        #2nd step: Murashi\r\n        current_time = time.time()\r\n        stop_time = current_time + wtimer[CUPIDX-1][1]\r\n        ssr_pwm.ChangeDutyCycle(0)\r\n        GPIO.output(AC_OUT_LED,0)\r\n        ledflag = True\r\n        while time.time() &lt; stop_time:\r\n            ctime = int(stop_time - time.time())\r\n            print(ctime)\r\n            GPIO.output(START_STOP_LED,ledflag)\r\n            lcdtest_2x8.write_data_to_lcd(\"\",\"2nd:\"+str(ctime)+\"   \")\r\n            ledflag = not ledflag\r\n            time.slee p(1)\r\n        print(\"Timer2 out\")\r\n        print('Time: ' + str(time.time() - current_time))\r\n        #3rd step:\r\n        current_time = time.time()\r\n        stop_time = current_time + wtimer[CUPIDX-1][2]\r\n        ssr_pwm.ChangeFrequency(freq_int)\r\n        ssr_pwm.ChangeDutyCycle(duty)\r\n        GPIO.output(AC_OUT_LED,1)\r\n        ledflag = True\r\n        while time.time() &lt; stop_time:\r\n            ctime = int(stop_time - time.time())\r\n            print(ctime)\r\n            GPIO.output(START_STOP_LED,ledflag)\r\n            lcdtest_2x8.write_data_to_lcd(\"\",\"3rd:\"+str(ctime)+\"   \")\r\n            ledflag = not ledflag\r\n            time.slee p(1)\r\n        ssr_pwm.ChangeFrequency(1)\r\n        ssr_pwm.ChangeDutyCycle(0)\r\n        GPIO.output(AC_OUT_LED,0)\r\n        GPIO.output(START_STOP_LED,False)\r\n        print(\"Timer3 out\")\r\n        print('Time: ' + str(time.time() - current_time))\r\n        lcdtest_2x8.write_data_to_lcd(\"\",\"Sto p    \")\r\n\r\n        GPIO.add_event_detect(BUTTON 1, GPIO.RISING, call back=button_pushed1, bouncetime=200)\r\n        \r\n\r\nexcept KeyboardInterrupt:\r\n    GPIO.remove_event_detect(BUTTON1)\r\n    ssr_pwm.stop()\r\n    GPIO.cleanup()       # clean up GPIO on CTRL+C exit\r\n    print(\"STOP\")\r\n<\/pre>\n<p>\u4e0b\u9762\u4ecb\u7ecd\u5404\u7a0b\u5e8f\u5757\u7684\u8fd0\u884c\u8981\u70b9\u3002\u8fd9\u4e2a\u7a0b\u5e8f\u7684\u540d\u79f0\u662f\u201ccoffee_control_rev1.py\u201d\u3002<\/p>\n<h3>#\u5bfc\u5165\u5e93<\/h3>\n<p>\u5728\u8fd9\u91cc\uff0c\u5148\u5bfc\u5165\u201cRPi.gpio\u201d\u548c\u201ctime\u201d\u6807\u51c6\u5e93\u3002\u7136\u540e\u5c06\u201cI2C\u6db2\u6676\u5de5\u4f5c\u786e\u8ba4\u6a21\u5757\u201d\u4e00\u8282\u4e2d\u63d0\u5230\u7684\u201clcdtest_2x8.py\u201d\u4f5c\u4e3a\u5e93\u52a0\u8f7d\u8fdb\u6765\u3002\u8bf7\u5c06\u201clcdtest_2x8.py\u201d\u653e\u5728\u4e0e\u8fd9\u4e2a\u4e3b\u7a0b\u5e8f\u76f8\u540c\u7684\u76ee\u5f55\u4e2d\uff08\u6211\u662f\u653e\u5728\/home\/pi\/python\/\u4e2d\uff09\u3002<\/p>\n<h3>#\u8bbe\u7f6e\u53d8\u91cf<\/h3>\n<p>\u6211\u5c06GPIO\u4f7f\u7528\u7684BCM\u7f16\u53f7\u653e\u5728\u547d\u540d\u53d8\u91cf\u4e2d\u4e86\u3002\u8fd9\u662f\u4e3a\u4e86\u5728\u8bbe\u7f6eGPIO\u65f6\u66f4\u5bb9\u6613\u7406\u89e3\uff08\u5728\u4e0b\u9762\u7684\u4ecb\u7ecd\u8bf4\u660e\u4e2d\uff0c\u4f1a\u6709\u7c7b\u4f3c\u201cBUTTON1\uff0824\uff09\u201d\u8fd9\u6837\u7684\u5e26\u6709BCM\u7f16\u53f7\u7684\u8868\u8ff0\uff09\u3002\u6700\u540e\u7684\u201cCUPIDX\u201d\u7528\u4f5c\u5168\u5c40\u53d8\u91cf\uff0c\u7528\u6765\u4fdd\u5b58\u5f53\u524d\u7684\u676f\u6570\u3002<\/p>\n<h3>#Parameters\uff1a\u8bbe\u7f6e\u53c2\u6570\u5217\u8868<\/h3>\n<p>\u524d\u9762\u63d0\u5230\u7684\u201c\u88681 \u8bbe\u7f6e\u53c2\u6570\u4e00\u89c8\u8868\u201d\u4e2d\u7684\u503c\u5728\u4e8c\u7ef4\u5217\u8868wtimer\u4e2d\u3002\u503c\u901a\u8fc7wtimer[\u676f\u6570][\u9879\u76ee]\u7d22\u5f15\u6765\u5f15\u7528\u3002\u5728\u8fd9\u4e2a\u7a0b\u5e8f\u4e2d\uff0c\u8bbe\u7f6e\u503c\u662f\u4ee5\u7f16\u7a0b\u65b9\u5f0f\u63cf\u8ff0\u7684\uff0c\u5728\u7b2c4\u90e8\u5206\u4e2d\uff0c\u6211\u4eec\u5c06\u5bf9\u5176\u8fdb\u884c\u66f4\u65b0\uff0c\u4ee5\u4fbf\u53ef\u4ee5\u901a\u8fc7Web\u6d4f\u89c8\u5668\u66f4\u6539\u8fd9\u4e9b\u503c\u3002<\/p>\n<h3># GPIO Setup<\/h3>\n<p>\u9996\u5148\uff0c\u901a\u8fc7\u201cGPIO.setmode(GPIO.BCM)\u201d\u5c06\u6a21\u5f0f\u8bbe\u7f6e\u4e3a\u4f7f\u7528BCM\u7f16\u53f7\u7684\u6a21\u5f0f\u3002\u8fde\u63a5\u5fae\u52a8\u5f00\u5173\u7684BUTTON1\uff0824\uff09\u548cBUTTON2\uff0825\uff09\u4e3a\u201cGPIO.IN\u201d\u8f93\u5165\u6a21\u5f0f\uff0c\u5c06\u5185\u90e8\u4e0a\u62c9\u7535\u963b\u6307\u5b9a\u4e3a\u4e0b\u62c9\u201cGPIO.PUD_DOWN\u201d\u3002\u5c06START_STOP_LED\uff0823\uff09\u3001AC_OUT_LED\uff0817\uff09\u3001SSR\uff0818\uff09\u8bbe\u7f6e\u4e3a\u201cGPIO.OUT\u201d\u6a21\u5f0f\u3002<\/p>\n<p>SSSR\uff0818\uff09\u4f7f\u7528PWM\u529f\u80fd\u3002Raspberry Pi\u6709\u4e24\u4e2a\u7531\u786c\u4ef6\u63a7\u5236\u7684PWM\u7aef\u53e3\uff0c\u7aef\u53e3\uff0818\uff09\u662f\u5176\u4e2d\u4e4b\u4e00\u3002<\/p>\n<p>\u901a\u8fc7\u4ee5\u4e0b\u8bed\u53e5\u6765\u542f\u52a8PWM\u3002<br \/>\nssr_pwm=GPIO.PWM(SSR,1)<br \/>\nssr_pwm.start(0)<\/p>\n<p>\u4e0a\u9762\u53c2\u6570\u4e2d\u7684\u6570\u5b571\u662f\u9891\u7387\uff0c\u5355\u4f4d\u662fHz\u3002\u53ef\u4ee5\u7528\u5b9e\u6570\u6765\u6307\u5b9a\u8fd9\u4e2a\u6570\u5b57\uff0c\u6240\u4ee5\u4e5f\u652f\u63011\u4ee5\u4e0b\u7684\u4f4e\u9891\u3002\u4e0b\u9762\u53c2\u6570\u4e2d\u7684\u6570\u5b570\u662f\u5360\u7a7a\u6bd4\uff0c\u7528%\u6765\u6307\u5b9a\u3002\u8fd9\u4e2a\u6570\u503c\u4e5f\u53ef\u4ee5\u7528\u5b9e\u6570\u6765\u8bbe\u7f6e\u3002\u521d\u59cb\u72b6\u6001\u7684\u5360\u7a7a\u6bd4=0\uff0c\u8f93\u51fa\u4e3aOFF\u3002<\/p>\n<h3>#\u676f\u6570\u8bbe\u7f6e\u4e2d\u65ad\u4f8b\u7a0b<\/h3>\n<p>\u5496\u5561\u676f\u6570\u7528\u9ed1\u8272\u5fae\u52a8\u5f00\u5173\u201cBUTTON1\uff0824\uff09\u201d\u8fdb\u884c\u8bbe\u7f6e\u3002\u9700\u8981\u68c0\u6d4b\u5230\u6b64\u6309\u94ae\u88ab\u6309\u4e0b\u5e76\u542f\u52a8\u4e2d\u65ad\u5904\u7406\u8bbe\u7f6e\u6240\u5b9a\u4e49\u7684\u51fd\u6570\u3002\u5176\u4e2d\u65ad\u52a8\u4f5c\u4f8b\u7a0b\u2014\u2014\u51fd\u6570\u4e3a\u201cdef button_pushed1\u201d\u3002\u6bcf\u6309\u4e00\u4e0b\u9ed1\u8272\u7684\u5fae\u52a8\u5f00\u5173\uff0c\u8be5\u4f8b\u7a0b\u2014\u2014\u51fd\u6570\u5c31\u4f1a\u88ab\u8c03\u7528\u3002<\/p>\n<p>\u4e2d\u65ad\u8bbe\u7f6e\u662f\u901a\u8fc7\u4e0b\u9762\u7684\u201c#\u521d\u59cb\u8bbe\u7f6e\u201d\u5f00\u5934\u7684\u8bed\u53e5\u6765\u5b8c\u6210\u7684\uff1a<\/p>\n<p>GPIO.add_event_detect(BUTTON1, GPIO.RISING, callback=button_pushed1, bouncetime=200)<br \/>\n\u901a\u8fc7\u201cGPIO.RISING\u201d\u6307\u5b9a\u5e94\u5728\u4eceL\u5230H\u7684\u4e0a\u5347\u6cbf\u68c0\u6d4b\u8f93\u5165\u3002\u201ccallback=button_pushed1\u201d\u662f\u68c0\u6d4b\u5230\u8f93\u5165\u65f6\u8981\u8c03\u7528\u7684\u51fd\u6570\u540d\u3002\u201cbouncetime=200\u201d\u662f\u975e\u68c0\u6d4b\u7a97\u53e3\u65f6\u95f4\uff0c\u7528\u6765\u9632\u6b62\u7531\u4e8e\u5f00\u5173\u6296\u52a8\u800c\u5bfc\u81f4\u7684\u8bef\u68c0\u6d4b\u3002\u5728\u8fd9\u4e2a\u6848\u4f8b\u4e2d\uff0c\u8bbe\u7f6e\u4e3a\u5728\u7b2c\u4e00\u6b21\u68c0\u6d4b\u540e200ms\u5185\u4e0d\u5de5\u4f5c\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u5728\u8fd9\u4e2a\u4e2d\u65ad\u51fd\u6570\u4f8b\u7a0b\u7684\u5f00\u5934\uff0c\u63d2\u5165\u4e86\u7528\u6765\u7981\u7528\u4e2d\u65ad\u7684\u201cGPIO.remove_event_detect\u201d\u3002\u8fd9\u662f\u9632\u6b62\u5728\u4e2d\u65ad\u5904\u7406\u8fc7\u7a0b\u4e2d\u53d1\u751f\u591a\u91cd\u4e2d\u65ad\u7684\u63aa\u65bd\u3002\u5728\u8be5\u4f8b\u7a0b\u7684\u6700\u540e\uff0c\u52a0\u4e0a\u201cGPIO.add_event_detect\u201d\u6765\u91cd\u65b0\u542f\u7528\u4e2d\u65ad\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u4e3a\u4fdd\u5b58\u5f53\u524d\u676f\u6570\u7684\u53d8\u91cf\u201cCUPIDX\u201d\u6307\u5b9a\u201cglobal\u201d\u3002\u5982\u679c\u4e0d\u8fdb\u884c\u8fd9\u4e2a\u6307\u5b9a\uff0c\u5c31\u4f1a\u88ab\u89c6\u4e3a\u5176\u51fd\u6570\u4e2d\u7684\u5c40\u90e8\u53d8\u91cf\uff0c\u5c06\u65e0\u6cd5\u5728\u4e3b\u7a0b\u5e8f\u4e2d\u5f15\u7528\u8be5\u503c\u3002<\/p>\n<p>\u7136\u540e\uff0c\u7531if\u8bed\u53e5\u5728\u6bcf\u6b21\u6309\u4e0b\u5f00\u5173\u65f6\u9012\u589e\u676f\u6570\u3002\u5728shell\u548c\u6db2\u6676\u663e\u793a\u5668\u4e0a\u5c06\u4f1a\u663e\u793a\u676f\u6570\u3002<\/p>\n<h3>#\u521d\u59cb\u8bbe\u7f6e<\/h3>\n<p>\u8fdb\u884c\u524d\u8ff0\u7684\u4e2d\u65ad\u8bbe\u7f6e\u548c\u6db2\u6676\u663e\u793a\u5668\u4e2d\u7684\u542f\u52a8\u6d88\u606f\u663e\u793a\u8bbe\u7f6e\u3002<\/p>\n<h3>#\u4e3b\u5faa\u73af<\/h3>\n<p>\u6211\u5728\u4ecb\u7ecd\u6574\u4f53\u7ed3\u6784\u65f6\u63d0\u5230\u8fc7\uff0c\u4e3b\u5faa\u73af\u7531\u7b49\u5f85\u542f\u52a8\u6309\u94ae\u8f93\u5165\u548c\u4e09\u4e2a\u5b9a\u65f6\u5668\u5faa\u73af\u7ec4\u6210\u3002<\/p>\n<p>\u9996\u5148\u662f\u7b49\u5f85\u542f\u52a8\u6309\u94ae\u2014\u2014BUTTON2\uff0825\uff09\u7684\u8f93\u5165\u3002<br \/>\nGPIO.wait_for_edge(BUTTON2, GPIO.RISING)<\/p>\n<p>\u4f7f\u7528\u201cGPIO.RISING\u201d\u68c0\u6d4b\u4e0a\u5347\u6cbf\u3002\u542f\u52a8\u65f6\uff0c\u9996\u5148\u7981\u7528\u676f\u6570\u8f93\u5165\u7684\u4e2d\u65ad\u5904\u7406\u3002<br \/>\nGPIO.remove_event_detect(BUTTON1)<\/p>\n<p>\u8fd9\u662f\u4e3a\u4e86\u7981\u6b62\u5728\u8403\u53d6\u5496\u5561\u8fc7\u7a0b\u4e2d\u6539\u53d8\u676f\u6570\u3002\u5728\u4e09\u4e2a\u5b9a\u65f6\u5668\u5faa\u73af\u7ed3\u675f\u540e\uff0c\u4f1a\u518d\u6b21\u542f\u7528\u4e2d\u65ad\uff0c\u4ee5\u4fbf\u6211\u4eec\u80fd\u591f\u8bbe\u7f6e\u676f\u6570\u3002<\/p>\n<h3>#Set Freqency and DutyCycle\uff1aPWM\u53c2\u6570\u8bbe\u7f6e<\/h3>\n<p>\u6211\u5728\u4e3b\u5faa\u73af\u4e2d\u6dfb\u52a0\u4e86\u57fa\u4e8ePWM\u7684\u5496\u5561\u673aON\/OFF\u529f\u80fd\u3002\u5176\u5de5\u4f5c\u793a\u610f\u56fe\u5982\u4e0b\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-28529\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2023\/05\/coffee-maker-with-raspberry-pi-03-06-2.png\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2023\/05\/coffee-maker-with-raspberry-pi-03-06-2.png 500w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2023\/05\/coffee-maker-with-raspberry-pi-03-06-2-150x150.png 150w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2023\/05\/coffee-maker-with-raspberry-pi-03-06-2-300x300.png 300w\" alt=\"coffee-maker-with-raspberry-pi-03-06-2\" width=\"500\" height=\"498\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>PWM\uff08Pulse Width Modulation\uff1d\u8109\u51b2\u5bbd\u5ea6\u8c03\u5236\uff09\u662f\u4e00\u79cd\u5468\u671f\u6027\u5730\u6539\u53d8\u8109\u51b2ON\/OFF\u5bbd\u5ea6\u7684\u4fe1\u53f7\u65b9\u5f0f\uff0c\u5e38\u88ab\u7528\u4e8e\u6539\u53d8LED\u7684\u4eae\u5ea6\u548c\u63a7\u5236\u7535\u673a\u8f6c\u901f\u7b49\u5e94\u7528\u3002\u5728\u8fd9\u7c7b\u5e94\u7528\u4e2d\uff0c\u9891\u7387\u4e3a\u51e0\u5341Hz\u4ee5\u4e0a\uff0c\u5bfc\u901a\u8109\u51b2\u5bbd\u5ea6\u4e3a\u6beb\u79d2\u7ea7\u3002\u5728Raspberry Pi\u7684PWM\u4e2d\uff0c\u662f\u901a\u8fc7\u9891\u7387\u548c\u5360\u7a7a\u6bd4\u8bbe\u7f6e\u7684\uff0c\u53ef\u4ee5\u7528\u5b9e\u6570\u4ee3\u5165\uff0c\u56e0\u6b64\uff0c\u5373\u4f7f\u57281Hz\u4ee5\u4e0b\u7684\u4f4e\u9891\u6761\u4ef6\u4e0b\u4e5f\u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\u3002<br \/>\n\u4e8e\u662f\uff0c\u6211\u4ee5\u201c\u79d2\u201d\u4e3a\u5355\u4f4d\u8bbe\u7f6e\u4e86\u5496\u5561\u673a\u7684\u70ed\u6c34\u6ce8\u5165\u65f6\u95f4\u548c\u6682\u505c\u65f6\u95f4\uff0c\u5e76\u5c1d\u8bd5\u5c06\u5176\u5e94\u7528\u4e8e\u6ce8\u5165\u70ed\u6c34\u6ce8\u5165\u65f6\u95f4\uff08ON\uff09=60\u79d2\u3001\u6682\u505c\u65f6\u95f4\uff08OFF\uff09=20\u79d2\u7b49\u8403\u53d6\u65b9\u6cd5\u3002\u5728\u672c\u6848\u4f8b\u4e2d\uff0c\u6211\u5c06\u9891\u7387\u8bbe\u7f6e\u4e3a0.0125Hz\uff0c\u5360\u7a7a\u6bd4\u8bbe\u7f6e\u4e3a75%\uff0c\u867d\u7136\u9891\u7387\u975e\u5e38\u4f4e\uff0c\u4f46PWM\u8fd8\u662f\u80fd\u5de5\u4f5c\u6b63\u5e38\u7684\u3002<\/p>\n<h3>#1st step\uff1a\u521d\u6b21\u6ce8\u6c34<\/h3>\n<p>\u8fd9\u662f\u5148\u7528\u70ed\u6c34\u6d78\u6da6\u5496\u5561\u7c89\u7684\u521d\u6b21\u6ce8\u6c34\u5b9a\u65f6\u5668\u5faa\u73af\u3002\u4f7f\u7528\u201ctime.time()\u201d\u51fd\u6570\u83b7\u53d6\u5f53\u524d\u65f6\u95f4\u3002\u4ee5\u79d2\u4e3a\u5355\u4f4d\u8f93\u5165\u53d8\u91cf\u3002\u5c06\u521d\u6b21\u6ce8\u6c34\u65f6\u95f4\u6dfb\u52a0\u5230\u8fd9\u91cc\u6210\u4e3a\u201cstop_time\u201d\u3002\u5728\u5f53\u524d\u65f6\u95f4\u8d85\u8fc7\u8fd9\u4e2a\u201cstop_time\u201d\u65f6\uff0c\u5b9a\u65f6\u5668\u7684while\u5faa\u73af\u7ed3\u675f\u3002<\/p>\n<p>while time.time() &lt; stop_time:<\/p>\n<p>\u8be5\u65b9\u6cd5\u4e0e\u540e\u7eed\u7684\u7b2c\u4e8c\u6b65\u548c\u7b2c\u4e09\u6b65\u76f8\u540c\u3002<br \/>\n\u81f3\u4e8e\u542f\u52a8\u5496\u5561\u673a\u7684\u65b9\u6cd5\uff0cSSR\uff0818\uff09\u4f7f\u7528PWM\u8bbe\u7f6e\u3002\u56e0\u6b64\uff0c\u8981\u4f7f\u7535\u6e90\u8fde\u7eedON\uff0c\u8bf7\u5c06\u5360\u7a7a\u6bd4\u8bbe\u7f6e\u4e3a100%\u3002<\/p>\n<p>ssr_pwm.ChangeDutyCycle(100)<\/p>\n<p>\u7136\u540e\u662f\u8981\u4f7fLED\u70b9\u4eae\u6765\u8868\u793a\u5de5\u4f5c\u4e2d\u8fd9\u4e2a\u72b6\u6001\u3002<\/p>\n<p>GPIO.output(AC_OUT_LED,1)<br \/>\nGPIO.output(START_STOP_LED,ledflag)<\/p>\n<p>\u201cAC_OUT_LED\u201d\u8868\u793a\u5496\u5561\u673a\u5df2\u542f\u52a8\uff08ON\uff09\u3002\u201cSTART_STOP_LED\u201d\u8868\u793a\u5b9a\u65f6\u5668\u6b63\u5728\u8fd0\u884c\uff0c\u6bcf\u96941\u79d2\u70b9\u4eae\u4e00\u6b21\u3002\u6211\u662f\u5c06\u201ctime.slee p(1)\u201d\u52a0\u5165\u5faa\u73af\u4e2d\uff0c\u4ee5\u201cledflag = not ledflag\u201d\u6765\u5b9e\u73b0\u95f4\u9694\u95ea\u70c1\u7684\u3002\u5728LCD\u4e0a\uff0c\u6bcf\u96941\u79d2\u4f1a\u663e\u793a\u5b9a\u65f6\u5668\u7684\u5269\u4f59\u65f6\u95f4\u3002<\/p>\n<h3>#2nd step: \u95f7\u84b8<\/h3>\n<p>\u7a0b\u5e8f\u7ed3\u6784\u4e0e#1st step\u57fa\u672c\u76f8\u540c\u3002\u7531\u4e8e\u5496\u5561\u673a\u5728\u95f7\u84b8\u8fc7\u7a0b\u4e2d\u5904\u4e8eOFF\u72b6\u6001\uff0c\u6240\u4ee5\u5c06SSR\uff0818\uff09\u7684PWM\u5360\u7a7a\u6bd4\u8bbe\u7f6e\u4e3a0%\u3002<\/p>\n<p>\u4e4b\u540e\uff0c\u8ba9\u201cAC_OUT_LED\u201d\u7184\u706d\u3002<\/p>\n<h3>#3rd step\uff1a\u8403\u53d6<\/h3>\n<p>\u7b2c\u4e09\u6b65\u7684\u7ed3\u6784\u4e5f\u4e0e#1st step \u548c#2nd step\u76f8\u540c\u3002\u901a\u8fc7\u6267\u884c\u4ee5\u4e0b\u8bed\u53e5\u6765\u542f\u7528\u524d\u8ff0\u7684\u57fa\u4e8ePWM\u7684ON\/OFF\u529f\u80fd\u3002<br \/>\nssr_pwm.ChangeFrequency(freq_int)<br \/>\nssr_pwm.ChangeDutyCycle(duty)<\/p>\n<p>\u201cfreq_int\u201d\u548c\u201cduty\u201d\u53d8\u91cf\u4e2d\u542b\u6709\u524d\u8ff0\u7684#Set Freqency and DutyCycle\u8ba1\u7b97\u503c\u3002\u5b9a\u65f6\u5668\u5faa\u73af\u7ed3\u675f\u540e\uff0c\u5c06PWM\u8bbe\u7f6e\u5982\u4e0b\uff0c\u5173\u95ed\u5496\u5561\u673a\uff08\u9891\u7387\uff1d1Hz\u3001duty\uff1d0%\uff09\uff1a<br \/>\nssr_pwm.ChangeFrequency(1)<br \/>\nssr_pwm.ChangeDutyCycle(0)<\/p>\n<p>\u6700\u540e\uff0c\u5141\u8bb8\u8bbe\u7f6e\u676f\u6570\u7684\u4e2d\u65ad\u5e76\u6062\u590d\u5f00\u59cb\u6309\u94ae\u8f93\u5165\u3002<br \/>\n\u201cexcept KeyboardInterrupt\uff1a\u201d\u90e8\u5206\u662f\u5f53\u7a0b\u5e8f\u88abCTRL+C\u4e2d\u6b62\u65f6\u7684\u5f02\u5e38\u5904\u7406\uff0c\u4f1a\u6e05\u7406GPIO\u5e76\u521d\u59cb\u5316\u6240\u6709\u7684\u7aef\u53e3\u3002<\/p>\n<p>\u5bf9python\u7a0b\u5e8f\u5217\u8868\u7684\u8bf4\u660e\u5c31\u5230\u8fd9\u91cc\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u4e0b\u9762\u7684YouTube\u89c6\u9891\u89c2\u5bdf\u672c\u88c5\u7f6e\u7684\u8fd0\u884c\u60c5\u51b5\u3002<\/p>\n<div class=\"video-container\" style=\"margin-bottom:5px;\"><a href=\"https:\/\/www.youtube.com\/embed\/IUk8Fmkns8I\" target=\"_blank\" rel=\"noopener\">https:\/\/www.youtube.com\/embed\/IUk8Fmkns8I<\/a><\/div>\n<div>\u203b\u6b64\u94fe\u63a5\u4e3aYoutube\u89c6\u9891<\/div>\n<p>&nbsp;<\/p>\n<p>\u5728\u4e0b\u4e00\u7bc7\u4e5f\u5c31\u662f\u7b2c4\u90e8\u5206\uff08\u5267\u7ec8\u7bc7\uff09\u4e2d\uff0c\u6211\u4eec\u5c06\u5bf9\u8fd9\u4e2a\u8f6f\u4ef6\u8fdb\u884c\u6269\u5c55\u548c\u4fee\u6539\uff0c\u4ee5\u4fbf\u53ef\u4ee5\u901a\u8fc7\u7f51\u7edc\u8fdb\u884c\u8fdc\u7a0b\u8bbe\u7f6e\u3002\u6211\u4eec\u4f1a\u901a\u8fc7Raspberry Pi\u63a7\u5236Web\u670d\u52a1\u5668\u529f\u80fd\uff0c\u5e76\u4ece\u5ba2\u6237\u7aefWeb\u6d4f\u89c8\u5668\u8fdb\u884c\u8bbe\u7f6e\u3002\u6211\u4eec\u5c06\u4f7f\u7528html\u3001Java Script\u3001Ajax\u3001PHP\u7b49Web\u7f16\u7a0b\u6765\u5b9e\u73b0\u8be5\u529f\u80fd\u3002<\/p>\n<p>\u6700\u540e\uff0c\u6211\u8fd8\u6253\u7b97\u8c08\u8c08\u5982\u4f55\u66f4\u597d\u5730\u4f7f\u7528\u672c\u88c5\u7f6e\u5236\u4f5c\u5496\u5561\uff0c\u656c\u8bf7\u671f\u5f85\uff01<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: 14pt;\"><strong>\u672c\u7cfb\u5217\u8fde\u8f7d\u7684\u5185\u5bb9<\/strong><\/span><\/p>\n<p>\u7b2c1\u90e8\u5206\uff1a<a href=\"https:\/\/techclass.wfjydl.com\/knowledge\/tech-info\/raspberry\/coffee-maker-with-raspberry-pi-01\">\u88c5\u7f6e\u6982\u51b5\u548c\u5496\u5561\u8403\u53d6<\/a><br \/>\n\u7b2c2\u90e8\u5206\uff1a<a href=\"https:\/\/techclass.wfjydl.com\/knowledge\/tech-info\/raspberry\/coffee-maker-with-raspberry-pi-02\">\u786c\u4ef6\u5236\u4f5c<\/a><br \/>\n\u7b2c3\u90e8\u5206\uff1a\u4f7f\u7528Python\u5b8c\u6210\u63a7\u5236\u8f6f\u4ef6\uff08\u672c\u6587\uff09<br \/>\n\u7b2c4\u90e8\u5206\uff1a\u8fdc\u7a0b\u8bbe\u7f6e\u8f6f\u4ef6<\/p>\n<p><!-- single__author --><\/p>\n<div class=\"single__author\">\n<div class=\"single__author__avatar\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-90 photo\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2026\/04\/profile-ayatani-90x90-1.png\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2026\/04\/profile-ayatani-90x90-1.png 2x\" alt=\"\" width=\"90\" height=\"90\" \/><\/div>\n<div class=\"single__author__description\">\n<h2><a href=\"https:\/\/deviceplus.jp\/author\/m-ayatani\/\">\u963f\u77e2\u8c37\u5145<\/a><\/h2>\n<p>\u5728\u4e00\u5bb6\u6d4b\u91cf\u4eea\u5668\u516c\u53f8\uff08\u7f51\u7edc\u8bbe\u5907\u4f9b\u5e94\u5546\uff09\u62c5\u4efb\u7cfb\u7edf\u5de5\u7a0b\u5e08\u3002\u76ee\u524d\u5728\u5404\u5a92\u4f53\u4e0a\uff0c\u9762\u5411\u559c\u6b22\u81ea\u5df1\u52a8\u624b\u5236\u4f5c\u7684\u7fa4\u4f53\u64b0\u5199\u548c\u53d1\u8868\u7535\u5b50\u4f5c\u54c1\u5236\u4f5c\u7c7b\u7684\u6587\u7ae0\u3002\u7231\u597d\u662f\u6f14\u594f\u53e4\u4e50\u5668\u548c\u7409\u7279\u7434\u3002\u73b0\u4efb\u65e5\u672c\u7409\u7279\u7434\u534f\u4f1a\u7406\u4e8b\u3002<\/p>\n<p><a href=\"http:\/\/lute.penne.jp\/thumbunder\/\" target=\"_blank\" rel=\"noopener\">http:\/\/lute.penne.jp\/thumbunder\/<\/a><\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"\u7b2c1\u90e8\u5206\uff1a\u88c5\u7f6e\u6982\u51b5\u548c\u5496\u5561\u8403\u53d6 \u7b2c2\u90e8\u5206\uff1a\u786c\u4ef6\u5236\u4f5c &nbsp; \u672c\u7cfb\u5217\u8fde\u8f7d\u5c06\u4e3a\u60a8\u4ecb\u7ecd\u4f7f\u7528Raspberry Pi\u5236\u4f5c\u5496\u5561\u673a\u63a7\u5236\u88c5\u7f6e\u7684\u65b9\u6cd5\u3002\u672c\u7cfb\u5217\u4e3a\u6211\u4eec\u5206\u4eab\u7684\u5609\u5bbe\u662f\u963f\u77e2\u8c37\u5145\u5148\u751f\uff0c\u4ed6\u8fc4\u4eca\u4e3a\u6b62\u5728\u5404\u79cd\u5a92\u4f53\u4e0a\uff0c\u9762\u5411\u559c\u6b22\u81ea\u5df1\u52a8\u624b\u5236\u4f5c [&hellip;]","protected":false},"author":4,"featured_media":23220,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1132],"tags":[],"class_list":["post-23194","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-raspberry"],"acf":[],"wps_subtitle":"","_links":{"self":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/23194","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/comments?post=23194"}],"version-history":[{"count":21,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/23194\/revisions"}],"predecessor-version":[{"id":29571,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/23194\/revisions\/29571"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/media\/23220"}],"wp:attachment":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/media?parent=23194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/categories?post=23194"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/tags?post=23194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}