{"product_id":"ultrasonic-radar-robot-miniradar-maker-education-tutorial-open-source-1","title":"Ultrasonic Radar Robot MiniRadar Maker Education Tutorial Open Source","description":"Wholesale electronics best price, bulk price,wholesale accessories\u003cdiv class=\"detailmodule_html\"\u003e\u003cdiv class=\"detail-desc-decorate-richtext\"\u003e\u003cdiv style=\"display:mangofig\"\u003e \n \u003cdiv style=\"height:0;overflow:hidden;\"\u003e\n   modname=ckeditor \n \u003c\/div\u003e \n \u003cdiv\u003e \n  \u003cp\u003e\u003cspan style=\"color:#FF0000\"\u003e\u003cspan style=\"font-size:22px\"\u003eoption1: rack, simple rack + screws, does not include accessories such as steering gear screens.\u003c\/span\u003e\u003c\/span\u003e\u003c\/p\u003e \n  \u003cp\u003e\u003cspan style=\"color:#FF0000\"\u003e\u003cspan style=\"font-size:22px\"\u003eOption2: a complete set of equipment rack + steering gear + ultrasonic module + screen + accessories + Arduino control board and shield board, you only need to assemble and debug the program to use.\u003c\/span\u003e\u003c\/span\u003e\u003c\/p\u003e \n  \u003cp\u003e\u003cspan style=\"color:#FF0000\"\u003e\u003cspan style=\"font-size:22px\"\u003eOption3: configuration three ¥99, rack + steering gear + ultrasonic module + screen, wire screws, etc. No arduino control board shield, you need to bring your own.\u003c\/span\u003e\u003c\/span\u003e\u003c\/p\u003e \n  \u003cp\u003e\u003cspan style=\"color:#FF0000\"\u003e\u003cspan style=\"font-size:22px\"\u003eoption4: Assembled and debugged finished product, ready to use after power-on.\u003c\/span\u003e\u003c\/span\u003e\u003c\/p\u003e \n  \u003cp\u003e\u003cspan style=\"font-size:16px\"\u003eOperation principle: The ultrasonic module can emit ultrasonic waves, and the distance of the object in front can be obtained by calculating the time length of receiving the echo. The steering gear can be positioned at any angle from 0 to 180°. The steering gear is equipped with an ultrasonic module to detect the distance of objects within 180 degrees around it. The measurement results are output through the display screen and presented graphically. A very interesting small production of A-r-d-u-i-n-o project.\u003c\/span\u003e\u003c\/p\u003e \n  \u003cp style=\"text-align:start\"\u003e \u003c\/p\u003e \n  \u003cp style=\"text-align:start\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/Hb546a1a9f72046a387cba86bf0e5e6c12.jpg\" style=\"max-width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/H1d28cf3691df4375affd5926ac1dfaa2A.jpg\" style=\"max-width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/Hd2cce894421f48cbb6674a9153775289h.jpg\" style=\"max-width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/Ha6f5052b449f431a8a9e4a4667ceb826A.jpg\" style=\"max-width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/H5cd480a965994f289e47cea6a7d42c67Z.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003c\/p\u003e \n  \u003cp style=\"text-align:start\"\u003e \u003c\/p\u003e \n  \u003cp style=\"text-align:start\"\u003e \u003c\/p\u003e \n  \u003cp\u003e\/\/TaoBao『Chuang element store』https:\/\/shop423015102.taobao.com\/\/\/Update date 2021\/03\/06\/\/MiniRadar Ultrasonic radar program\/\/Commodities corresponding to this procedure https:\/\/item.taobao.com\/item.htm?spm=a1z10.1-c.w4004-23815833841.8.4f231fe7qvLFZi\u0026amp;id=649834806872\u003c\/p\u003e \n  \u003cp\u003e\/\/GithubVersion link： https:\/\/github.com\/johnsonwust\/MiniRadar\u003c\/p\u003e \n  \u003cp\u003e#include #include #include \"Ucglib.h\" \/\/Displaylib If there is no suchlibPlease pressCtrl+Shift+I from Search in library manager ucglib，And install\u003c\/p\u003e \n  \u003cp\u003e#define trigPin 6 \/\/Ultrasonic moduleTrigmouth 6##define echoPin 5 \/\/Ultrasonic moduleechomouth 5##define ServoPin 3 \/\/Base steering gear port 3#int Ymax = 128; \/\/Vertical pixels of the screenint Xmax = 160; \/\/Horizontal pixels of the screenint Xcent = Xmax \/ 2; \/\/xMedianint base = 118; \/\/Baseline heightint scanline = 105; \/\/Radar scan line length\u003c\/p\u003e \n  \u003cp\u003eServo baseServo; Ucglib_ST7735_18x128x160_HWSPI ucg(\/*cd=*\/ 9, \/*cs=*\/ 10, \/*reset=*\/ 8);\u003c\/p\u003e \n  \u003cp\u003evoid setup(void){ ucg.begin(UCG_FONT_MODE_SOLID); \/\/Initialization screen ucg.setRotate90(); \/\/Set to horizontal screen If the direction of the screen is reversed，You can modify the function setRotate90 or setRotate270 pinMode(trigPin, OUTPUT); \/\/set uptrigPinPort mode pinMode(echoPin, INPUT); \/\/set upechoPinPort mode Serial.begin(115200); \/\/Set serial port transmission rate baseServo.attach(ServoPin); \/\/Initialize steering gear \/\/Welcome screen ucg.setFontMode(UCG_FONT_MODE_TRANSPARENT); ucg.setColor(0, 0, 100, 0); ucg.setColor(1, 0, 100, 0); ucg.setColor(2, 20, 20,20); ucg.setColor(3, 20, 20, 20); ucg.drawGradientBox(0, 0, 160, 128); ucg.setPrintDir(0); ucg.setColor(0, 5, 0); ucg.setPrintPos(27,42); ucg.setFont(ucg_font_logisoso18_tf); ucg.print(\"Mini Radar\"); ucg.setColor(0, 255, 0); ucg.setPrintPos(25,40); ucg.print(\"Mini Radar\"); ucg.setFont(ucg_font_helvB08_tf); ucg.setColor(20, 255, 20); ucg.setPrintPos(40,100); ucg.print(\"Testing...\"); baseServo.write(90); \/\/Test the operation of the base，Pay attention to detecting the position and rotation attitude of the base，Is it stuck（Or wire winding）Situation。 for(int x=0;x\u0026lt;180;x+=5) { baseServo.write(x); delay(50); } ucg.print(\"OK!\"); delay(500);\u003c\/p\u003e \n  \u003cp\u003e\/\/Clear screen \/\/ucg.clearScreen(); cls(); ucg.setFontMode(UCG_FONT_MODE_SOLID); ucg.setFont(ucg_font_orgv01_hr); }\u003c\/p\u003e \n  \u003cp\u003evoid cls(){ \/\/Clear screen ucg.setColor(0, 0, 0, 0); for(int s=0;s\u0026lt;128;s+=8) for(int t=0;t\u0026lt;160;t+=16) { ucg.drawBox(t,s,16,8); \/\/ delay(1); }\u003c\/p\u003e \n  \u003cp\u003e}\u003c\/p\u003e \n  \u003cp\u003eint calculateDistance(){ long duration; \/\/trigPinpower failure and wait for2subtle digitalWrite(trigPin, LOW); delayMicroseconds(2); \/\/trigPinPower up delayed 10subtle Power off again digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); \/\/readechoPinReturns the propagation time of the sound wave（subtle） duration = pulseIn(echoPin, HIGH); \/\/Convert echo time to distance value return duration*0.034\/2;}\u003c\/p\u003e \n  \u003cp\u003evoid fix_font() { ucg.setColor(0, 180, 0); ucg.setPrintPos(70,14); ucg.print(\"1.00\"); ucg.setPrintPos(70,52); ucg.print(\"0.50\"); ucg.setPrintPos(70,90); ucg.print(\"0.25\");}\u003c\/p\u003e \n  \u003cp\u003evoid fix(){\u003c\/p\u003e \n  \u003cp\u003eucg.setColor(0, 40, 0); \/\/Draw baseline disc ucg.drawDisc(Xcent, base+1, 3, UCG_DRAW_ALL); ucg.drawCircle(Xcent, base+1, 115, UCG_DRAW_UPPER_LEFT); ucg.drawCircle(Xcent, base+1, 115, UCG_DRAW_UPPER_RIGHT); ucg.drawCircle(Xcent, base+1, 78, UCG_DRAW_UPPER_LEFT); ucg.drawCircle(Xcent, base+1, 78, UCG_DRAW_UPPER_RIGHT); ucg.drawCircle(Xcent, base+1, 40, UCG_DRAW_UPPER_LEFT); ucg.drawCircle(Xcent, base+1, 40, UCG_DRAW_UPPER_RIGHT); ucg.drawLine(0, base+1, Xmax,base+1); ucg.setColor(0, 120, 0); \/\/Draw a scale for(int i= 40;i \u0026lt; 140; i+=2) {\u003c\/p\u003e \n  \u003cp\u003eif (i % 10 == 0) ucg.drawLine(105*cos(radians(i))+Xcent,base - 105*sin(radians(i)) , 113*cos(radians(i))+Xcent,base - 113*sin(radians(i))); else ucg.drawLine(110*cos(radians(i))+Xcent,base - 110*sin(radians(i)) , 113*cos(radians(i))+Xcent,base - 113*sin(radians(i))); } \/\/Draw some decorative patterns ucg.setColor(0,200,0); ucg.drawLine(0,0,0,18); for(int i= 0;i \u0026lt; 5; i++) { ucg.setColor(0,random(200)+50,0); ucg.drawBox(2,i*4,random(14)+2,3); }\u003c\/p\u003e \n  \u003cp\u003eucg.setColor(0,180,0); ucg.drawFrame(146,0,14,14); ucg.setColor(0,60,0); ucg.drawHLine(148,0,10); ucg.drawVLine(146,2,10); ucg.drawHLine(148,13,10); ucg.drawVLine(159,2,10); ucg.setColor(0,220,0); ucg.drawBox(148,2,4,4); ucg.drawBox(148,8,4,4); ucg.drawBox(154,8,4,4); ucg.setColor(0,100,0); ucg.drawBox(154,2,4,4);\u003c\/p\u003e \n  \u003cp\u003eucg.setColor(0,90,0); ucg.drawTetragon(62,123,58,127,98,127,102,123); ucg.setColor(0,160,0); ucg.drawTetragon(67,123,63,127,93,127,97,123); ucg.setColor(0,210,0); ucg.drawTetragon(72,123,68,127,88,127,92,123);}\u003c\/p\u003e \n  \u003cp\u003evoid loop(void){ int distance; fix(); fix_font(); \/\/Redraw screen background elements\u003c\/p\u003e \n  \u003cp\u003efor (int x=180; x \u0026gt; 4; x-=2){ \/\/Base steering gear from180~0Degree cycle baseServo.write(x); \/\/Adjust steering gear angle \/\/Draw radar scan line int f = x - 4; ucg.setColor(0, 255, 0); ucg.drawLine(Xcent, base, scanline*cos(radians(f))+Xcent,base - scanline*sin(radians(f))); f+=2; ucg.setColor(0, 128, 0); ucg.drawLine(Xcent, base, scanline*cos(radians(f))+Xcent,base - scanline*sin(radians(f))); f+=2; ucg.setColor(0, 0, 0); ucg.drawLine(Xcent, base, scanline*cos(radians(f))+Xcent,base - scanline*sin(radians(f))); ucg.setColor(0,200, 0); \/\/ranging distance = calculateDistance(); \/\/Draw a point at the corresponding position according to the measured distance if (distance \u0026lt; 100) { ucg.setColor(255,0,0); ucg.drawDisc(distance*cos(radians(x))+Xcent,-distance*sin(radians(x))+base, 1, UCG_DRAW_ALL); } else { \/\/exceed1More than meters，Draw in yellow on the edge area ucg.setColor(255,255,0); ucg.drawDisc(116*cos(radians(x))+Xcent,-116*sin(radians(x))+base, 1, UCG_DRAW_ALL); } \/\/Debug code，Output angle and ranging value Serial.print(x); Serial.print(\" , \"); Serial.println(distance);\u003c\/p\u003e \n  \u003cp\u003eif (x \u0026gt; 70 and x \u0026lt; 110) fix_font(); \/\/When the scan line coincides with the number，Redraw numbers ucg.setColor(0,155, 0); ucg.setPrintPos(0,126); ucg.print(\"DEG: \"); ucg.setPrintPos(24,126); ucg.print(x); ucg.print(\" \"); ucg.setPrintPos(125,126); ucg.print(\" \"); ucg.print(distance); ucg.print(\"cm \"); } \/\/ucg.clearScreen(); \/\/Clear screen IfarduinoInsufficient power supply，May cause white screen（Display signal interrupt）Can use cls();Function substitution ucg.clearScreen(); delay(50); cls(); \/\/In case of frequent white screen，You can use this function 。Or add external power supply fix(); fix_font(); \/\/Redraw screen background elements for (int x=1; x \u0026lt; 176; x+=2){ baseServo.write(x); \/\/Adjust steering gear angle \/\/Draw radar scan line int f = x + 4; ucg.setColor(0, 255, 0); ucg.drawLine(Xcent, base, scanline*cos(radians(f))+Xcent,base - scanline*sin(radians(f))); f-=2; ucg.setColor(0, 128, 0); ucg.drawLine(Xcent, base, scanline*cos(radians(f))+Xcent,base - scanline*sin(radians(f))); f-=2; ucg.setColor(0, 0, 0); ucg.drawLine(Xcent, base, scanline*cos(radians(f))+Xcent,base - scanline*sin(radians(f))); ucg.setColor(0, 200, 0); \/\/ranging distance = calculateDistance();\u003c\/p\u003e \n  \u003cp\u003e\/\/Draw a point at the corresponding position according to the measured distance if (distance \u0026lt; 100) { ucg.setColor(255,0,0); ucg.drawDisc(distance*cos(radians(x))+Xcent,-distance*sin(radians(x))+base, 1, UCG_DRAW_ALL); } else { \/\/exceed1More than meters，Draw in yellow on the edge area ucg.setColor(255,255,0); ucg.drawDisc(116*cos(radians(x))+Xcent,-116*sin(radians(x))+base, 1, UCG_DRAW_ALL); } \/\/Debug code，Output angle and ranging value Serial.print(x); Serial.print(\" , \"); Serial.println(distance); if (x \u0026gt; 70 and x \u0026lt; 110) fix_font(); \/\/When the scan line coincides with the number，Redraw numbers ucg.setColor(0,155, 0); ucg.setPrintPos(0,126); ucg.print(\"DEG: \"); ucg.setPrintPos(24,126); ucg.print(x); ucg.print(\" \"); ucg.setPrintPos(125,126); ucg.print(\" \"); ucg.print(distance); ucg.print(\"cm \"); } \/\/ucg.clearScreen(); \/\/ delay(50); cls();\u003c\/p\u003e \n  \u003cp\u003e}\u003c\/p\u003e \n  \u003cp style=\"text-align:start\"\u003e \u003c\/p\u003e \n  \u003cp style=\"text-align:start\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/H14646e7070124b45b9211b881fb01fddr.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/H07d166e0e649455db627be2df70abdb7R.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/He385dd4bb2bd434dbba2ae9fa2d95843h.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/H3b9f388255f3433c84e6cce741cbc548s.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/H577b369089b54c938d1e2612ee42a66a4.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/H6de4a687a0724ab7a1a69617a7be42c5G.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/H9044ba8612354d2980fcccc47fe32024X.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/H581a60c7a15b4e20b7752f8aee5c5ff3O.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/H70c483d8cbbd4947a96533e72012bcf08.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/Hde6bab0b778f4a2593e9b02c597cff407.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/Ha24c787034414a18ab1f85f3ba99a60bH.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/H1f355d9bb9064e4e82b67adf29c05185n.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/He880514c19b248f0ab1fe4980ca04490X.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/Hfca620bfa94e4e208b0368f240178074A.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/H9df76e9e16e04df1955dd87481687458X.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/H8ce792da0478449dbc827c2b2f586f83M.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/H8805e8b7db0e4d408e8108371f4e3a14B.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/H0bc1a5e4853749e7b9eac0528bbbb588U.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/H9b6d9209433f45c2aea0d86cd7f57fe3f.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003c\/p\u003e \n  \u003cp style=\"text-align:start\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/H43d083969c18429fac02406cf7f8a3c0C.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003cimg src=\"https:\/\/ae01.alicdn.com\/kf\/H37b53cd8f43b455aa7609169d4860effr.jpg\" style=\"max-width:none; width:750.0px\"\u003e\u003c\/p\u003e \n \u003c\/div\u003e \n\u003c\/div\u003e\u003c\/div\u003e\u003c\/div\u003e\r\n\n\u003cscript\u003ewindow.adminAccountId=253926457;\u003c\/script\u003e\nAbout US:\u003cbr\u003e\nWe are a foreign trade technology company headquartered in Shenzhen, specialized in serving Southeast Asian customers, providing customers with one-stop services such as electronic materials, electronic products, computers and peripheral equipment, crafts, electronic watches, wearables, overall solutions, etc. We can also help Southeast Asian customers to purchase a variety of goods from China, providing high quality products.\u003cbr\u003e\nFind the right supplier for customers in China, grow together with customers, create miracles and the future.\u003cbr\u003e\nThe founder of the company has served in the electronics industry for more than 20 years, has rich experience and technology, has its own professional electronics factory and rich supply chain.","brand":"pfdeal","offers":[{"title":"option1","offer_id":46649649332530,"sku":"","price":18.16,"currency_code":"USD","in_stock":true},{"title":"option2","offer_id":46649649365298,"sku":"","price":35.85,"currency_code":"USD","in_stock":true},{"title":"option3","offer_id":46649649398066,"sku":"","price":26.02,"currency_code":"USD","in_stock":true},{"title":"option4","offer_id":46649649430834,"sku":"","price":48.96,"currency_code":"USD","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0015\/6634\/3243\/files\/Ultrasonic-Radar-Robot-MiniRadar-Maker-Education-Tutorial-Open-Source_fd719bf8-666e-4524-9e54-7ac1eb118fe6.jpg?v=1693201284","url":"https:\/\/www.pfdeal.com\/products\/ultrasonic-radar-robot-miniradar-maker-education-tutorial-open-source-1","provider":"pfdeal","version":"1.0","type":"link"}