{"id":10270,"date":"2020-12-15T16:49:01","date_gmt":"2020-12-15T16:49:01","guid":{"rendered":"https:\/\/wolles-elektronikkiste.de\/lm393-turns-analog-into-digital"},"modified":"2024-02-15T19:24:47","modified_gmt":"2024-02-15T19:24:47","slug":"lm393-turns-analog-into-digital","status":"publish","type":"post","link":"https:\/\/wolles-elektronikkiste.de\/en\/lm393-turns-analog-into-digital","title":{"rendered":"LM393 &#8211; turns analog into digital"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">About the post<\/h2>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/20200322_131832.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"526\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/20200322_131832-1024x526.jpg\" alt=\"Versch. sensor modules for vibration, light, heat (flame), volume, obstacle\" class=\"wp-image-5745\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/20200322_131832-1024x526.jpg 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/20200322_131832-300x154.jpg 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/20200322_131832-768x395.jpg 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/20200322_131832-1536x790.jpg 1536w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/20200322_131832-1320x679.jpg 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/20200322_131832.jpg 1801w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Versch. sensor modules for vibration, light, heat (flame), volume, obstacle<\/figcaption><\/figure>\n\n<p>What do the sensor modules shown above have in common? The title of the article already reveals it: an LM393. In addition, all modules have a digital output, although the underlying sensors are analog. And finally, all sensors have a potentiometer that can be used to set the analog limit at which the digital output switches. In this article I would like to explain how this works and how you can use analog sensors digitally with an LM393.<\/p>\n\n<h2 class=\"wp-block-heading\">Why digital instead of analog?<\/h2>\n\n<\/p>Imagine reading an analog signal and an action should be taken at a certain limit. For example, you measure the brightness of a light barrier via an LDR (photo resistor). If a certain value is exceeded, an alarm shall be triggered. You could of course read the analog signal with the analogRead function. However, this has some drawbacks:<\/p>\r\n<ul>\r\n \t<li>You must read out the signals permanently so that no event is lost to you. This, in turn, can be problematic if there are other tasks to be done in between.<\/li>\r\n \t<li>AnalogRead is a comparatively slow function. About 100 \u00b5s are needed for this using the Arduino UNO. A digitalRead is almost fifty times faster and a direct read out of the Port Input Register PIN<em>x<\/em>is even about three hundred and fifty times faster.<\/li>\r\n \t<li>If you receive the digital signal via an interrupt pin, you can also send the microcontroller to sleep in between (see my post about <a href=\"https:\/\/wolles-elektronikkiste.de\/en\/sleep-modes-and-power-management\" target=\"_blank\" rel=\"noopener noreferrer\">Sleep Modes<\/a>). This would not be possible using the analogRead function.<\/li>\r\n<\/ul>\n\n<h2 class=\"wp-block-heading\">Features of the LM393<\/h2>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/lm393_pinout_2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"359\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/lm393_pinout_2-1024x359.png\" alt=\"LM393 - left: pinout, right: schematic structure\" class=\"wp-image-5761\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/lm393_pinout_2-1024x359.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/lm393_pinout_2-300x105.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/lm393_pinout_2-768x269.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/lm393_pinout_2-1536x539.png 1536w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/lm393_pinout_2-1320x463.png 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/lm393_pinout_2.png 1679w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">LM393 &#8211; left: pin numbering, right: schematic structure<\/figcaption><\/figure>\n\n<p>The LM393 has two independent comparators. The comparators each have two inputs (IN- and IN+) and one output (OUT). As the name suggests, the comparator compares something, namely the voltages at IN and IN+. At OUT there&#8217;s a transistor which state depends on the ratio of voltages:<\/p>\r\n<ul>\r\n \t<li>IN- voltage is <strong>greater<\/strong> than IN+ \u2192 OUT is closed against GND<\/li>\r\n \t<li>IN- voltage is <strong>less<\/strong> than IN+ \u2192 OUT is open against GND (Open Collector)<\/li>\r\n<\/ul>\r\n<p>If you attach a pull-up resistor with the voltage V<sub>PU<\/sub> to OUT, the polarity changes between 0 and V<sub>PU<\/sub>. With this, you have your digital signal:<\/p>\r\n<ul>\r\n \t<li>IN- is <strong>less<\/strong> than IN+ \u2192 V<sub>OUT<\/sub> = V<sub>PU<\/sub><\/li>\r\n \t<li>IN- is <strong>greater<\/strong> than IN+ \u2192 V<sub>OUT<\/sub> = 0 V<\/li>\r\n<\/ul>\n\n<h3 class=\"wp-block-heading\">Electrical properties of the LM393<\/h3>\n\n<p>With single power supply of the LM393, the supply voltage can be 2 to 36 volts, with double power supply it should be 1 to 18 volts:<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/single_vs_dual_power_supply.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"374\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/single_vs_dual_power_supply-1024x374.png\" alt=\"Power supply of the LM393 - left: simple power supply, right: double power supply\" class=\"wp-image-5772\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/single_vs_dual_power_supply-1024x374.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/single_vs_dual_power_supply-300x110.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/single_vs_dual_power_supply-768x281.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/single_vs_dual_power_supply.png 1291w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Left: simple power supply, right: double power supply<\/figcaption><\/figure>\n\n<p>If OUT is open agains GND, the LM393 serves as a current sink. The maximum current should not exceed 16 milliamperes. So you can attach an LED to it, but nothing more.<\/p>\r\n\r\n<p>The LM393 consumes approx. 0.4 mA. Further information can be found in the <a href=\"https:\/\/asset.conrad.com\/media10\/add\/160267\/c1\/-\/en\/000155603DS01\/datenblatt-155603-stmicroelectronics-lm393n-linear-ic-komparator-differential-dip-8.pdf\" target=\"_blank\" rel=\"noopener noreferrer\">data sheet<\/a>.<\/p>\n\n<h3 class=\"wp-block-heading\">Where can I get the LM393?<\/h3>\n\n<p>The LM393 is a component that is available in virtually all (electronic) online shops. At <a href=\"https:\/\/www.conrad.de\/de\/search.html?search=LM393\" target=\"_blank\" rel=\"noopener noreferrer\">Conrad<\/a>, <a href=\"https:\/\/www.reichelt.de\/index.html?ACTION=446&amp;LA=0&amp;nbc=1&amp;q=lm393\" target=\"_blank\" rel=\"noopener noreferrer\">Reichelt<\/a> and Co you get it for 20 to 30 cents, but you have to pay the shipping fees. With <a href=\"https:\/\/www.ebay.de\/sch\/i.html?_from=R40&amp;_trksid=m570.l1313&amp;_nkw=LM393&amp;_sacat=0\" target=\"_blank\" rel=\"noopener noreferrer\">ebay<\/a> and <a href=\"https:\/\/smile.amazon.de\/s?k=LM393&amp;__mk_de_DE=%C3%85M%C3%85%C5%BD%C3%95%C3%91&amp;ref=nb_sb_noss\" target=\"_blank\" rel=\"noopener noreferrer\">Amazon<\/a> it is sometimes cheaper overall, but you should check where the shops are located. From China, it usually takes a few weeks.<\/p>\r\n\r\n<p>The LM393 is available in different designs, e.g. DIP or SMD, and for different temperature ranges. This information is encoded in the full part designation, e.g. LM393AN, LM393ST, etc. In the <a href=\"https:\/\/asset.conrad.com\/media10\/add\/160267\/c1\/-\/en\/000155603DS01\/datenblatt-155603-stmicroelectronics-lm393n-linear-ic-komparator-differential-dip-8.pdf\" target=\"_blank\" rel=\"noopener noreferrer\">data sheet<\/a> you will find what the abbreviations mean.<\/p>\n\n<h2 class=\"wp-block-heading\">Basic circuit of the LM393<\/h2>\n\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/LM393_basic-1024x368.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"368\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/LM393_basic-1024x368.png\" alt=\"Basic circuit of the comparators of the LM393\" class=\"wp-image-20199\" style=\"width:840px;height:auto\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/LM393_basic-1024x368.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/LM393_basic-300x108.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/LM393_basic-768x276.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/LM393_basic-1536x552.png 1536w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/LM393_basic-1320x475.png 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/LM393_basic.png 1607w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Basic circuit of the comparators of the LM393<\/figcaption><\/figure>\n\n<p>Normally, the LM393 is used to compare a signal voltage V<sub>IN<\/sub> with a reference voltage V<sub>ref.<\/sub> Most of the time, you will find examples where V<sub>Ref<\/sub> is IN- and V<sub>IN<\/sub> is IN+. But that doesn&#8217;t really matter. The reference voltage is usually provided by a voltage divider or a potentiometer. Between IN+ and V<sub>OUT<\/sub> you put a 1 MOhm resistor (R2). R3 is the pull-up resistor that pulls up V<sub>OUT<\/sub> when OUT is closed against GND. You can omit the resistors R1 and R4 if you attach a high-impedance potentiometer or voltage divider to IN- and IN+.<\/p>\n\n<h2 class=\"wp-block-heading\">A circuit to get to know the LM393<\/h2>\n\n<p>The following circuit is intended to showcase how the LM393 works. An Arduino measures the voltages V<sub>REF<\/sub>,V<sub>IN<\/sub> and V<sub>OUT<\/sub> for us.<\/p>\r\n<ul>\r\n \t<li>The voltage divider R1 \/ R2 delivers (ideally) 2.5 volts. This is our reference voltage.<\/li>\r\n \t<li>The signal voltage V<sub>IN<\/sub> is variable and is supplied by a potentiometer.<\/li>\r\n \t<li>When OUT is open against GND, the LED1 starts to light up. Note the polarity &#8211; the LM393 acts as a current sink.<\/li>\r\n \t<li>The voltage V<sub>IN<\/sub> is measured at A1, V<sub>Ref<\/sub> on A0 and V<sub>OUT<\/sub> on A2<\/li>\r\n<\/ul>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/LM393_test_circuit-1024x576.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/LM393_test_circuit-1024x576.png\" alt=\"LM393 - Circuit for testing and practicing\" class=\"wp-image-20202\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/LM393_test_circuit-1024x576.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/LM393_test_circuit-300x169.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/LM393_test_circuit-768x432.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/LM393_test_circuit-1536x864.png 1536w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/LM393_test_circuit-1320x743.png 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/LM393_test_circuit.png 1582w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">LM393 &#8211; Circuit for testing and practicing<\/figcaption><\/figure>\n\n<p>If you take the above-mentioned resistance values, then the switching point for the LED should be approximately in the middle position of the potentiometer. With the following sketch you can follow V<sub>IN<\/sub>, V<sub>Ref<\/sub> and V<sub>OUT:<\/sub><\/p>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-group=\"LM393_test_sketch.ino\" data-enlighter-title=\"LM393_test_sketch.ino\">const int refPin = A0;\r\nconst int vInPin = A1;\r\nconst int vOutPin = A2;\r\nfloat vRef, vIn, vOut;\r\n\r\nvoid setup() {\r\n  Serial.begin(9600); \r\n}\r\n\r\nvoid loop() {\r\n  vRef = analogRead(refPin)*5.0\/1024;\r\n  vIn = analogRead(vInPin)*5.0\/1024;\r\n  vOut = analogRead(vOutPin)*5.0\/1024;\r\n  Serial.print(\"VRef = \");\r\n  Serial.print(vRef);\r\n  Serial.print(\"  |  VIn = \");\r\n  Serial.print(vIn);\r\n  Serial.print(\"  |  VOut = \");\r\n  Serial.println(vOut);\r\n  delay(500);\r\n}<\/pre>\r\n<p>\u00a0<\/p>\r\n\n<p>This is what the result on the serial monitor might look like when you vary the voltage with the potentiometer:<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/12\/lm393_output_arduino.png\"><img decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/12\/lm393_output_arduino.png\" alt=\"Output of LM393_ test_sketch.ino\" class=\"wp-image-5740\"\/><\/a><figcaption class=\"wp-element-caption\">Output of LM393_ test_sketch.ino<\/figcaption><\/figure>\n\n<p>You can see nicely how V<sub>OUT<\/sub> &#8220;tilts&#8221; sharply when V<sub>IN<\/sub> slips under V<sub>Ref<\/sub>.<\/p>\n\n<h2 class=\"wp-block-heading\">Build a digital light sensor<\/h2>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/LDRs.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"407\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/LDRs-1024x407.jpg\" alt=\"\" class=\"wp-image-5804\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/LDRs-1024x407.jpg 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/LDRs-300x119.jpg 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/LDRs-768x305.jpg 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/LDRs-1320x524.jpg 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/LDRs.jpg 1500w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Various LDRs<\/figcaption><\/figure>\n\n<p>Now we come to the actual topic, namely how you turn an analog sensor into a digital one. I want to show this with the example of a light sensor. Replace the resistor R1 of the voltage divider by an LDR and R2 with a suitable resistor, e.g. 33 kOhm. As the light intensity increases, the resistance of the LDR decreases and thus the signal voltage drops. The reference voltage is set with the potentiometer.<\/p>\r\n\r\n<p>You no longer need the lines to the analogue inputs of the Arduino UNO. In addition, remove the LED and connect it to the Arduino Pin 13 instead. You connect OUT of the LM393 to the Arduino Pin 2. This is what the circuit looks like:<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/digital_light_sensor-1024x623.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"623\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/digital_light_sensor-1024x623.png\" alt=\"A digital light sensor using the LM393\" class=\"wp-image-20204\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/digital_light_sensor-1024x623.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/digital_light_sensor-300x183.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/digital_light_sensor-768x467.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/digital_light_sensor-1536x935.png 1536w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/digital_light_sensor-1320x803.png 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/02\/digital_light_sensor.png 1602w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">A digital light sensor using the LM393<\/figcaption><\/figure>\n\n<p>With the following small sketch you can check the circuit:<\/p>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-group=\"digital_light_sensor_basic.ino\" data-enlighter-title=\"digital_light_sensor_basic.ino\">byte sensorPin=2;\r\nbyte ledPin=13;\r\n\r\nvoid setup() {\r\n  pinMode(ledPin, OUTPUT);\r\n  pinMode(sensorPin, INPUT);\r\n}\r\n\r\nvoid loop() {\r\n  while(!digitalRead(sensorPin)){\r\n    digitalWrite(ledPin, HIGH);\r\n  }\r\n  digitalWrite(ledPin,LOW);\r\n}<\/pre>\r\n&nbsp;\n\n<p>Turn the potentiometer until the LED is switched off. If you then cover the LDR with your hand, you&#8217;ll see that the LED lights up.<\/p>\n\n<h3 class=\"wp-block-heading\">Using Interrupts<\/h3>\n\n<p>As already mentioned at the beginning of this article, the advantages of a digital sensor are only really used with interrupts.<\/p>\r\n\r\n<p>Imagine you control a light barrier with the circuit above. This means that you may only have a very short &#8220;dark event&#8221;. In between, however, the microcontroller shall do other things, e.g. read out another sensor. Or, for some reason, you&#8217;ve added delays to your main loop. If you are unlucky, you will miss the triggering of the light barrier.<\/p>\r\n\r\n<p>Here is the solution:<\/p>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-group=\"digital_light_sensor_with_interrupt.ino\" data-enlighter-title=\"digital_light_sensor_with_interrupt.ino\">int interruptPin=2;\r\nint ledPin=13;\r\nvolatile bool dark;\r\n\r\nvoid setup() {\r\n  pinMode(ledPin, OUTPUT);\r\n  pinMode(interruptPin, INPUT);\r\n  attachInterrupt(digitalPinToInterrupt(interruptPin), darkISR, FALLING);\r\n  dark = false;\r\n}\r\n\r\nvoid loop() {\r\n  if(dark){\r\n    digitalWrite(ledPin, HIGH);\r\n    delay(1000);\r\n    digitalWrite(ledPin, LOW);   \r\n    dark = false;\r\n    attachInterrupt(digitalPinToInterrupt(interruptPin), darkISR, FALLING);\r\n  }\r\n}\r\n\r\nvoid darkISR(){\r\n  dark = true;\r\n  detachInterrupt(digitalPinToInterrupt(interruptPin));\r\n}<\/pre>\r\n&nbsp;\n\n<p>Here, the &#8220;dark event&#8221; triggers an interrupt. The interrupt service routine darkISR sets the variable dark to true. And it turns off the interrupts on the interrupt pin so that no more interrupts are triggered before or while the actions are processed.<\/p>\r\n\r\n<p>In the main program loop, the state of the variable dark is then queried in a relaxed manner at a given time. If dark is true, the LED on pin 13 lights up for one second. After that, dark is set to false and the interrupts on the interrupt pin are switched on again. The system is armed again, so to speak.<\/p>\r\n\r\n<p>This way you can do other things in the main loop because you will not lose the information that an interrupt has been triggered.<\/p>\r\n\r\n<p>If you haven&#8217;t been so familiar with interrupts since, maybe read <a href=\"https:\/\/www.arduino.cc\/reference\/de\/language\/functions\/external-interrupts\/attachinterrupt\/\" target=\"_blank\" rel=\"noopener noreferrer\">this article<\/a> on the Arduino pages.<\/p>\n\n<h2 class=\"wp-block-heading\">Digitize other sensors<\/h2>\n\n<p>You should now be able to digitize other analog sensors. With most sensors, it\u2019s even a bit easier than with the LDR, as they directly provide a voltage signal. This allows you to attach it directly to one of the comparator inputs. If necessary, you will still have a resistor in between. A potentiometer is attached to the other input and that\u2019s it.<\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>Using the LM393, analog sensors can deliver digital signals. This can make programming much easier. In this article I will show you how this works using an LDR (light dependent resistor). <\/p>\n","protected":false},"author":1,"featured_media":8469,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[565],"tags":[1132,1131,1139,1137,1136,1124],"class_list":["post-10270","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-other-parts","tag-comparator","tag-digital-light-sensor-2","tag-digitize","tag-digitize-sensors","tag-ldr-en-2","tag-lm393-en"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>LM393 - turns analog into digital &#8226; Wolles Elektronikkiste<\/title>\n<meta name=\"description\" content=\"Using the LM393, analog sensors can deliver digital signals. This can make programming much easier. Here is a systematic guide.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wolles-elektronikkiste.de\/en\/lm393-turns-analog-into-digital\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"LM393 - turns analog into digital &#8226; Wolles Elektronikkiste\" \/>\n<meta property=\"og:description\" content=\"Using the LM393, analog sensors can deliver digital signals. This can make programming much easier. Here is a systematic guide.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wolles-elektronikkiste.de\/en\/lm393-turns-analog-into-digital\" \/>\n<meta property=\"og:site_name\" content=\"Wolles Elektronikkiste\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-15T16:49:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-15T19:24:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/Beitragsbild.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1101\" \/>\n\t<meta property=\"og:image:height\" content=\"1101\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Wolfgang Ewald\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Wolfgang Ewald\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/lm393-turns-analog-into-digital#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/lm393-turns-analog-into-digital\"},\"author\":{\"name\":\"Wolfgang Ewald\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\"},\"headline\":\"LM393 &#8211; turns analog into digital\",\"datePublished\":\"2020-12-15T16:49:01+00:00\",\"dateModified\":\"2024-02-15T19:24:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/lm393-turns-analog-into-digital\"},\"wordCount\":1332,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\"},\"image\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/lm393-turns-analog-into-digital#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/Beitragsbild.png\",\"keywords\":[\"comparator\",\"digital light sensor\",\"digitize\",\"digitize sensors\",\"LDR\",\"LM393\"],\"articleSection\":[\"Other parts\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/lm393-turns-analog-into-digital#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/lm393-turns-analog-into-digital\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/lm393-turns-analog-into-digital\",\"name\":\"LM393 - turns analog into digital &#8226; Wolles Elektronikkiste\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/lm393-turns-analog-into-digital#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/lm393-turns-analog-into-digital#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/Beitragsbild.png\",\"datePublished\":\"2020-12-15T16:49:01+00:00\",\"dateModified\":\"2024-02-15T19:24:47+00:00\",\"description\":\"Using the LM393, analog sensors can deliver digital signals. This can make programming much easier. Here is a systematic guide.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/lm393-turns-analog-into-digital#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/lm393-turns-analog-into-digital\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/lm393-turns-analog-into-digital#primaryimage\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/Beitragsbild.png\",\"contentUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/Beitragsbild.png\",\"width\":1101,\"height\":1101},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/lm393-turns-analog-into-digital#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Startseite\",\"item\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"LM393 &#8211; turns analog into digital\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#website\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\",\"name\":\"Wolles Elektronikkiste\",\"description\":\"Die wunderbare Welt der Elektronik\",\"publisher\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\",\"name\":\"Wolfgang Ewald\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\",\"contentUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\",\"width\":512,\"height\":512,\"caption\":\"Wolfgang Ewald\"},\"logo\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"LM393 - turns analog into digital &#8226; Wolles Elektronikkiste","description":"Using the LM393, analog sensors can deliver digital signals. This can make programming much easier. Here is a systematic guide.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wolles-elektronikkiste.de\/en\/lm393-turns-analog-into-digital","og_locale":"en_US","og_type":"article","og_title":"LM393 - turns analog into digital &#8226; Wolles Elektronikkiste","og_description":"Using the LM393, analog sensors can deliver digital signals. This can make programming much easier. Here is a systematic guide.","og_url":"https:\/\/wolles-elektronikkiste.de\/en\/lm393-turns-analog-into-digital","og_site_name":"Wolles Elektronikkiste","article_published_time":"2020-12-15T16:49:01+00:00","article_modified_time":"2024-02-15T19:24:47+00:00","og_image":[{"width":1101,"height":1101,"url":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/Beitragsbild.png","type":"image\/png"}],"author":"Wolfgang Ewald","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Wolfgang Ewald","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wolles-elektronikkiste.de\/en\/lm393-turns-analog-into-digital#article","isPartOf":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/lm393-turns-analog-into-digital"},"author":{"name":"Wolfgang Ewald","@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46"},"headline":"LM393 &#8211; turns analog into digital","datePublished":"2020-12-15T16:49:01+00:00","dateModified":"2024-02-15T19:24:47+00:00","mainEntityOfPage":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/lm393-turns-analog-into-digital"},"wordCount":1332,"commentCount":4,"publisher":{"@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46"},"image":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/lm393-turns-analog-into-digital#primaryimage"},"thumbnailUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/Beitragsbild.png","keywords":["comparator","digital light sensor","digitize","digitize sensors","LDR","LM393"],"articleSection":["Other parts"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/wolles-elektronikkiste.de\/en\/lm393-turns-analog-into-digital#respond"]}]},{"@type":"WebPage","@id":"https:\/\/wolles-elektronikkiste.de\/en\/lm393-turns-analog-into-digital","url":"https:\/\/wolles-elektronikkiste.de\/en\/lm393-turns-analog-into-digital","name":"LM393 - turns analog into digital &#8226; Wolles Elektronikkiste","isPartOf":{"@id":"https:\/\/wolles-elektronikkiste.de\/en#website"},"primaryImageOfPage":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/lm393-turns-analog-into-digital#primaryimage"},"image":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/lm393-turns-analog-into-digital#primaryimage"},"thumbnailUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/Beitragsbild.png","datePublished":"2020-12-15T16:49:01+00:00","dateModified":"2024-02-15T19:24:47+00:00","description":"Using the LM393, analog sensors can deliver digital signals. This can make programming much easier. Here is a systematic guide.","breadcrumb":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/lm393-turns-analog-into-digital#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wolles-elektronikkiste.de\/en\/lm393-turns-analog-into-digital"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wolles-elektronikkiste.de\/en\/lm393-turns-analog-into-digital#primaryimage","url":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/Beitragsbild.png","contentUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/03\/Beitragsbild.png","width":1101,"height":1101},{"@type":"BreadcrumbList","@id":"https:\/\/wolles-elektronikkiste.de\/en\/lm393-turns-analog-into-digital#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Startseite","item":"https:\/\/wolles-elektronikkiste.de\/en"},{"@type":"ListItem","position":2,"name":"LM393 &#8211; turns analog into digital"}]},{"@type":"WebSite","@id":"https:\/\/wolles-elektronikkiste.de\/en#website","url":"https:\/\/wolles-elektronikkiste.de\/en","name":"Wolles Elektronikkiste","description":"Die wunderbare Welt der Elektronik","publisher":{"@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wolles-elektronikkiste.de\/en?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46","name":"Wolfgang Ewald","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png","url":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png","contentUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png","width":512,"height":512,"caption":"Wolfgang Ewald"},"logo":{"@id":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png"}}]}},"_links":{"self":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/posts\/10270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/comments?post=10270"}],"version-history":[{"count":0,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/posts\/10270\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/media\/8469"}],"wp:attachment":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/media?parent=10270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/categories?post=10270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/tags?post=10270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}