Mundarija:

Elektron sotuvchi sizni aldayaptimi yoki yo'qligini aytadigan robot: 6 qadam
Elektron sotuvchi sizni aldayaptimi yoki yo'qligini aytadigan robot: 6 qadam

Video: Elektron sotuvchi sizni aldayaptimi yoki yo'qligini aytadigan robot: 6 qadam

Video: Elektron sotuvchi sizni aldayaptimi yoki yo'qligini aytadigan robot: 6 qadam
Video: VidCommissions Review-«НЕ ПОКУПАЙТЕ ЭТОГО БЕЗ МОИХ», «ПОЛЬЗОВАТЕ... 2024, Noyabr
Anonim
Robot, elektronika sotuvchisi sizni aldayaptimi yoki yo'qligini aytadi
Robot, elektronika sotuvchisi sizni aldayaptimi yoki yo'qligini aytadi

O'tgan yili men va dadam biz yashayotgan joyga juda yaqinda ochilgan robototexnika/elektronika do'koniga bordik. Men u erga kirganimda, u elektronika, serovlar, datchiklar, malina pis va Arduinosga to'la edi. Ertasi kuni biz o'sha do'konga bordik va 150 senaga yaqin bo'lgan ko'plab senorlarni va 3 Arduino sotib oldik. Uyga qaytganimdan so'ng, Arduino Mega -dan boshqa hech qanday mahsulot ishlamadi. Bizni taxminan 130 dollarga aldashdi, bu juda ko'p.

Shunday qilib, men 12 ta sensor va 2 ta dvigatelni sinovdan o'tkaza oladigan robotni yaratishga qaror qildim (hali servoda ishlaydi) va mahsulotning nosozligini aniqlay oladi.

Keling, bunga to'g'ridan -to'g'ri kiraylik!

Ta'minotlar

1. Arduino UNO

2. 2,4 dyuymli TFT sensorli ekran

3. bir nechta o'tish simlari

4. Siz ularni sinab ko'rishingiz uchun sensorlar va motorlar (bu erda men ishlatganman - Harakat sensori, MQ6 gaz sensori, Ovoz sensori, potensiometr va suv sathi sensori)

1 -qadam: Bu qanday ishlaydi …

Image
Image

Men Arduino -ni TFT displeyli interaktiv interfeys yaratish uchun dasturlashtirdim. Ma'lumki, TFT displeyida faqat bitta bo'sh pin bor, ya'ni A5 pinli. (agar siz BMTdan foydalansangiz). Ma'lumotni o'qish uchun analog pinlardan foydalanadigan har qanday sensor ushbu sozlash bilan mos keladi …

UI -da siz ish stoli fon rangini o'zgartirishingiz mumkin va men sensorlarni sinab ko'rish uchun men Arduino uchun ishlab chiqqan dasturni ochishingiz mumkin.

Ilovani ochganingizda, siz ikkita variantni ko'rishingiz mumkin: INPUT va OUTPUT. Agar siz "Kirish" tugmachasini bosgan bo'lsangiz, u 4 ta sensorni ko'rsatadi (u 12 bilan mos keladi, lekin men hali dasturlamayman, chunki menda imtihonlar yaqinlashmoqda …. vaqt yo'q:(. Har kim kodni tahrir qilishi mumkin …)

Shuningdek, u sizning servo dvigatelingiz uni uyaga ulashini tekshirishi mumkin.

qarang:

2 -qadam: Kodni yuklash

Kod - bu taxminan 50 soat ichida sinchkovlik bilan kodlangan 600 qatorli dastur. U bir nechta xatolarga ega, shuning uchun uni o'zgartiring va menga pochta orqali yuboring ([email protected]).

Kodni yuklang va TFT qalqonini Arduino -ga ulang. Sizga yaxshiroq UI bilan o'ynashni maslahat beraman.

Kod:

#qo'shing

