{"id":6961,"date":"2020-08-24T17:32:00","date_gmt":"2020-08-24T15:32:00","guid":{"rendered":"https:\/\/www.carrera-fun.com\/?p=6961"},"modified":"2025-01-10T12:27:15","modified_gmt":"2025-01-10T11:27:15","slug":"mobile-speed-radar","status":"publish","type":"post","link":"https:\/\/www.carrera-fun.com\/?p=6961&lang=en","title":{"rendered":"Mobile speed radar"},"content":{"rendered":"<div class=\"wp-block-image is-resized\">\n<figure class=\"alignright size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"532\" height=\"300\" src=\"https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/DSC_6025_lt.png\" alt=\"\" class=\"wp-image-2821\" srcset=\"https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/DSC_6025_lt.png 532w, https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/DSC_6025_lt-300x169.png 300w\" sizes=\"auto, (max-width: 532px) 100vw, 532px\" \/><\/figure>\n<\/div>\n\n\n<p>We always ask ourselves the question \u00ab\u00a0What is the fastest car?\u00a0\u00bb. Sometimes the difference is so big that the answer is easy. But sometimes, it is not easy. We can also ask ourselves the following question: \u00ab\u00a0Who is the fastest driver?\u00a0\u00bb with the same car. I had made an electronic assembly controlled by a Rasberry Pi but it was not easy to install, finally it took a few minutes. I wanted to make a faster, more flexible and not too expensive system. I chose an Arduino Nano with which I had already made some assemblies.<\/p>\n\n\n<div class=\"wp-block-image is-resized\">\n<figure class=\"alignright size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"532\" height=\"300\" src=\"https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/DSC_6024_lt.png\" alt=\"\" class=\"wp-image-2819\" srcset=\"https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/DSC_6024_lt.png 532w, https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/DSC_6024_lt-300x169.png 300w\" sizes=\"auto, (max-width: 532px) 100vw, 532px\" \/><\/figure>\n<\/div>\n\n\n<p><strong>Material :<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>1 arduino Nano (3\u20ac)<\/li>\n\n\n\n<li>1 arduino nano support (2\u20ac)<\/li>\n\n\n\n<li>1 9V power supply (2\u20ac)<\/li>\n\n\n\n<li>2 infrared proximity sensors (3\u20ac for 10)<\/li>\n\n\n\n<li>1 LCD screen (3.5\u20ac)<\/li>\n\n\n\n<li>3 sets of 4 Dupont wires (1\u20ac)<\/li>\n<\/ul>\n\n\n\n<p><strong>Principle:<\/strong><\/p>\n\n\n<div class=\"wp-block-image is-resized\">\n<figure class=\"alignright size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"411\" height=\"245\" src=\"https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/ecran.png\" alt=\"\" class=\"wp-image-2820\" srcset=\"https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/ecran.png 411w, https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/ecran-300x179.png 300w\" sizes=\"auto, (max-width: 411px) 100vw, 411px\" \/><\/figure>\n<\/div>\n\n\n<p>Two proximity sensors detect the car, the Arduino informed of the passage of the car, notes the time of passage with a precision of the microsecond. Then the micro controller calculates the difference between the two times, which gives the duration. Knowing the distance between the 2 sensors, it calculates the speed. Then the information is sent to the LCD screen. As the display is large, we calculate and display the number of revolutions (or measurements), the minimum, the maximum and the average of the values.<\/p>\n\n\n<div class=\"wp-block-image is-resized\">\n<figure class=\"alignright size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"532\" src=\"https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/DSC_6026_lt.png\" alt=\"\" class=\"wp-image-2822\" srcset=\"https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/DSC_6026_lt.png 300w, https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/DSC_6026_lt-169x300.png 169w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/figure>\n<\/div>\n\n\n<p>So that all the elements do not move around, I put everything in a box. The morning breakfast was very useful in my research. This yellow box is the ideal element with its cover and its size.<\/p>\n\n\n\n<p>The cover allows to fix the sensors, and can be easily removed. The side of the box will accommodate the display. The bottom of the box will be pierced to let the power cord pass through.<\/p>\n\n\n\n<p>At this stage, visually, the fault that I find is this solid yellow color, I will have to find stickers to personalize this radar.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"451\" src=\"https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/DSC_6103.jpg\" alt=\"\" class=\"wp-image-2827\" srcset=\"https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/DSC_6103.jpg 800w, https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/DSC_6103-300x169.jpg 300w, https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/DSC_6103-768x433.jpg 768w, https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/DSC_6103-600x338.jpg 600w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>Inside, we see that it is simple, there are just a few wires between each element. Below, we see the 2 sensors fixed on plastic corners.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"451\" src=\"https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/DSC_6104.jpg\" alt=\"\" class=\"wp-image-2826\" srcset=\"https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/DSC_6104.jpg 800w, https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/DSC_6104-300x169.jpg 300w, https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/DSC_6104-768x433.jpg 768w, https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/DSC_6104-600x338.jpg 600w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>Here is the assembly plan of the elements, note that you have to pay attention to the pin numbers of the sensors. You have to be consistent with those indicated in the program.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"705\" src=\"https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/projet_vitesse_1_bb-1024x705.png\" alt=\"\" class=\"wp-image-2828\" srcset=\"https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/projet_vitesse_1_bb-1024x705.png 1024w, https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/projet_vitesse_1_bb-300x207.png 300w, https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/projet_vitesse_1_bb-768x529.png 768w, https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/projet_vitesse_1_bb-1536x1058.png 1536w, https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/projet_vitesse_1_bb-600x413.png 600w, https:\/\/www.carrera-fun.com\/wp-content\/uploads\/2020\/08\/projet_vitesse_1_bb.png 1956w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Here is the program for the Arduino.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/Libraries \n#include &lt;Wire.h&gt;  \n#include &lt;LiquidCrystal_I2C.h&gt;\n\nLiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  \/\/ Set the LCD I2C address, if it's not working try 0x27.\n\nconst int sensorPin = A0;\nint outputValue = 0;\nconst int IR1 = 4;\nconst int IR2 = 5;\n\nint compteur1 = 1;      \/\/ variable enregistre un passage compteur 1\nint compteur2 = 1;      \/\/ variable enregistre un passage compteur 2\nlong temps1=millis();    \/\/ Variable prise de temps pour IR 1\nlong temps2=millis();    \/\/ Variable prise de temps pour IR 2\nlong temps3 = 0;         \/\/ Variable pour le calcul du temps reel passe\nfloat V = 0.0;            \/\/ Variable Vitesse\nfloat TTS = 0.0;          \/\/ Variable temps passe en secondes\nfloat VKM = 0.0;          \/\/ Variable vitesse en KM\/H\nfloat VKMN = 0.0;         \/\/ Variable vitesse en N\nfloat VKMH0 = 0.0;        \/\/ Variable vitesse en H0\n\nfloat V_min = 99999999;        \/\/ Vitesse min\nfloat V_max = 0.0;        \/\/ Vitesse max\nfloat V_moy = 0.0;        \/\/ Vitesse moy\nfloat V_som = 0.0;        \/\/ Vitesse som\n\nString texte=\"\";\nint tours=0;\n\nvoid setup(){\n  lcd.begin(20,4);   \/\/ iInit the LCD for 16 chars 2 lines\n  lcd.backlight();   \/\/ Turn on the backligt (try lcd.noBaklight() to turn it off)\n  lcd.setCursor(0,0); \/\/First line\n  lcd.print(\"*** attente  ***\");\n  lcd.setCursor(0,1); \/\/Second line\n  lcd.print(\"*** vehicule ***\");\n  lcd.setCursor(0,2); \/\/3eme line\n  lcd.print(\"***   SLOT   ***\");\n  lcd.setCursor(0,3); \/\/4eme line\n  lcd.print(\"***  RACING  ***\");\n  \/\/ capteurs\n  pinMode(IR1,INPUT);\n  pinMode(IR2,INPUT);\n  \/\/Serial.begin(9600);\n}\n\nvoid loop(){\n  \n  int valIR1 = digitalRead(IR1);  \n  \/\/ Lecture de broche A2 et mise du resultat dans la variable valIR1\n  int valIR2 = digitalRead(IR2);   \n  \/\/ Lecture de broche A3 et mise du resultat dans la variable valIR2\n \n   if(valIR1 == LOW &amp;&amp; compteur1 == 1 &amp;&amp; compteur2 == 1) {  \n   \/\/ Si passage devant IR1 ET compteur1 = 1 alors ....\n   temps1=micros();       \/\/ enregistrement dans temps1 de la valeur millis\n   compteur1 = compteur1 + 1;   \n  \/\/ On rajoute +1 a compteur1 ce qui empeche le remplacement de la valeur de temps1   \n  \/\/Serial.print(temps1);\n  \/\/Serial.println();\n   } \n \n   if(valIR2 == LOW &amp;&amp; compteur2 == 1 &amp;&amp; compteur1 == 2) {   \n   \/\/ Si passage devant IR2 ET compteur2 = 1 alors .... \n   temps2=micros();      \/\/ enregistrement dans temps1 de la valeur millis    \n   compteur2 = compteur2 + 1; \n  \/\/ On rajoute +1 a compteur2 ce qui empeche le remplacement de la valeur de temps2    \n  \/\/Serial.print(temps2);\n  \/\/Serial.println();\n   }\n\n   if(compteur1 &gt; 1 &amp;&amp; compteur2 &gt; 1) {   \n       \/\/ Si les valeurs de Compteur1 ET de compteur2 sont differente de 1 alors le calcul peut debuter\n      tours=tours+1;\n       temps3 = (temps2 - temps1);       \n       \/\/ temps en millisecondes passez entre les deux capteurs\n  \/\/Serial.print(temps3);\n  \/\/Serial.println();\n  \/\/Serial.print(\"----\");\n  \/\/Serial.println();\n\n     \n       TTS = ((float)temps3 \/ 1000000.0);          \n       \/\/ conversion milisecondes en secondes\n     \n       V = (0.05 \/ (float)TTS)*100;               \n       \/\/ calcul de d\/t, ma distance est ici de 5 cm, soit 0,05 m\n       \/\/ en cm\/s\n      V_som =V_som+V;\n      V_moy=V_som\/tours;\n      if(V &lt; V_min) {\n        V_min=V;\n      }\n      if(V &gt; V_max) {\n        V_max=V;\n      }\n      \/\/texte=String(V)+\"cm\/s -\"+String(tours)+\"    \";\n      affichage(String(V),String(tours),String(V_min),String(V_max),String(V_moy));\n      delay(500);  \/\/ delais de 10 secondes avant reprise du programme \n        \/\/ Pour permettre la liberation de la zone IR\n     \n        compteur1=1;  \/\/ Variable remise a 1\n        compteur2=1;  \/\/ Variable remise a 1\n        temps1 = 0;   \/\/ Variable remise a 0\n        temps2= 0;    \/\/ Variable remise a 0\n   }\n \n  \/\/delay(10);\n  \n}\n\nvoid  affichage(String vitesse,String tours,String V_min, String V_max ,String V_moy) {\n\n  lcd.backlight(); \n  \/\/lcd.noBacklight();\n  \n  lcd.clear();\n  lcd.setCursor(0,0); \/\/First line\n  lcd.print(vitesse+\"cm\/s\");\n  lcd.setCursor(0,1); \/\/Second line\n  lcd.print(tours+\" tours\");\n  lcd.setCursor(0,2); \/\/3eme line\n  lcd.print(V_min+\" a \"+V_max);\n  lcd.setCursor(0,3); \/\/4eme line\n  lcd.print(\"Moy. \"+V_moy);\n  \n}<\/code><\/pre>\n\n\n\n<p>If you want more information on the implementation to send the program to the Arduino, you can consult the following article: https:\/\/www.framboise314.fr\/commencer-avec-larduino\/<\/p>\n\n\n\n<p>So there you have it, you have a radar that you just have to place on the edge of the track and then connect to the mains. It is also possible to use a 9V battery and a small adapter to power the Arduino, but the autonomy will not be very long.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We always ask ourselves the question \u00ab\u00a0What is the fastest car?\u00a0\u00bb. Sometimes the difference is so big that the answer is easy. But sometimes, it is not easy. We can&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_sitemap_exclude":false,"_sitemap_priority":"","_sitemap_frequency":"","footnotes":""},"categories":[194],"tags":[],"class_list":["post-6961","post","type-post","status-publish","format-standard","hentry","category-articles-en"],"_links":{"self":[{"href":"https:\/\/www.carrera-fun.com\/index.php?rest_route=\/wp\/v2\/posts\/6961","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.carrera-fun.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.carrera-fun.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.carrera-fun.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.carrera-fun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6961"}],"version-history":[{"count":3,"href":"https:\/\/www.carrera-fun.com\/index.php?rest_route=\/wp\/v2\/posts\/6961\/revisions"}],"predecessor-version":[{"id":7173,"href":"https:\/\/www.carrera-fun.com\/index.php?rest_route=\/wp\/v2\/posts\/6961\/revisions\/7173"}],"wp:attachment":[{"href":"https:\/\/www.carrera-fun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.carrera-fun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.carrera-fun.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}