久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 4215|回復: 1
打印 上一主題 下一主題
收起左側

制作分享:女神生日不知道送什么禮物,不如手工打造一顆arduino心愿球

[復制鏈接]
跳轉到指定樓層
樓主
ID:487444 發表于 2019-3-29 18:04 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
本帖最后由 arduinoxyz 于 2019-3-29 18:48 編輯

心愿球
由黃銅棒制成,采用自由球形態連接 18 顆發光 LED。制作出來的實物圖如下:

硬件材料
1*黃銅棒
18*貼片 LED
1*ATmega8L 芯片
1*CR2032 紐扣電池
1*開關
天體
主要挑戰是用黃銅棒彎成圓形,看起來像一個天體。我用 6 根銅棒豎直排列(經度)和 3 根銅棒
水平排列(緯度)構建一個球。這樣子就總共有 18 個交叉點用于焊接 LED。在球體的底部有一個
環形開口,為的是最終可以更好的放入芯片、電池等元器件。

首先,把銅棒彎成圓形。我最開始找到一個直徑為 50 毫米的鐵罐,可以在彎曲時用底蓋固定銅
棒。彎曲銅棒后,把其剪斷并把兩端焊接在一起,形成一個漂亮的環。在一張紙上畫出相同的形
狀,可以幫助你匹配最完美的圓形。為了制作更小的圓環,我使用了其他直徑的瓶。使用與你的
直徑相匹配的東西,身邊上到處都是圓形的東西!

接下來,我把 LED 焊接到三個 50mm 環上。我在一張紙上畫了一個模板。我采用是黃色和紅色
LED。黃色和紅色,因為它比藍色或白色更節能。

接著,我把帶有 LED 的環焊接到基環上。我用一塊膠帶把基環固定在桌子上,修剪了垂直環的底
部并把它們焊接到環上,形成了一個皇冠。第一個環焊接成一體,第二個和第三個環切成兩半,
形成球體的平頂。

最后一步是最讓人沮喪和耗時的。把 LED 與彎曲桿相互連接以形成水平環。我把剩下的環一個一
個地切開,以適應垂直環之間的空間并求佛一樣地焊接。

我想到一種放置 LED 的簡單方法。 兩個 LED 在鄰近的垂直環(地面)上彼此面對,它們與一根彎
曲的桿連接,該桿是水平環(電源線)的一部分。最終得到 18 個 LED,分為 9 個部分。

溫馨提醒:經常測試 LED 是否仍是好的,否則你需要在最后重做這件事,這是一種可怕的又振奮
人心的測試。
如果你只是希望它發光并且不關心任何動畫。你可以立即停止閱讀,把 CR2032 紐扣電池和開關放
入內部。通過 68Ω 限流電阻把 LED 與電池連接,就可以使其發光!把電池焊接到黃銅線時,請確
保不要過熱,否則可能會導致電池過熱。

如果你像我一樣,愛 Arduino 并希望讓它變得聰明并且有一點樂趣,讓我們把微控制器放入其
中!我使用的是 ATmega8L 芯片——與 Arduino NANO 相同的封裝,但內存更少,功耗更低。L 意
味著它具有 2.7 - 5V 的寬工作電壓范圍,這在使用 3V 紐扣電池時非常棒。另一方面,由于它是
TQF32 封裝,因此焊接到銅棒上是一個不小的挑戰,但外觀和效果都很好。


電路原理圖如下:


