INHOUDSOPGAWE:

N Robot wat vertel of 'n elektroniese verskaffer u bedrieg of nie: 6 stappe
N Robot wat vertel of 'n elektroniese verskaffer u bedrieg of nie: 6 stappe

Video: N Robot wat vertel of 'n elektroniese verskaffer u bedrieg of nie: 6 stappe

Video: N Robot wat vertel of 'n elektroniese verskaffer u bedrieg of nie: 6 stappe
Video: Бен Герцель: Неудержимый рост искусственного интеллекта 2024, Julie
Anonim
'N Robot wat vertel of 'n elektroniese verskaffer jou bedrieg of nie
'N Robot wat vertel of 'n elektroniese verskaffer jou bedrieg of nie

Verlede jaar het ek en my pa na 'n nuut geopende robotika-/elektronika -winkel gegaan, baie naby aan ons woonplek. Toe ek daar inkom, was dit vol elektronika, serovs, sensors, framboospis en Arduinos. Die volgende dag gaan ons na dieselfde winkel en koop baie senors en 3 Arduino's ter waarde van ongeveer 150 dollar. Toe ek huis toe gaan, werk geen ander produkte behalwe die Arduino Mega nie. Ons is bedrieg vir ongeveer 130 dollar, wat baie is.

Daarom het ek besluit om 'n robot te skep wat ongeveer 12 sensors en 2 motors kan toets (wat steeds aan die servo werk) en kan bepaal of die produk foutief is.

Kom ons gaan reguit daarin!

Voorrade

1. Arduino UNO

2. 2,4 TFT -raakskerm

3. paar springdrade

4. sensors en motors sodat u dit kan toets (hier het ek gebruik - Bewegingsensor, MQ6 gassensor, Klanksensor, potensiometer en watervlak sensor)

Stap 1: Hoe dit werk …

Image
Image

Ek het 'n Arduino geprogrammeer vir die skep en interaktiewe UI met 'n TFT -skerm. Soos ons weet, het die TFT -skerm slegs een gratis pen, naamlik die A5 -pen. (as u die UNO gebruik). Elke sensor wat analoog penne gebruik om data te lees, is dus verenigbaar met hierdie opstelling …

In die UI kan u die agtergrondkleur van die tafelblad verander, en u kan die app oopmaak wat deur my vir Arduino ontwikkel is om sensors te toets.

