{"id":3375,"date":"2018-02-22T12:07:02","date_gmt":"2018-02-22T04:07:02","guid":{"rendered":"https:\/\/dingxuan.info\/wp\/?p=3375"},"modified":"2018-02-22T18:49:01","modified_gmt":"2018-02-22T10:49:01","slug":"3375","status":"publish","type":"post","link":"https:\/\/dingxuan.info\/wp\/?p=3375","title":{"rendered":"\u9001\u7ed9LP\u7684\u4e03\u5f69\u5927\u94bb\u77f3 &#8211; 2\u6863\u53d8\u901f\u7bb1+LED\u8272\u5f69\u63a7\u5236"},"content":{"rendered":"<iframe loading=\"lazy\" src=\"http:\/\/player.youku.com\/embed\/XMzQxNDg2MzU4OA==\" width=\"700\" height=\"500\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><span data-mce-type=\"bookmark\" style=\"width: 0px;overflow: hidden;line-height: 0\" class=\"mce_SELRES_start\">\ufeff<\/span>\n<span data-mce-type=\"bookmark\" style=\"width: 0px;overflow: hidden;line-height: 0\" class=\"mce_SELRES_start\">\ufeff<\/span>\n<span data-mce-type=\"bookmark\" style=\"width: 0px;overflow: hidden;line-height: 0\" class=\"mce_SELRES_start\">\ufeff<\/span>\n<span data-mce-type=\"bookmark\" style=\"width: 0px;overflow: hidden;line-height: 0\" class=\"mce_SELRES_start\">\ufeff<\/span>\n<span data-mce-type=\"bookmark\" style=\"width: 0px;overflow: hidden;line-height: 0\" class=\"mce_SELRES_start\">\ufeff<\/span>\n<span data-mce-type=\"bookmark\" style=\"width: 0px;overflow: hidden;line-height: 0\" class=\"mce_SELRES_start\">\ufeff<\/span><\/iframe>\n<h1 class=\"wp-block-heading\">\u73a9\u5177\u529f\u80fd<\/h1>\n<ol>\n\n<li>\u51cf\u901f\u9f7f\u8f6e\u7ec4\uff0c\u628a\u7535\u673a\u901f\u5ea6\u964d\u4f4e\u3002<\/li>\n\n<li>\u9f7f\u8f6e\u6bd4\u53ef\u4ee5\u8c03\u3002\u4e24\u6863\u53d8\u901f\u3002<\/li>\n\n<li>\u53ea\u80fd\u505c\u8f6c\u540e\u624d\u80fd\u6362\u6321\u3002\u60f3\u8fc7\u505a\u4e2a\u79bb\u5408\u5668\uff0c\u8c8c\u4f3c\u6ca1\u6cd53D\u6253\u5370\u5b9e\u73b0\u5427\u3002\u5982\u679c\u54ea\u4f4d\u9ad8\u624b\u6709\u529e\u6cd5\uff0c\u8bf7\u8d50\u6559\u3002<\/li>\n\n<li>LED\u5f69\u706f\uff0c\u4e24\u4e2a\u6a21\u5f0f\u3002\nA. \u968f\u673a\u989c\u8272\uff0c\u8fc7\u6e21\u53d8\u6362\u3002\nB. \u624b\u52a8\u6a21\u5f0f\uff0c\u4e09\u4e2a\u53ef\u8c03\u53d8\u963b\u5668\uff0c\u5206\u522b\u63a7\u5236RGB\u503c\u3002<\/li>\n<\/ol>\n<h1 class=\"wp-block-heading\">\u7ecf\u9a8c\u603b\u7ed3<\/h1>\n<ol>\n\n<li>\u5148\u8bf4\u6559\u8bad\u5427\u3002\u70e7\u6389\u4e00\u5757arduino nano\u3002\u5b9e\u9a8c\u6210\u529f\u540e\u8ddfLP\u663e\u6446\uff0c\u7ed3\u679c9v\u4f9b\u7535\u628aVIN\u548cGND\u63a5\u53cd\u4e86\u3002\u4e00\u80a1\u9752\u70df\uff0c\u6362\u6765LP\u5927\u4eba\u7684\u6b22\u7b11\u3002<\/li>\n\n<li>\u8fd8\u70e7\u6389\u4e00\u5757\u7535\u6c60\u5145\u7535\u4fdd\u62a4\u677f\u3002\u6559\u8bad\u65f6\uff0c\u710a\u7535\u6c60\u7684\u65f6\u5019\uff0c<strong>\u6700\u540e\u4e00\u6b65\u518d\u710a\u6b63\u8d1f\u7ea7<\/strong>\u3002<\/li>\n\n<li>\u8bbe\u8ba1\u5efa\u6a21\u65f6\uff0c\u591a\u6839\u7535\u7ebf\u7ed1\u5728\u4e00\u8d77\u65f6\uff0c\u76f4\u5f84\u8981\u6253\u51fa\u5bcc\u88d5\u3002<\/li>\n\n<li>\u8981\u5145\u5206\u8003\u8651\u5230\u6c89\u79ef\u6253\u5370\u6210\u54c1\u7684\u53d7\u529b\u7279\u70b9\u3002\u51e0\u4ef6\u4e1c\u897f\u62fc\u63a5\u7684\u65f6\u5019\uff0c\u4e0d\u80fd\u7528\u63d2\u5934\u94fe\u63a5\u3002\u4e00\u5b9a\u8981\u7528\u7684\u8bdd\uff0c\u63d2\u5934\u505a\u5230\u5f88\u7c97\u3002\u800c\u4e14\u63d2\u5b54\u8981\u5927\uff0c\u62d4\u51fa\u65f6\u4e0d\u80fd\u6709\u963b\u529b\u3002\u8fd9\u6b21\u6298\u4e86\u7c98\uff0c\u7c98\u4e86\u6298\uff0c\u7528\u6389\u4e0d\u5c11502\u3002<\/li>\n\n<li>\u610f\u5916\u53d1\u73b0\uff0c502\u7c98\u5b8c\u540e\uff0c\u518d\u7528\u73bb\u7483\u80f6\u6cbe\u4e00\u4e0b\u3002\u8fd8\u7b97\u6bd4\u8f83\u7ed3\u5b9e\u3002<\/li>\n<\/ol>\n<h1 class=\"wp-block-heading\">\u5236\u4f5c\u8fc7\u7a0b\u8bb0\u5f55<\/h1>\n<p>\u4ee3\u7801\u89c1\u672c\u6587\u672b\u5c3e\u3002SolidWorks\u6a21\u578b\u6700\u8fd1\u51e0\u5929\u53d1\u5230thingiverse.com\u4e0a\u3002<\/p>\n<h2 class=\"wp-block-heading\">\u4e00. \u7535\u8def\u539f\u578b<\/h2>\n<p><figure id=\"attachment_mmd_3390\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"1920\" height=\"1080\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/wx_camera_1510408037201510674206.jpg\" class=\"attachment-full size-full\" alt=\"\" loading=\"lazy\" align=\"none\" \/><\/figure><!--more--><\/p>\n<p>\u539f\u578b\u6d4b\u8bd5\u6210\u529f\u540e\uff0c\u753b\u7535\u8def\u56fe\u3002\u4e0d\u8d76\u7d27\u753b\u51fa\u6765\uff0c\u4e09\u5929\u540e\u81ea\u5df1\u5c31\u641e\u4e0d\u6e05\u695a\u4e00\u5806\u4e71\u7ebf\u600e\u4e48\u63d2\u51fa\u6765\u7684\u4e86\u3002<\/p>\n<figure id=\"attachment_mmd_3386\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"1278\" height=\"1221\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/motorrun_diamond_bb509861493.png\" class=\"attachment-full size-full\" alt=\"\" loading=\"lazy\" align=\"none\" \/><\/figure>\n<p>\u5148\u7528arduino uno\u505a\u8bbe\u8ba1\u3002\u8003\u8651\u5230\u6210\u54c1\u5c3a\u5bf8\u4e0d\u80fd\u592a\u5927\uff0c\u6700\u540e\u6539\u5728nano dreamer\u4e0a\u5b9e\u73b0\u3002<\/p>\n<h2 class=\"wp-block-heading\">\u4e8c. \u7535\u8def\u677f\u710a\u63a5<\/h2>\n<figure id=\"attachment_mmd_3393\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"2000\" height=\"1500\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/img_20171111_1535402039709494.jpg\" class=\"attachment-full size-full\" alt=\"\" loading=\"lazy\" align=\"none\" \/><\/figure>\n<p>\u710a\u63a5\u5de5\u4f5c\u53f0\u3002\u710a\u63a5\u624b\u827a\u6709\u5f85\u63d0\u9ad8\uff0c\u597d\u5728\u5012\u662f\u4e00\u6b21\u6210\u529f\u3002\u8be5\u8fde\u7684\u90fd\u8fde\u4e0a\u4e86\uff0c\u4e0d\u8be5\u8fde\u7684\u90fd\u8fd8\u5206\u7740\u3002<\/p>\n<figure id=\"attachment_mmd_3391\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"1500\" height=\"2000\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/img_20171111_1536151991805296.jpg\" class=\"attachment-full size-full\" alt=\"\" loading=\"lazy\" align=\"none\" \/><\/figure>\n<figure id=\"attachment_mmd_3392\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"1500\" height=\"2000\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/img_20171111_1536021934264047.jpg\" class=\"attachment-full size-full\" alt=\"\" loading=\"lazy\" align=\"none\" \/><\/figure>\n<figure id=\"attachment_mmd_3387\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"2000\" height=\"1500\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/img_20171118_205335421646196.jpg\" class=\"attachment-full size-full\" alt=\"\" loading=\"lazy\" align=\"none\" \/><\/figure>\n<figure id=\"attachment_mmd_3384\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"2000\" height=\"1500\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/img_20171118_2054491819718382.jpg\" class=\"attachment-full size-full\" alt=\"\" loading=\"lazy\" align=\"none\" \/><\/figure>\n<figure id=\"attachment_mmd_3385\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"2000\" height=\"1500\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/img_20171118_2053041470881936.jpg\" class=\"attachment-full size-full\" alt=\"\" loading=\"lazy\" align=\"none\" \/><\/figure>\n<h2 class=\"wp-block-heading\">\u4e09. SolidWorks\u5efa\u6a21<\/h2>\n<p>&nbsp;<\/p>\n<div style=\"width: 640px;\" class=\"wp-video\"><video class=\"size-full\" id=\"video-3375-1\" width=\"640\" height=\"360\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/wx_camera_1518958816012.mp4?_=1\" \/><a href=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/wx_camera_1518958816012.mp4\">https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/wx_camera_1518958816012.mp4<\/a><\/video><\/div>\n<p>\u8fd9\u4e00\u6b65\u82b1\u7684\u65f6\u95f4\u6700\u957f\u3002\u5efa\u597d\u4e86\u662f\u8fd9\u6837\u3002<\/p>\n<p>\u624d\u77e5\u9053\u9f7f\u8f6e\u90fd\u6709\u6a21\u6570\u4e00\u8bf4\u3002\u6a21\u6570\u4e00\u6837\u7684\uff0c\u624d\u80fd\u54ac\u5408\u5f97\u4e0a\u3002<\/p>\n<figure id=\"attachment_mmd_3394\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"2000\" height=\"1500\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/img_20171002_1646291991016274.jpg\" class=\"attachment-full size-full\" alt=\"\" loading=\"lazy\" align=\"none\" \/><\/figure>\n<figure id=\"attachment_mmd_3395\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"2000\" height=\"1500\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/img_20171002_1645211238822296.jpg\" class=\"attachment-full size-full\" alt=\"\" loading=\"lazy\" align=\"none\" \/><\/figure>\n<figure id=\"attachment_mmd_3379\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"2000\" height=\"1500\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/img_20180110_1824561231383899.jpg\" class=\"attachment-full size-full\" alt=\"\" loading=\"lazy\" align=\"none\" \/><\/figure>\n<figure id=\"attachment_mmd_3380\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"2000\" height=\"1500\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/img_20180110_1822571523629350.jpg\" class=\"attachment-full size-full\" alt=\"\" loading=\"lazy\" align=\"none\" \/><\/figure>\n<figure id=\"attachment_mmd_3378\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"2000\" height=\"1500\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/img_20180110_183246575096738.jpg\" class=\"attachment-full size-full\" alt=\"\" loading=\"lazy\" align=\"none\" \/><\/figure>\n<h2 class=\"wp-block-heading\">\u56db. 3D\u6253\u5370<\/h2>\n<figure id=\"attachment_mmd_3383\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"2000\" height=\"1500\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/img_20180110_09131221385684.jpg\" class=\"attachment-full size-full\" alt=\"\" loading=\"lazy\" align=\"none\" \/><\/figure>\n<p>\u6bcf\u5929\u65e9\u4e0a\u5f00\u59cb\u6253\uff0c\u987a\u5229\u7684\u65f6\u5019\uff0c\u665a\u4e0a\u56de\u6765\u80fd\u51fa\u7089\u4e00\u6279\u96f6\u4ef6\u3002<\/p>\n<figure id=\"attachment_mmd_3382\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"1500\" height=\"2000\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/img_20180109_2221121177536470.jpg\" class=\"attachment-full size-full\" alt=\"\" loading=\"lazy\" align=\"none\" \/><\/figure>\n<p>\u5f53\u7136\u4e5f\u6709\u4e0d\u987a\u7684\u65f6\u5019\u3002\u3002\u3002\u56de\u6765\u9700\u8981\u6253\u626b\u536b\u751f\u3002<\/p>\n<figure id=\"attachment_mmd_3377\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"2000\" height=\"1500\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/img_20180122_2111501489402855.jpg\" class=\"attachment-full size-full\" alt=\"\" loading=\"lazy\" align=\"none\" \/><\/figure>\n<div style=\"width: 640px;\" class=\"wp-video\"><video class=\"size-full\" id=\"video-3375-2\" width=\"640\" height=\"360\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/wx_camera_1518958816012.mp4?_=2\" \/><a href=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/wx_camera_1518958816012.mp4\">https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/wx_camera_1518958816012.mp4<\/a><\/video><\/div>\n<p>\u90fd\u6253\u51fa\u6765\uff0c\u5dee\u4e0d\u591a\u662f\u8fd9\u6837\u3002<\/p>\n<h2 class=\"wp-block-heading\">\u4e94. \u6700\u540e\u7ec4\u88c5\u8c03\u8bd5<\/h2>\n<figure id=\"attachment_mmd_3373\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"3000\" height=\"2250\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/img_20180221_1345261662919514.jpg\" class=\"attachment-full size-full\" alt=\"\" loading=\"lazy\" align=\"none\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_mmd_3374\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"3000\" height=\"2250\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/img_20180221_103717843070337.jpg\" class=\"attachment-full size-full\" alt=\"\" loading=\"lazy\" align=\"none\" \/><\/figure>\n<figure id=\"attachment_mmd_3372\" class=\"wp-block-image aligncenter\"><img decoding=\"async\" width=\"3000\" height=\"2250\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2018\/02\/img_20180221_1046262073469346.jpg\" class=\"attachment-full size-full\" alt=\"\" loading=\"lazy\" align=\"center\" \/><\/figure>\n<p>\u4ee3\u7801\uff1a<\/p>\n<pre class=\"brush: plain; collapse: true; light: false; title: ; toolbar: true; wrap-lines: true; notranslate\" title=\"\">\n\/*\nversion 2: \n removed IC L293D\n added color LED, auto \/ manual color change\n added 3 pots\n *\/\n\n\/\/#include \n\n#define potPinR 0\n#define potPinG 1\n#define potPinB 2\n#define transistorPin 4\n#define bluePin 9\n#define greenPin 10\n#define redPin 11\n\nint redValue=0;\nint greenValue=0;\nint blueValue=0;\n\nint mButtonPin= 5;   \/\/motor button pin, digital\nint lButtonPin= 6;  \/\/ led button pin, digital\n\nint buttonState[] = {\n  LOW, LOW};    \/\/[0] &gt; motor, [1] &gt; led.\n\/\/int buttonState[1] = LOW;\nint lastButtonState[] = {\n  LOW, LOW};                  \/\/ \u8bb0\u5f55button\u524d\u4e00\u4e2a\u72b6\u6001\u503c\nint reading[] = {\n  0,0};\nlong lastDebounceTime[] = {\n  0,0};\nlong debounceDelay = 50;                    \/\/\u53bb\u9664\u6296\u52a8\u65f6\u95f4\n\nint mSwitchStatus = LOW;\nint lSwitchStatus = LOW;\nint ledMode = 1;  \/\/  0&gt;turn off, 1 &gt; auto color, 2 &gt; manual color\n\nfloat RGB1[3];\nfloat RGB2[3];\nfloat INC[3];\n\nvoid setup(){\n  \/\/  pinMode(potPin,INPUT);\n  pinMode(transistorPin,OUTPUT);\n  pinMode(potPinR,INPUT);\n  pinMode(potPinG,INPUT);\n  pinMode(potPinB,INPUT);\n  pinMode(mButtonPin, INPUT);  \/\/ motor on\/off\n  pinMode(lButtonPin, INPUT);  \/\/ led on\/off\n  Serial.begin(9600);\n\n  digitalWrite(transistorPin,HIGH);\n\n  randomSeed(millis());\n  RGB1[0]=0;\n  RGB1[1]=0;\n  RGB1[2]=0;\n  RGB2[0]=random(256);\n  RGB2[1]=random(256);\n  RGB2[2]=random(256);\n\n}\n\nvoid loop(){\n  mSwitchStatus=digitalRead(transistorPin);\n\n  buttonDebounce(mButtonPin,0);   \/\/[0] &gt; motor, [1] &gt; led.\n  buttonDebounce(lButtonPin,1);   \/\/[0] &gt; motor, [1] &gt; led.\n\n  switch(ledMode){\n  case 0:\n    lSwitchStatus=LOW;\n    offRGB();\n    redValue=0;\n    greenValue=0;\n    blueValue=0;\n    analogWrite(redPin,redValue);\n    analogWrite(greenPin,greenValue);\n    analogWrite(bluePin,blueValue);\n    break;\n\n  case 1:\n    \/*  redValue=0;\n     greenValue=100;\n     blueValue=0;\n     analogWrite(redPin,redValue);\n     analogWrite(greenPin,greenValue);\n     analogWrite(bluePin,blueValue);            *\/\n\n    for (int x=0;x motor, [1] &gt; led.\n  \/\/  delay(800);\n  \/\/  Serial.println(strf);\n\n  reading[deviceID] = digitalRead(buttonPin);   \/\/reading\u7528\u6765\u5b58\u50a8buttonPin\u7684\u6570\u636e\n\n  \/\/ \u4e00\u65e6\u68c0\u6d4b\u5230\u6570\u636e\u53d1\u751f\u53d8\u5316\uff0c\u8bb0\u5f55\u5f53\u524d\u65f6\u95f4\n  if (reading[deviceID] != lastButtonState[deviceID]) {   \n    lastDebounceTime[deviceID] = millis();\n  } \n\/*\n  Serial.print(\"ButtonPin: \");\n   Serial.print(buttonPin);\n   Serial.print(\". now: \");\n   Serial.print(millis());    \n   Serial.print(\". last: \");\n   Serial.print(lastDebounceTime[deviceID]);\n   Serial.print(\". reading: \");\n   Serial.print(reading[deviceID]);    \n   Serial.print(\". buttonState: \");\n   Serial.println(buttonState[deviceID]);    \n*\/\n\n  \/\/ \u7b49\u5f8550ms\uff0c\u518d\u8fdb\u884c\u4e00\u6b21\u5224\u65ad\uff0c\u662f\u5426\u548c\u5f53\u524dbutton\u72b6\u6001\u76f8\u540c\n  \/\/ \u5982\u679c\u548c\u5f53\u524d\u72b6\u6001\u4e0d\u76f8\u540c\uff0c\u6539\u53d8button\u72b6\u6001\n  \/\/ \u540c\u65f6\uff0c\u5982\u679cbutton\u72b6\u6001\u4e3a\u9ad8\uff08\u4e5f\u5c31\u662f\u88ab\u6309\u4e0b\uff09\uff0c\u90a3\u4e48\u5c31\u6539\u53d8\u7ee7\u7535\u5668\u7684\u72b6\u6001\n  if ((millis() - lastDebounceTime[deviceID]) &gt; debounceDelay) {\n    \/\/      Serial.println(\"&gt;100ms\");    \n    if (reading[deviceID] != buttonState[deviceID]) {\n      buttonState[deviceID] = reading[deviceID];\n      Serial.println(\"StateDiff\");\n\n      if (buttonState[deviceID] == HIGH) {\n        if(deviceID==0){  \/\/motor\n          mSwitchStatus=!mSwitchStatus;\n        }\n        else if(deviceID==1){ \/\/led\n          \/\/          Serial.print(\"ledMode: \");\n          \/\/          Serial.println(ledMode);\n          \/\/           lSwitchStatus=!lSwitchStatus;\n          if(ledMode==2){\n            ledMode=0;\n          }\n          else{\n            ledMode =ledMode+1;\n          }\n        }\n      }\n    }\n  }\n\n  digitalWrite(transistorPin,mSwitchStatus);  \n\n \/\/  Serial.print(\"Turn: \");\n \/\/ Serial.println(lSwitchStatus);\n  \/\/ \u6539\u53d8button\u524d\u4e00\u4e2a\u72b6\u6001\u503c\n  lastButtonState[deviceID] = reading[deviceID];\n\n}\n\nvoid offRGB(){\n  RGB2[0]=0;\n  RGB2[1]=0;\n  RGB2[2]=0;\n\n  for (int x=0; x&lt;3; x++){\n    INC[x] = ( RGB2[x] - RGB1[x] ) \/ 128;\n  }\n\n  for ( int x =0 ; x&lt;128; x++) {\n    redValue = int(RGB1[0]);\n    greenValue = int(RGB1[1]);\n    blueValue = int(RGB1[2]);\n    analogWrite(redPin, redValue);\n    analogWrite(greenPin, greenValue);\n    analogWrite(bluePin, blueValue);\n\n    delay(3);\n\n    RGB1[0] += INC[0];\n    RGB1[1] += INC[1];\n    RGB1[2] += INC[2];\n  }\n\n}\n\nvoid colorRGB(){\n  \/*\n   int potRed = analogRead(potRedPin);     \/\/ potRed\u5b58\u50a8\u6a21\u62df\u53e30\u8bfb\u5230\u7684\u503c\n   int potGreen = analogRead(potGreenPin); \/\/ potGreen\u5b58\u50a8\u6a21\u62df\u53e31\u8bfb\u5230\u7684\u503c\n   int potBlue = analogRead(potBluePin);  \/\/ potBlue\u5b58\u50a8\u6a21\u62df\u53e32\u8bfb\u5230\u7684\u503c\n\n   int val1 = map(potRed,0,1023,0,255);     \/\/\u901a\u8fc7map\u51fd\u6570\u8f6c\u6362\u4e3a0~255\u7684\u503c\n   int val2 = map(potGreen,0,1023,0,255);\n   int val3 = map(potBlue,0,1023,0,255);\n\n   int val1 = random(255);\n   int val2 = random(255);\n   int val3 = random(255);\n\n   *\/\n\n  randomSeed(millis());\n\n  for (int x=0; x&lt;3; x++){\n    INC[x] = ( RGB2[x] - RGB1[x] ) \/ 128;\n  }\n\n  for ( int x =0 ; x motor, [1] &gt; led.\n  buttonDebounce(lButtonPin,1);   \/\/[0] &gt; motor, [1] &gt; led.\n  }\n\n  for (int x=0;x&lt;3;x++){\n    RGB2[x] = random(256);\n    RGB2[x] = constrain(RGB2[x], 0, 255);\n    delay(20);\n  }\n\n}\n<\/pre>\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>\ufeff \ufeff \ufeff \ufeff \ufeff \ufeff \u73a9\u5177\u529f\u80fd \u51cf\u901f\u9f7f\u8f6e\u7ec4\uff0c\u628a\u7535\u673a\u901f\u5ea6\u964d\u4f4e\u3002 \u9f7f\u8f6e\u6bd4\u53ef\u4ee5\u8c03\u3002\u4e24\u6863\u53d8\u901f\u3002 \u53ea\u80fd\u505c\u8f6c\u540e\u624d\u80fd\u6362\u6321\u3002 &hellip; <a href=\"https:\/\/dingxuan.info\/wp\/?p=3375\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u9001\u7ed9LP\u7684\u4e03\u5f69\u5927\u94bb\u77f3 &#8211; 2\u6863\u53d8\u901f\u7bb1+LED\u8272\u5f69\u63a7\u5236<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[135,138,140],"class_list":["post-3375","post","type-post","status-publish","format-standard","hentry","category-live","tag-3d","tag-arduino","tag-solidworks"],"_links":{"self":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/posts\/3375","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3375"}],"version-history":[{"count":0,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/posts\/3375\/revisions"}],"wp:attachment":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}