Arduino源代碼
  1. #define LEDS 9

  2. byte leds[] = {
  3.   5, 19, 17, // bottom
  4.   6, 1, 15, // middle
  5.   8, 21, 13 // top
  6. };

  7. #define ON true
  8. #define OFF false

  9. // variables for pattern timing
  10. unsigned long currentMillis = millis();
  11. unsigned long previousMillis = 0;
  12. unsigned long millisInterval = 3
  13. 00;

  14. // variables for software PWM
  15. unsigned long currentMicros = micros();
  16. unsigned long previousMicros = 0;
  17. // this is the frequency of the sw PWM
  18. // frequency = 1/(2 * microInterval)
  19. unsigned long microInterval = 250;

  20. const byte pwmMax = 100;

  21. // fading (for the timing)
  22. int fadeIncrement = 1;

  23. // typedef for properties of each sw pwm pin
  24. typedef struct pwmPins {
  25.   int pin;
  26.   int pwmValue;
  27.   bool pinState;
  28.   int pwmTickCount;
  29. } pwmPin;

  30. // create the sw pwm pins
  31. // these can be any I/O pin
  32. // that can be set to output!
  33. const int pinCount = 9;
  34. const byte pins[pinCount] = {
  35.   5, 19, 17, // bottom
  36.   6, 1, 15, // middle
  37.   8, 21, 13 // top
  38. };

  39. pwmPin myPWMpins[pinCount];

  40. // function to "setup" the sw pwm pin states
  41. // modify to suit your needs
  42. // this creates an alternating fade pattern
  43. void setupPWMpins() {
  44.   for (int index=0; index < pinCount; index++) {
  45.     myPWMpins[index].pin = pins[index];

  46.     // mix it up a little bit
  47.     // changes the starting pwmValue for odd and even
  48.     if (index % 2)
  49.       myPWMpins[index].pwmValue = 25;
  50.     else
  51.       myPWMpins[index].pwmValue = 75;

  52.     myPWMpins[index].pinState = ON;
  53.     myPWMpins[index].pwmTickCount = 0;

  54.     // unlike analogWrite(), this is necessary
  55.     pinMode(pins[index], OUTPUT);
  56.   }
  57. }

  58. void pwmFadePattern() {
  59.   // go through each sw pwm pin, and increase
  60.   // the pwm value. this would be like
  61.   // calling analogWrite() on each hw pwm pin
  62.   for (int index=0; index < pinCount; index++) {
  63.     myPWMpins[index].pwmValue += fadeIncrement;
  64.     if (myPWMpins[index].pwmValue > 100)
  65.       myPWMpins[index].pwmValue = 0;
  66.   }
  67. }

  68. void handlePWM() {
  69.   currentMicros = micros();
  70.   // check to see if we need to increment our PWM counters yet
  71.     if (currentMicros - previousMicros >= microInterval) {
  72.     // Increment each pin's counter
  73.     for (int index=0; index < pinCount; index++) {
  74.     // each pin has its own tickCounter
  75.       myPWMpins[index].pwmTickCount++;

  76.     // determine if we're counting on or off time
  77.       if (myPWMpins[index].pinState == ON) {
  78.         // see if we hit the desired on percentage
  79.         // not as precise as 255 or 1024, but easier to do math
  80.         if (myPWMpins[index].pwmTickCount >= myPWMpins[index].pwmValue) {
  81.           myPWMpins[index].pinState = OFF;
  82.         }
  83.       } else {
  84.         // if it isn't on, it is off
  85.         if (myPWMpins[index].pwmTickCount >= pwmMax) {
  86.           myPWMpins[index].pinState = ON;
  87.           myPWMpins[index].pwmTickCount = 0;
  88.         }
  89.       }
  90.       // could probably use some bitwise optimization here, digitalWrite()
  91.       // really slows things down after 10 pins.
  92.       digitalWrite(myPWMpins[index].pin, myPWMpins[index].pinState);
  93.     }
  94.     // reset the micros() tick counter.
  95.     digitalWrite(13, !digitalRead(13));
  96.     previousMicros = currentMicros;
  97.   }
  98. }

  99. void setup() {
  100.   setupPWMpins();
  101.   //pinMode(13, OUTPUT);
  102. }

  103. void loop() {
  104.   // this is the magic for sw pwm
  105.   // need to call this anytime you
  106.   // have a long operation
  107.   handlePWM();

  108.   // check timer for fading pattern
  109.   // this would be the same
  110.   // if we used analogWrite()
  111.   currentMillis = millis();
  112.   if (currentMillis - previousMillis >= millisInterval) {
  113.     // moved to own funciton for clarity
  114.     pwmFadePattern();

  115.     // setup clock for next tick
  116.     previousMillis = currentMillis;
  117.   }
  118. }
復制代碼

評分

參與人數 1黑幣 +100 收起 理由
admin + 100 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩
回復

使用道具 舉報

沙發
ID:479945 發表于 2019-4-10 12:36 | 只看該作者
好玩有趣的arduino交互設計
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 国产成人精品久久二区二区 | 一区二区在线看 | 亚洲高清在线视频 | 91在线视频免费观看 | 在线观看亚洲欧美 | 91丨九色丨国产在线 | 日本精品久久久久久久 | 欧美 日韩 综合 | 国产精品久久一区 | 三区在线 | 在线观看免费观看在线91 | 国产亚洲精品精品国产亚洲综合 | 九九99久久 | 久在线观看 | 欧美黄在线观看 | 成人在线不卡 | 波多野结衣av中文字幕 | www久久av| 国产亚洲精品久久情网 | 久久精品国产a三级三级三级 | 精品一区二区三区四区视频 | 国产成人久久av免费高清密臂 | 欧美成年网站 | 青青久久久 | 亚洲国产精品久久久久秋霞不卡 | 最新国产精品 | 性色综合 | 成人午夜激情 | 国产高清在线视频 | 亚洲av毛片| 91在线精品秘密一区二区 | 一区天堂| 成人精品在线视频 | 99热精品6 | 日韩精品1区2区 | 免费在线观看毛片 | 日韩精品免费视频 | 国产一区二区在线免费观看 | 欧美 视频 | 精品国产一区久久 | 亚洲日本欧美日韩高观看 |