By die opening van die app kan u twee opsies sien: INGANG en UITGANG. so as u op Invoer klik, wys dit 4 sensors (dit is verenigbaar met 12, maar ek moet dit nog programmeer namate ek eksamens nader … geen tyd nie: (. Dit staan enigiemand vry om die kode te wysig …)

En dit kan ook kyk of die servomotor werk of u dit in die gleuf koppel.

Kyk:

Stap 2: Laai die kode op

Die kode is 'n program van 600 reëls wat ek binne ongeveer 50 uur noukeurig gekodeer het. Dit bevat 'n paar foute, so verander dit asseblief en stuur dit vir my in my pos ([email protected]).

Laai die kode op en koppel die TFT -skild aan die Arduino. Ek beveel u aan om met die UI te speel sodat u dit beter kan verstaan.

Die kode:

#insluit

#include #include #include #define LCD_CS A3 #define LCD_CD A2 #define LCD_WR A1 #definieer LCD_RD A0 #definieer LCD_RESET A4 #define SWART 0x0000 #define BLUE 0x001F #define NAVY 0x000F #define RED 0xF800 #define RED 0xF800 #define RED 0xF800 #define RED 0xF800 # define MAGENTA 0xF81F # define GEEL 0xFFE0 # define WHITE 0xFFFF # define Light 0xC618 # define PURPLE 0x780F # define OLIVE 0x7BE0 # define Seleksie # define YP A1 # define XM A2 # define YM 7 # define XP 6 # define TS_MINX 940 # define TS_MINY 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); #define BOXSIZE 40 #define PENRADIUS 3 #define MINPRESSURE 10 #define MAXPRESSURE 1000 int sound; char toestand = 6; int raak = 0; int kleur = SWART; int redir = 0; int ota; ongeldige opstelling () {Serial.begin (9600); tft.reset (); tft.setFont (& FreeMonoBoldOblique12pt7b); tft.begin (0x9325); tft.setRotation (45); tft.setTextSize (0.5); tft.fillScreen (WIT); tft.setCursor (60, 160); tft.setTextColor (SWART); tft.print ("Veeg om aan te meld"); } leemte lus () {float sensorVoltage; float sensorValue; TSPoint p = ts.getPoint (); pinMode (XM, OUTPUT); pinMode (YP, OUTPUT); as (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) {touch = 26; }} if (raak == 1 && staat == 6) {tft.setRotation (0); tft.fillScreen (kleur); klank = 0; tft.fillRect (200, 180, 80, 140, WIT); tft.drawRect (201, 181, 81, 141, SWART); tft.fillRect (80, 30, 100, 100, CYAN); tft.drawRect (81, 31, 101, 101, SWART); tft.fillRect (10, 30, 50, 100, NAVY); tft.drawRect (11, 31, 51, 101, SWART); tft.fillRect (10, 180, 30, 120, PURPLE); tft.drawRect (11, 181, 31, 121, SWART); tft.fillRect (45, 180, 30, 120, BLOU); tft.drawRect (46, 181, 31, 121, SWART); tft.fillRect (80, 180, 30, 120, CYAN); tft.drawRect (81, 181, 31, 121, SWART); tft.fillRect (115, 180, 30, 120, GROEN); tft.drawRect (116, 181, 31, 121, SWART); tft.fillRect (150, 180, 30, 120, GEEL); tft.drawRect (151, 181, 31, 121, SWART); tft.fillTriangle (210, 30, 210, 50, 220, 40, WIT); tft.fillRect (200, 35, 12, 12, WIT); tft.drawTriangle (210, 30, 210, 50, 220, 40, SWART); tft.drawRect (200, 35, 12, 12, SWART); tft.drawCircle (210, 40, 14, WIT); //tft.fillTriange(a1, b1, a2, b2, c1, c2, ROOI); tft.setRotation (45); tft.setCursor (200, 20); tft.print ("Instellings"); tft.fillRoundRect (45, 75, 75, 75, 4, WIT); tft.drawRoundRect (45, 75, 75, 75, 4, SWART); tft.fillRect (75, 75, 15, 30, SWART); tft.fillRect (75, 120, 15, 30, SWART); tft.fillRect (90, 105, 30, 15, SWART); tft.fillRect (45, 105, 30, 15, SWART); staat = 7; raak = 0; ota = 0; } as (raak == 2) {tft.fillScreen (WIT); tft.setRotation (0); tft.fillTriangle (210, 30, 210, 50, 220, 40, WIT); tft.fillRect (200, 35, 12, 12, WIT); tft.drawTriangle (210, 30, 210, 50, 220, 40, SWART); tft.drawRect (200, 35, 12, 12, SWART); tft.drawCircle (210, 40, 14, SWART); tft.setRotation (45); tft.fillTriangle (270, 40, 270, 20, 260, 30, SWART); tft.drawLine (300, 30, 270, 30, SWART); tft.setCursor (20, 200); tft.print ("personalisering"); tft.setCursor (20, 170); tft.print ("afmeld"); tft.setCursor (20, 140); tft.print ("randapparatuur"); tft.setCursor (20, 110); tft.print ("About"); raak = 1; toestand = 2; } as (raak == 10 && staat == 2) {tft.fillScreen (WIT); tft.setCursor (10, 160); tft.setTextColor (SWART); tft.print ("Geskep en ontwikkel"); tft.setCursor (100, 190); tft.print ("deur:"); tft.setCursor (60, 220); tft.print ("'n Tiener uit Indië"); tft.setRotation (0); tft.fillTriangle (210, 30, 210, 50, 220, 40, WIT); tft.fillRect (200, 35, 12, 12, WIT); tft.drawTriangle (210, 30, 210, 50, 220, 40, SWART); tft.drawRect (200, 35, 12, 12, SWART); tft.drawCircle (210, 40, 14, SWART); tft.setRotation (45); tft.fillTriangle (270, 40, 270, 20, 260, 30, SWART); tft.drawLine (300, 30, 270, 30, SWART); staat = 6; } as (raak == 11 && staat == 2) {tft.fillScreen (WIT); tft.setCursor (60, 40); tft.print ("Kies 'n"); tft.setCursor (40, 60); tft.print ("agtergrondkleur"); tft.fillRect (60, 180, 45, 45, ROOI); tft.fillRect (120, 180, 45, 45, GEEL); tft.fillRect (180, 180, 45, 45, BLOU); tft.fillRect (240, 180, 45, 45, GROEN); 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, WIT); tft.drawRect (60, 80, 45, 45, SWART); tft.fillRect (120, 80, 45, 45, SWART); 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, WIT); tft.fillRect (200, 35, 12, 12, WIT); tft.drawTriangle (210, 30, 210, 50, 220, 40, SWART); tft.drawRect (200, 35, 12, 12, SWART); tft.drawCircle (210, 40, 14, SWART); tft.setRotation (45); tft.fillTriangle (270, 40, 270, 20, 260, 30, SWART); tft.drawLine (300, 30, 270, 30, SWART); staat = 6; as (redir == 1) {color = WHITE; } as (redir == 2) {color = SWART; } as (redir == 3) {color = OLIVE; } as (redir == 4) {color = PURPLE; } if (redir == 5) {color = MAGENTA; } as (redir == 6) {color = NAVY; } if (redir == 7) {color = LIGHTGREY; } as (redir == 8) {color = CYAN; } as (redir == 9) {color = ROOI; } as (redir == 10) {color = GEEL; } as (redir == 11) {color = BLUE; } as (redir == 12) {color = GROEN; }} as (raak == 26) {ota = 1; tft.fillScreen (WIT); tft.setRotation (0); tft.fillTriangle (210, 30, 210, 50, 220, 40, WIT); tft.fillRect (200, 35, 12, 12, WIT); tft.drawTriangle (210, 30, 210, 50, 220, 40, SWART); tft.drawRect (200, 35, 12, 12, SWART); tft.drawCircle (210, 40, 14, SWART); tft.setRotation (45); tft.fillTriangle (270, 40, 270, 20, 260, 30, SWART); tft.drawLine (300, 30, 270, 30, SWART); tft.setRotation (1); tft.setCursor (30, 80); tft.print ("Invoer"); tft.setCursor (30, 150); tft.print ("Uitset"); tft.drawRect (25, 130, 90, 30, SWART); tft.draWRect (25, 60, 90, 30, SWART); as (p.x> 190 && p.x 30 && p.y <90) {tft.setCursor (150, 220); tft.print ("Watervlak"); tft.setCursor (150, 170); tft.print ("Gaspeil"); tft.setCursor (150, 120); tft.print ("Afstand"); tft.setCursor (150, 70); tft.print ("Klank"); raak = 1; toestand = 2; }}} terwyl (klank == 1) {tft.fillScreen (WHITE); sensorValue = analogRead (A5); sensorVoltage = sensorValue; tft.setCursor (60, 160); tft.print (sensorVoltage); Serial.println ("Klankvlak ="); Serial.println (sensorVoltage); vertraging (1000); as (klank == 0) {breek; }}}}

Stap 3: biblioteke benodig:

  • Adafruit_GFX.h
  • Adafruit_TFTLCD.h
  • Raakskerm.h

Github skakel vir dieselfde:

github.com/adafruit/Adafruit-GFX-Library

github.com/adafruit/TFTLCD-Library

github.com/adafruit/Adafruit_TouchScreen

Stap 4: Die verbindings

Klap alles saam
Klap alles saam

U benodig 6 springdrade. 3 reuntjies en 3 wyfies. soldeer hulle direk aan die Arduino -bord soos volg:

Stap 5: Klap alles saam

Steek die drade in die arduino (verwys na die prent), gebruik indien nodig 'n bietjie lijmpistool …

Heg dan die TFT -skild aan en toets dan u sensors.

Dankie dat u heeltemal afgeskakel het. Maak seker dat u vir my stem as u van mening was dat hierdie projek uniek en nuttig was

Gelukkig om te wees en pasop vir elektroniese swendelaars?

Stap 6: Verdere verbeterings:

  • Meer sensorversoenbaarheid
  • Servomotorkode moes voltooi word
  • Nog 'n app wat met Bluetooth -modules gekoppel kan word, sodat ons 'n Bluetooth -aangedrewe robot daarmee kan beheer.
  • Foutoplossings

Aanbeveel: