在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

電子發(fā)燒友App

硬聲App

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示
創(chuàng)作
電子發(fā)燒友網(wǎng)>電子資料下載>電子資料>使用MKR IoT Bundle中組件和紙板創(chuàng)建拼圖盒

使用MKR IoT Bundle中組件和紙板創(chuàng)建拼圖盒

2022-11-01 | zip | 0.23 MB | 次下載 | 免費

資料介紹

描述

有時讓貴重物品遠離窺探可能很困難,除非你把它放在一個大保險箱或類似的東西里……但誰有空間呢?

相反,請使用 MKR IoT Bundle 中的組件和一些紙板創(chuàng)建您自己的拼圖盒!我們不能保證您財物的安全,但至少對于潛在的小偷來說這將是一種有趣的威懾。

當然,我們建議您將糖果存放在那里……而不是真正的貴重物品。

簡而言之

為了打開用伺服電機保持關(guān)閉的盒子,您必須轉(zhuǎn)動電位器,直到獲得正確的組合。可以通過在線應(yīng)用程序Blynk設(shè)置組合LED 將幫助您猜測,給您顏色反饋:您越接近顏色越暖。

當猜到正確的組合時,蜂鳴器將開始播放歌曲,而伺服器將打開盒子。

為了創(chuàng)建我們的拼圖框,我們需要以下組件:

  • 蜂鳴器
  • RGB LED
  • 3個電位器
  • 液晶屏
  • 伺服電機
?
?

學習目標

  • 介紹Blynk互聯(lián)網(wǎng)平臺
  • 液晶顯示屏的接線和使用
  • 用蜂鳴器播放星球大戰(zhàn)主題

想知道更多?

教程是讓您熟悉 MKR1000 和 IoT 的一系列實驗的一部分。所有實驗都可以使用 MKR IoT Bundle 中包含的組件構(gòu)建。

  • 拼圖盒

介紹布林克

Blynk是一款流行的物聯(lián)網(wǎng)移動應(yīng)用程序,它讓我們可以隨時隨地輕松控制與互聯(lián)網(wǎng)連接的 Arduino

它在Kickstarter上成立,并迅速成為該領(lǐng)域最常用的應(yīng)用程序之一,這要歸功于其出色的文檔和簡單性。

開始使用 Blynk

創(chuàng)建一個新項目真的很容易,只需按照這幾個簡單的步驟或看一下 Blynk 的官方入門

成功創(chuàng)建新項目后,您還應(yīng)該通過郵件收到Auth Token。這是將硬件連接到智能手機所需的唯一標識符。您創(chuàng)建的每個新項目都將擁有自己的 Auth Token。

為了將 Arduino 連接到應(yīng)用程序,我們需要安裝Blynk 庫。如果您使用的是 Arduino Web 編輯器,則當您將其包含在草圖中時,該庫將自動下載,否則您可以從庫管理器下載該庫。

現(xiàn)在我們準備好了。上傳此草圖并使用滑塊查看結(jié)果:

#include <WiFi101.h> 
#include <BlynkSimpleWiFiShield101.h> 
const char* ssid = SECRET_SSID;    //  your network SSID (name) 
const char* password = SECRET_PSWD;  // your network password 
char auth[] = SECRET_TOKEN; // your Blynk API token 
// Variables to store the combination value 
// Set the intitial combination to ( 1 1 1 ) 
int SliderValueOne = 1; 
int SliderValueTwo = 1; 
int SliderValueThree = 1; 
// Blynk functions to retrive values 
BLYNK_WRITE(V1) { 
 SliderValueOne = param.asInt(); // assigning incoming value from pin V1 to a variable 
} 
BLYNK_WRITE(V2) { 
 SliderValueTwo = param.asInt(); // assigning incoming value from pin V1 to a variable 
} 
BLYNK_WRITE(V3) { 
 SliderValueThree = param.asInt(); // assigning incoming value from pin V1 to a variable 
} 
void setup() { 
 Serial.begin(9600);  
 Blynk.begin(auth, ssid, password); // start Blynk functionalities and connect to WiFi
} 
void loop() { 
 // Variambles to temporarily store the combination 
 int Temp_Slider_One_value = SliderValueOne; 
 int Temp_Slider_Two_value = SliderValueTwo; 
 int Temp_Slider_Three_value = SliderValueThree; 
 Blynk.run(); // poll new combination values from the online app 
 // check if combination values are changed and print them on the console 
 if(Temp_Slider_One_value != SliderValueOne || Temp_Slider_Two_value != SliderValueTwo || Temp_Slider_Three_value != SliderValueThree){ 
   Serial.print("New combination: "); 
   Serial.print(SliderValueOne); 
   Serial.print(" "); 
   Serial.print(SliderValueTwo); 
   Serial.print(" "); 
   Serial.println(SliderValueThree); 
 }  
} 
?
poYBAGNgl1aAK35xAADVisRVYVQ025.png
更改時在串行監(jiān)視器上打印組合
?

使用液晶屏

是時候連接屏幕了!

LCD 屏幕易于使用,但需要大量電線,因此請準備好證明您的耐心。

?
pYYBAGNgl1mASid0AAEV0pMKiYM969.png
液晶屏接線
?

請注意,我們使用的是 5V 電源和 220 歐姆電阻

可以調(diào)節(jié)亮度,將模擬引腳 3 的輸出值從 0 更改為 255,其中 0 為最大值。

analogWrite(A3, 0); 

現(xiàn)在我們可以上傳示例草圖,看看是否一切正常。

// include the library code: 
#include  
// initialize the library by associating any needed LCD interface pin 
// with the arduino pin number it is connected to 
const int rs = 12, en = 11, d4 = 2, d5 = 3, d6 = 4, d7 = 5; 
LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 
void setup() { 
 analogWrite(A3, 0); // Set the brightness to its maximum value 
 // set up the LCD's number of columns and rows: 
 lcd.begin(16, 2); 
 // Print a message to the LCD. 
 lcd.print("hello, world!"); 
} 
void loop() { 
 // set the cursor to column 0, line 1 
 // (note: line 1 is the second row, since counting begins with 0): 
 lcd.setCursor(0, 1); 
 // print the number of seconds since reset: 
 lcd.print(millis() / 1000); 
} 

添加電位器

要讀取電位器的值,我們只需要analogRead() 正確引腳上的一個。我們將它們連接到模擬引腳 0、1、2。

?
poYBAGNgl16AMC7jAAEg93WD-4A028.png
電位器接線
?

請注意,電位器的值范圍從 0 到 1023,因此無法猜測組合。要將這些值從 0 映射到 9,我們將使用該map() 函數(shù),

 int PotOne = map(analogRead(A0), 0, 1023, 0, 9); 

您可以使用此示例代碼在 LCD 屏幕上打印電位器的值。

#include  
// LCD screen pins 
const int rs = 12, 
         en = 11, 
         d4 = 2, 
         d5 = 3, 
         d6 = 4, 
         d7 = 5; 
LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 
void setup() { 
 analogWrite(A3, 0); // set the brightness of the LCD screen to the maximum value 
 Serial.begin(9600);  
 lcd.begin(16, 2); // begin LCD screen with 16 columns and 2 rows 
} 
void loop() { 
 int PotOne = map(analogRead(A0), 0, 1023, 0, 9); 
 int PotTwo = map(analogRead(A1), 0, 1023, 0, 9); 
 int PotThree = map(analogRead(A2), 0, 1023, 0, 9); 
 lcd.setCursor(0, 0); 
 lcd.print(PotOne); 
 lcd.setCursor(2, 0); 
 lcd.print(PotTwo); 
 lcd.setCursor(4, 0); 
 lcd.print(PotThree); 
} 

添加 RGB LED

我們將使用 RGB LED 作為反饋來幫助人們猜測組合,他們越接近正確的值,LED 的顏色就越暖和,從藍色、淺綠色、黃色和紅色。

?
?
?
?
pYYBAGNgl2CANj6AAABEIt9nvT8582.png
?
1 / 2 ? LED 引腳
?

您可以使用此示例草圖來查看 RGB 的實際效果!

// RGB LED pins 
int redPin = 6; 
int greenPin = 8; 
int bluePin = 7; 
void setup() { 
 pinMode(redPin, OUTPUT); 
 pinMode(greenPin, OUTPUT); 
 pinMode(bluePin, OUTPUT);   
 Serial.begin(9600);  
} 
void loop() { 
   setColor(0, 0, 255); // blue 
   delay(1000); 
   setColor(0, 255, 255); // aqua 
   delay(1000); 
   setColor(255, 255, 0); // yellow 
   delay(1000); 
   setColor(255, 0, 0); // Red 
   delay(1000); 
} 
// Send RGB values to the LED pins 
void setColor(int red, int green, int blue){ 
 analogWrite(redPin, red); 
 analogWrite(greenPin, green); 
 analogWrite(bluePin, blue);   
} 

將其連接到 Blynk

現(xiàn)在我們準備把東西放在一起:將電路板連接到 Blynk,將電位器連接到 LCD 屏幕,并在組合正確時使 LED 閃爍綠色。

  • 請注意,giveColorFeedback() 當每個電位器的絕對值接近某個閾值時,我們將使用該功能設(shè)置 LED 的顏色以正確組合。
void giveColorFeedback(int PotOne, int PotTwo, int PotThree){...}
  • 我們還將使用這些變量來存儲從應(yīng)用程序發(fā)送的值以及組合。
int SliderValueOne = 1; 
int SliderValueTwo = 1; 
int SliderValueThree = 1; 

請注意,初始值設(shè)置為 1,只有在您修改應(yīng)用程序上滑塊的值時才會更改。如果您重置板,組合將恢復(fù)為默認值。

  • 布爾變量bool start = true; 用于檢測何時已經(jīng)猜到組合,以避免在每個循環(huán)中重新打開框。

上傳此示例草圖以查看它的實際效果:

#include  
#include  
#include  
#include  
// RGB LED pins 
int redPin = 6; 
int greenPin = 8; 
int bluePin = 7; 
const char* ssid = SECRET_SSID;    //  your network SSID (name) 
const char* password = SECRET_PSWD;  // your network password 
char auth[] = SECRET_TOKEN; // your Blynk API token 
// LCD screen pins 
const int rs = 12, 
         en = 11, 
         d4 = 2, 
         d5 = 3, 
         d6 = 4, 
         d7 = 5; 
bool start = true; 
// Variables to store the combination value 
// Set the intitial combination to ( 1 1 1 ) 
int SliderValueOne = 1; 
int SliderValueTwo = 1; 
int SliderValueThree = 1; 
// Blynk functions to retrive values 
BLYNK_WRITE(V1) { 
 SliderValueOne = param.asInt(); // assigning incoming value from pin V1 to a variable 
} 
BLYNK_WRITE(V2) { 
 SliderValueTwo = param.asInt(); // assigning incoming value from pin V1 to a variable 
} 
BLYNK_WRITE(V3) { 
 SliderValueThree = param.asInt(); // assigning incoming value from pin V1 to a variable 
} 
LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 
void setup() { 
 pinMode(redPin, OUTPUT); 
 pinMode(greenPin, OUTPUT); 
 pinMode(bluePin, OUTPUT);   
 analogWrite(A3, 0); // set the brightness of the LCD screen to the maximum value 
 Serial.begin(9600);  
 lcd.begin(16, 2); // begin LCD screen with 16 columns and 2 rows 
 Blynk.begin(auth, ssid, password); // start Blynk functionalities 
} 
void loop() { 
 // Variambles to temporarily store the combination 
 int Temp_Slider_One_value = SliderValueOne; 
 int Temp_Slider_Two_value = SliderValueTwo; 
 int Temp_Slider_Three_value = SliderValueThree; 
 Blynk.run(); // poll new combination values from the online app 
 // check if combination values are changed and print them on the console 
 if(Temp_Slider_One_value != SliderValueOne || Temp_Slider_Two_value != SliderValueTwo || Temp_Slider_Three_value != SliderValueThree){ 
   Serial.print("New combination: "); 
   Serial.print(SliderValueOne); 
   Serial.print(" "); 
   Serial.print(SliderValueTwo); 
   Serial.print(" "); 
   Serial.println(SliderValueThree); 
 }  
 int PotOne = map(analogRead(A0), 0, 1023, 0, 9); 
 int PotTwo = map(analogRead(A1), 0, 1023, 0, 9); 
 int PotThree = map(analogRead(A2), 0, 1023, 0, 9); 
 lcd.setCursor(0, 0); 
 lcd.print(PotOne); 
 lcd.setCursor(2, 0); 
 lcd.print(PotTwo); 
 lcd.setCursor(4, 0); 
 lcd.print(PotThree); 
 if (start) { 
   giveColorFeedback(PotOne, PotTwo, PotThree); 
   if (PotOne == SliderValueOne && PotTwo == SliderValueTwo && PotThree == SliderValueThree) { 
     blinkGreenLed(); 
     start = false; 
   } 
 } 
 if(!start) { 
   if(PotOne == 0 && PotTwo == 0 && PotThree == 0){ 
     start = true; 
   } 
 } 
} 
// Give feedback based on how close the potentiometer are to the combination value  
// The more it's close the warmer is the color of the LED 
void giveColorFeedback(int PotOne, int PotTwo, int PotThree) { 
 if (abs(PotOne - SliderValueOne) <= 1 && abs(PotTwo - SliderValueTwo) <= 1 && abs(PotThree - SliderValueThree) <= 1 ) { 
   // Red 
   setColor(255, 0, 0); 
 } 
 else   if (abs(PotOne - SliderValueOne) <= 3 && abs(PotTwo - SliderValueTwo) <= 3 && abs(PotThree - SliderValueThree) <= 3 ) { 
   // yellow 
   setColor(255, 255, 0); 
 } 
   else   if (abs(PotOne - SliderValueOne) <= 4 && abs(PotTwo - SliderValueTwo) <= 4 && abs(PotThree - SliderValueThree) <= 4 ) { 
   // aqua 
   setColor(0, 255, 255);   
 } 
 else { 
   // blue 
   setColor(0, 0, 255); 
 } 
} 
void blinkGreenLed() { 
 for (int a = 0; a < 2; a++) { 
   for (int b = 0; b <= 255; b += 5) { 
     setColor(0, b, 0);  
     delay(5); 
   } 
   for (int b = 255; b >= 0; b -= 5) { 
     setColor(0, b, 0);  
     delay(5); 
   } 
 } 
 for (int b = 0; b <= 255; b += 5) { 
   setColor(0, b, 0);  
   delay(5); 
 } 
} 
// Send RGB values to the LED pins 
void setColor(int red, int green, int blue){ 
 analogWrite(redPin, red); 
 analogWrite(greenPin, green); 
 analogWrite(bluePin, blue);   
} 

添加蜂鳴器

打開盒子時,我們將使用蜂鳴器播放旋律。更確切地說,我們將播放星球大戰(zhàn)主題曲!

連接蜂鳴器很簡單:

?
poYBAGNgl2OAQrpXAAEgpXUDiWU162.png
蜂鳴器接線
?

上傳此示例代碼并收聽:

const int c = 261; 
const int d = 294; 
const int e = 329; 
const int f = 349; 
const int g = 391; 
const int gS = 415; 
const int a = 440; 
const int aS = 455; 
const int b = 466; 
const int cH = 523; 
const int cSH = 554; 
const int dH = 587; 
const int dSH = 622; 
const int eH = 659; 
const int fH = 698; 
const int fSH = 740; 
const int gH = 784; 
const int gSH = 830; 
const int aH = 880; 
int counter = 0; 
#define buzzerPin 1 
void setup() { 
 pinMode(buzzerPin, OUTPUT); 
 Serial.begin(9600);  
} 
void loop() { 
 play_jingle(); 
 delay(3000); 
} 
void play_jingle() 
{ 
 beep(a, 500); 
 beep(a, 500);     
 beep(a, 500); 
 beep(f, 350); 
 beep(cH, 150);   
 beep(a, 500); 
 beep(f, 350); 
 beep(cH, 150); 
 beep(a, 650); 
 delay(500); 
 beep(eH, 500); 
 beep(eH, 500); 
 beep(eH, 500);   
 beep(fH, 350); 
 beep(cH, 150); 
 beep(gS, 500); 
 beep(f, 350); 
 beep(cH, 150); 
 beep(a, 650); 
 delay(500); 
} 
void beep(int note, int duration) 
{ 
 //Play tone on buzzerPin 
 tone(buzzerPin, note, duration); 
 //Stop tone on buzzerPin 
 noTone(buzzerPin); 
 delay(50); 
 //Increment counter 
 counter++; 
} 

添加伺服電機

伺服電機是我們盒子的鎖,當密碼正確時,我們需要它旋轉(zhuǎn)90度,這樣盒子才會打開。

連接伺服只需要三根線。

?
pYYBAGNgl2aAGgmHAACqTsHxSNQ153.png
伺服接線
?

為了將其旋轉(zhuǎn) 90 度,我們將使用以下函數(shù):

#include  
int pos = 0;    // variable to store the servo position 
Servo myservo;  // create servo object to control a servo 
void setup() { 
 myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
 myservo.write(pos); // set the servo in position 0 
} 
void loop() { 
     open_the_box(); 
     delay(2000); 
     close_the_box(); 
     delay(2000); 
} 
void open_the_box(){ 
     for (pos = 0; pos <= 90; pos += 1) { // goes from 0 degrees to 90 degrees 
     myservo.write(pos);              // tell servo to go to position in variable 'pos' 
     delay(15);                       // waits 15ms for the servo to reach the position 
   } 
} 
void close_the_box(){ 
   for (pos = 90; pos >= 0; pos -= 1) { // goes from 90 degrees to 0 degrees 
     myservo.write(pos);              // tell servo to go to position in variable 'pos' 
     delay(15);                       // waits 15ms for the servo to reach the position 
   } 
}  

請注意,為了將伺服器轉(zhuǎn)回并關(guān)閉盒子,您只需將所有電位器轉(zhuǎn)為 0。

建立你的拼圖盒

它不會是一個沒有盒子的盒子,所以請下載下面的案例文件并將其用作構(gòu)建您自己的指南。

請注意,我們使用了 2 毫米厚的紙板。


下載該資料的人也在下載 下載該資料的人還在閱讀
更多 >

評論

查看更多

下載排行

本周

  1. 1RA4L1硬件手冊
  2. 21.89 MB  |  2次下載  |  免費
  3. 2RA4L1_SENSOR-V1原理圖
  4. 754.36 KB  |  2次下載  |  免費
  5. 3RA4L1數(shù)據(jù)手冊
  6. 1.88 MB  |  1次下載  |  免費
  7. 4電子元件FCO-6P-PJ系列超低相噪低抖動晶體振蕩器:規(guī)格參數(shù)與應(yīng)用領(lǐng)域介紹
  8. 3.66 MB  |  次下載  |  免費
  9. 5單片機c語言編程實例大全
  10. 0.66 MB   |  次下載  |  1 積分
  11. 6DS-AN5V PB00 CN-V1
  12. 610.46 KB  |  次下載  |  免費
  13. 7電橋前端共模電感有效抑制干擾電路分享
  14. 0.06 MB   |  次下載  |  免費
  15. 8蘋果A1465 820-00164圖紙
  16. 1.41 MB   |  次下載  |  免費

本月

  1. 1晶體三極管的電流放大作用詳細說明
  2. 0.77 MB   |  32次下載  |  2 積分
  3. 2九陽豆?jié){機高清原理圖
  4. 2.47 MB   |  28次下載  |  1 積分
  5. 3雙極型三極管放大電路的三種基本組態(tài)的學習課件免費下載
  6. 4.03 MB   |  25次下載  |  1 積分
  7. 4AIWA HS-J303 MKⅡ維修手冊
  8. 22.47 MB   |  24次下載  |  10 積分
  9. 5多級放大電路的學習課件免費下載
  10. 1.81 MB   |  21次下載  |  2 積分
  11. 6AIWA HS-J202/HS-J202M/HS-J800維修手冊
  12. 13.60 MB   |  16次下載  |  10 積分
  13. 7人形機器人電機驅(qū)動和傳感報告
  14. 4.27 MB   |  13次下載  |  免費
  15. 8Altium Designer元件庫
  16. 17.11 MB   |  9次下載  |  免費

總榜

  1. 1matlab軟件下載入口
  2. 未知  |  935127次下載  |  10 積分
  3. 2開源硬件-PMP21529.1-4 開關(guān)降壓/升壓雙向直流/直流轉(zhuǎn)換器 PCB layout 設(shè)計
  4. 1.48MB  |  420063次下載  |  10 積分
  5. 3Altium DXP2002下載入口
  6. 未知  |  233089次下載  |  10 積分
  7. 4電路仿真軟件multisim 10.0免費下載
  8. 340992  |  191382次下載  |  10 積分
  9. 5十天學會AVR單片機與C語言視頻教程 下載
  10. 158M  |  183338次下載  |  10 積分
  11. 6labview8.5下載
  12. 未知  |  81586次下載  |  10 積分
  13. 7Keil工具MDK-Arm免費下載
  14. 0.02 MB  |  73814次下載  |  10 積分
  15. 8LabVIEW 8.6下載
  16. 未知  |  65988次下載  |  10 積分
主站蜘蛛池模板: 久久亚洲国产成人影院 | 欧美一区二区在线观看视频 | 亚洲欧美卡通 动漫 丝袜 | 四虎国产永久在线观看 | 国产资源网站 | 午夜艹逼 | 久久国产精品久久久久久久久久 | 色六月婷婷 | 日本一区二区三区视频在线 | 色视频www在线播放国产人成 | 国产精品久久久久久久久kt | 在线观看的黄网 | ts国产 | 九九国产在线 | 毛片免费网 | 成人免费看片视频色多多 | 国产精品美女一区二区三区 | 欧美在线视频看看 | 三级理论手机在线观看视频 | 三级亚洲 | 伊人不卡久久大香线蕉综合影院 | 美女又黄又免费的视频 | 在线视频毛片 | 91久久婷婷国产综合精品青草 | 欧美艹逼视频 | 国产精品美女免费视频大全 | 日本加勒比一区 | 中文字幕一区二区三区精彩视频 | 欧美成人免费 | 8050网午夜一级毛片免费不卡 | 好吊日在线| 婷婷免费视频 | 直接观看黄网站免费视频 | 国模精品 | 好紧好爽太大了h快穿 | 精品国产一区二区三区成人 | 国产专区视频 | 久久99热狠狠色精品一区 | 成人国产精品一级毛片视频 | 特级全黄一级毛片免费 | yy6080三级理论韩国日本 |