option1: rack, simple rack + screws, does not include accessories such as steering gear screens.
Option2: 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.
option3: Assembled and debugged finished product, ready to use after power-on.
Operation 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.
![](https://ae01.alicdn.com/kf/Hb546a1a9f72046a387cba86bf0e5e6c12.jpg)
![](https://ae01.alicdn.com/kf/H1d28cf3691df4375affd5926ac1dfaa2A.jpg)
![](https://ae01.alicdn.com/kf/Hd2cce894421f48cbb6674a9153775289h.jpg)
![](https://ae01.alicdn.com/kf/Ha6f5052b449f431a8a9e4a4667ceb826A.jpg)
![](https://ae01.alicdn.com/kf/H5cd480a965994f289e47cea6a7d42c67Z.jpg)
//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&id=649834806872
//GithubVersion link£º https://github.com/johnsonwust/MiniRadar
#include #include #include "Ucglib.h" //Displaylib If there is no suchlibPlease pressCtrl+Shift+I from Search in library manager ucglib£¬And install
#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
Servo baseServo; Ucglib_ST7735_18x128x160_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
void 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<180;x+=5) { baseServo.write(x); delay(50); } ucg.print("OK!"); delay(500);
//Clear screen //ucg.clearScreen(); cls(); ucg.setFontMode(UCG_FONT_MODE_SOLID); ucg.setFont(ucg_font_orgv01_hr); }
void cls(){ //Clear screen ucg.setColor(0, 0, 0, 0); for(int s=0;s<128;s+=8) for(int t=0;t<160;t+=16) { ucg.drawBox(t,s,16,8); // delay(1); }
}
int 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;}
void 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");}
void fix(){
ucg.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 < 140; i+=2) {
if (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 < 5; i++) { ucg.setColor(0,random(200)+50,0); ucg.drawBox(2,i*4,random(14)+2,3); }
ucg.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);
ucg.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);}
void loop(void){ int distance; fix(); fix_font(); //Redraw screen background elements
for (int x=180; x > 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 < 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 > 70 and x < 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 < 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();
//Draw a point at the corresponding position according to the measured distance if (distance < 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 > 70 and x < 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();
}
![](https://ae01.alicdn.com/kf/H14646e7070124b45b9211b881fb01fddr.jpg)
![](https://ae01.alicdn.com/kf/H07d166e0e649455db627be2df70abdb7R.jpg)
![](https://ae01.alicdn.com/kf/He385dd4bb2bd434dbba2ae9fa2d95843h.jpg)
![](https://ae01.alicdn.com/kf/H3b9f388255f3433c84e6cce741cbc548s.jpg)
![](https://ae01.alicdn.com/kf/H577b369089b54c938d1e2612ee42a66a4.jpg)
![](https://ae01.alicdn.com/kf/H6de4a687a0724ab7a1a69617a7be42c5G.jpg)
![](https://ae01.alicdn.com/kf/H9044ba8612354d2980fcccc47fe32024X.jpg)
![](https://ae01.alicdn.com/kf/H581a60c7a15b4e20b7752f8aee5c5ff3O.jpg)
![](https://ae01.alicdn.com/kf/H70c483d8cbbd4947a96533e72012bcf08.jpg)
![](https://ae01.alicdn.com/kf/Hde6bab0b778f4a2593e9b02c597cff407.jpg)
![](https://ae01.alicdn.com/kf/Ha24c787034414a18ab1f85f3ba99a60bH.jpg)
![](https://ae01.alicdn.com/kf/H1f355d9bb9064e4e82b67adf29c05185n.jpg)
![](https://ae01.alicdn.com/kf/He880514c19b248f0ab1fe4980ca04490X.jpg)
![](https://ae01.alicdn.com/kf/Hfca620bfa94e4e208b0368f240178074A.jpg)
![](https://ae01.alicdn.com/kf/H9df76e9e16e04df1955dd87481687458X.jpg)
![](https://ae01.alicdn.com/kf/H8ce792da0478449dbc827c2b2f586f83M.jpg)
![](https://ae01.alicdn.com/kf/H8805e8b7db0e4d408e8108371f4e3a14B.jpg)
![](https://ae01.alicdn.com/kf/H0bc1a5e4853749e7b9eac0528bbbb588U.jpg)
![](https://ae01.alicdn.com/kf/H9b6d9209433f45c2aea0d86cd7f57fe3f.jpg)
![](https://ae01.alicdn.com/kf/H43d083969c18429fac02406cf7f8a3c0C.jpg)
![](https://ae01.alicdn.com/kf/H37b53cd8f43b455aa7609169d4860effr.jpg)