#include #include #dexine LCD_CS A3 #define LCD_CD A2 #define LCD_WR A1 #define LCD_RD A0 #define LCD_RESET A4 #define BLACK 0x0000 #define BLUE 0x001F #define NAVYFF0x00F0x00F #define MAGENTA 0xF81F #define YELLOW 0xFFE0 #define WHITE 0xFFFF #define LIGHTGREY 0xC618 #define PURPLE 0x780F #define OLIVE 0x7BE0 #define Tanlash #define Tin Adefine TP2. 160 #define TS_MAXX 160 #define TS_MAXY 970 TouchScreen ts = TouchScreen (XP, YP, XM, YM, 300); Adafruit_TFTLCD tft (LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET); #dexine BOXSIZE 40 #defrine PENRADIUS 3 #deinine MINPRESSURE 10 #dexine MAXPRESSURE 1000 int tovush; char holati = 6; int touch = 0; int rangi = QARA; int redir = 0; int ota; void setup () {Serial.begin (9600); tft.reset (); tft.setFont (& FreeMonoBoldOblique12pt7b); tft.begin (0x9325); tft.setRotation (45); tft.setTextSize (0,5); tft.fillScreen (oq); tft.setCursor (60, 160); tft.setTextColor (Qora); tft.print ("Kirish uchun suring"); } void loop () {float sensorVoltage; suzish sensori qiymati; TSPoint p = ts.getPoint (); pinMode (XM, OUTPUT); pinMode (YP, OUTPUT); agar (pz> MINPRESSURE && pz 240 && px 130 && py 240 && px 20 && py 240 && px 20 && py 160 && px 12 && py 240 && px 20 && py 240 && px 20 && py 40 && px 15 && py 150 && px 40 && py 150 && px 80 && py 150 && px 120 && py 150 && px 170 && py 90 && px 40 && py 90 && px 80 && py 90 && px 120 && py 150 && px 170 && py 150 && px 170 && py 150 && px 170 && py 150 && px 170 && py 150 && px 170 && py 100 && px 20 && py 200 && px 100 && py 100 && px 20 && py 100 && px 20 && py 100 && px 20 && py <100) {tegish = 26; }} if (tegish == 1 && state == 6) {tft.setRotation (0); tft.fillScreen (rang); ovoz = 0; tft.fillRect (200, 180, 80, 140, oq); tft.drawRect (201, 181, 81, 141, Qora); tft.fillRect (80, 30, 100, 100, CYAN); tft.drawRect (81, 31, 101, 101, QORA); tft.fillRect (10, 30, 50, 100, NAVY); tft.drawRect (11, 31, 51, 101, QORA); tft.fillRect (10, 180, 30, 120, PURPLE); tft.drawRect (11, 181, 31, 121, Qora); tft.fillRect (45, 180, 30, 120, KO'K); tft.drawRect (46, 181, 31, 121, Qora); tft.fillRect (80, 180, 30, 120, CYAN); tft.drawRect (81, 181, 31, 121, Qora); tft.fillRect (115, 180, 30, 120, Yashil); tft.drawRect (116, 181, 31, 121, Qora); tft.fillRect (150, 180, 30, 120, SARI); tft.drawRect (151, 181, 31, 121, Qora); tft.fillTriangle (210, 30, 210, 50, 220, 40, oq); tft.fillRect (200, 35, 12, 12, oq); tft.drawTriangle (210, 30, 210, 50, 220, 40, QORA); tft.drawRect (200, 35, 12, 12, QORA); tft.drawCircle (210, 40, 14, oq); //tft.fillTriange(a1, b1, a2, b2, c1, c2, RED); tft.setRotation (45); tft.setCursor (200, 20); tft.print ("Sozlamalar"); tft.fillRoundRect (45, 75, 75, 75, 4, oq); tft.drawRoundRect (45, 75, 75, 75, 4, QORA); tft.fillRect (75, 75, 15, 30, Qora); tft.fillRect (75, 120, 15, 30, Qora); tft.fillRect (90, 105, 30, 15, Qora); tft.fillRect (45, 105, 30, 15, Qora); davlat = 7; tegish = 0; ota = 0; } agar (tegish == 2) {tft.fillScreen (WHITE); tft.setRotation (0); tft.fillTriangle (210, 30, 210, 50, 220, 40, oq); tft.fillRect (200, 35, 12, 12, oq); tft.drawTriangle (210, 30, 210, 50, 220, 40, QORA); tft.drawRect (200, 35, 12, 12, QORA); tft.drawCircle (210, 40, 14, Qora); tft.setRotation (45); tft.fillTriangle (270, 40, 270, 20, 260, 30, Qora); tft.drawLine (300, 30, 270, 30, Qora); tft.setCursor (20, 200); tft.print ("shaxsiylashtirish"); tft.setCursor (20, 170); tft.print ("chiqish"); tft.setCursor (20, 140); tft.print ("tashqi qurilmalar"); tft.setCursor (20, 110); tft.print ("Haqida"); teginish = 1; holat = 2; } agar (tegish == 10 && hol == 2) {tft.fillScreen (WHITE); tft.setCursor (10, 160); tft.setTextColor (Qora); tft.print ("Yaratilgan va ishlab chiqilgan"); tft.setCursor (100, 190); tft.print ("tomonidan:"); tft.setCursor (60, 220); tft.print ("Hindistonlik o'smir"); tft.setRotation (0); tft.fillTriangle (210, 30, 210, 50, 220, 40, oq); tft.fillRect (200, 35, 12, 12, oq); tft.drawTriangle (210, 30, 210, 50, 220, 40, QORA); tft.drawRect (200, 35, 12, 12, QORA); tft.drawCircle (210, 40, 14, Qora); tft.setRotation (45); tft.fillTriangle (270, 40, 270, 20, 260, 30, Qora); tft.drawLine (300, 30, 270, 30, Qora); davlat = 6; } if (touch == 11 && state == 2) {tft.fillScreen (WHITE); tft.setCursor (60, 40); tft.print ("Tanlash"); tft.setCursor (40, 60); tft.print ("fon rangi"); tft.fillRect (60, 180, 45, 45, RED); tft.fillRect (120, 180, 45, 45, SARI); tft.fillRect (180, 180, 45, 45, moviy); tft.fillRect (240, 180, 45, 45, Yashil); tft.fillRect (60, 130, 45, 45, MAGENTA); tft.fillRect (120, 130, 45, 45, NAVY); tft.fillRect (180, 130, 45, 45, LIGHTGREY); tft.fillRect (240, 130, 45, 45, CYAN); tft.fillRect (60, 80, 45, 45, oq); tft.drawRect (60, 80, 45, 45, Qora); tft.fillRect (120, 80, 45, 45, Qora); tft.fillRect (180, 80, 45, 45, OLIVE); tft.fillRect (240, 80, 45, 45, PURPLE); tft.setRotation (0); tft.fillTriangle (210, 30, 210, 50, 220, 40, oq); tft.fillRect (200, 35, 12, 12, oq); tft.drawTriangle (210, 30, 210, 50, 220, 40, QORA); tft.drawRect (200, 35, 12, 12, QORA); tft.drawCircle (210, 40, 14, Qora); tft.setRotation (45); tft.fillTriangle (270, 40, 270, 20, 260, 30, Qora); tft.drawLine (300, 30, 270, 30, Qora); davlat = 6; if (redir == 1) {color = WHITE; } if (redir == 2) {color = QARA; } if (redir == 3) {color = OLIVE; } if (redir == 4) {color = PURPLE; } if (redir == 5) {color = MAGENTA; } if (redir == 6) {color = NAVY; } if (redir == 7) {color = LIGHTGREY; } if (redir == 8) {color = CYAN; } if (redir == 9) {color = RED; } if (redir == 10) {color = SARI; } if (redir == 11) {color = KO'Z; } if (redir == 12) {color = Yashil; }} if (tegish == 26) {ota = 1; tft.fillScreen (oq); tft.setRotation (0); tft.fillTriangle (210, 30, 210, 50, 220, 40, oq); tft.fillRect (200, 35, 12, 12, oq); tft.drawTriangle (210, 30, 210, 50, 220, 40, QORA); tft.drawRect (200, 35, 12, 12, QORA); tft.drawCircle (210, 40, 14, Qora); tft.setRotation (45); tft.fillTriangle (270, 40, 270, 20, 260, 30, Qora); tft.drawLine (300, 30, 270, 30, Qora); tft.setRotation (1); tft.setCursor (30, 80); tft.print ("Kirish"); tft.setCursor (30, 150); tft.print ("Chiqish"); tft.drawRect (25, 130, 90, 30, Qora); tft.drawRect (25, 60, 90, 30, Qora); if (p.x> 190 && p.x 30 && p <y <90) {tft.setCursor (150, 220); tft.print ("Suv sathi"); tft.setCursor (150, 170); tft.print ("Gaz darajasi"); tft.setCursor (150, 120); tft.print ("Masofa"); tft.setCursor (150, 70); tft.print ("Ovoz"); teginish = 1; holat = 2; }}} while (tovush == 1) {tft.fillScreen (OQ); sensorValue = analogRead (A5); sensorVoltaj = sensorValue; tft.setCursor (60, 160); tft.print (sensor kuchlanish); Serial.println ("Ovoz darajasi ="); Serial.println (sensor kuchlanish); kechikish (1000); if (tovush == 0) {tanaffus; }}}}

3 -qadam: Kutubxonalar kerak:

  • Adafruit_GFX.h
  • Adafruit_TFTLCD.h
  • TouchScreen.h

Github havolalari bir xil:

github.com/adafruit/Adafruit-GFX-Library

github.com/adafruit/TFTLCD-Library

github.com/adafruit/Adafruit_TouchScreen

4 -qadam: Ulanishlar

Hammasini Birga Qoqing
Hammasini Birga Qoqing

Sizga 6 ta o'tish simlari kerak. 3 erkak va 3 urg'ochi. ularni to'g'ridan -to'g'ri Arduino kartasiga lehimlang:

5 -qadam: Hammasini bir -biriga urish

Arduino -ga simlarni ulang (rasmga qarang), agar kerak bo'lsa, yopishqoq tabancadan foydalaning …

Keyin TFT qalqonini ulang va sensorlaringizni tekshiring.

Barchasini pastga aylantirganingiz uchun tashakkur. Agar siz ushbu loyiha o'ziga xos va foydali deb hisoblasangiz, menga ovoz berishga ishonch hosil qiling

Baxtli bo'lasizmi va Electronics firibgarlaridan ehtiyot bo'lasizmi?

6 -qadam: qo'shimcha yaxshilanishlar:

  • Sensorlarning ko'proq mosligi
  • Servo dvigatel kodini tugatish kerak edi
  • Bluetooth modullari bilan aloqa o'rnatadigan yana bir ilova, bunda biz Bluetooth bilan ishlaydigan robotni boshqaramiz.
  • Xatoliklar tuzatildi

Tavsiya: