{"id":1416,"date":"2020-01-01T12:07:37","date_gmt":"2020-01-01T18:07:37","guid":{"rendered":"https:\/\/www.protowrxs.com\/?p=1416"},"modified":"2020-01-01T12:23:36","modified_gmt":"2020-01-01T18:23:36","slug":"nanometer-2020","status":"publish","type":"post","link":"https:\/\/www.protowrxs.com\/index.php\/2020\/01\/01\/nanometer-2020\/","title":{"rendered":"NanOMeter 2020"},"content":{"rendered":"\n<p>(Pronounced Nan OM\neter \u2013 Like speedometer of course)<\/p>\n\n\n\n<p>Having historically\nkludged together a breadboard, or dead bug wired something to simply\ntest an SR04, measure a resistance, or test a servo or stepper\ndriver, I finally decided I\u2019d do something a little more permanent.\nWhat trigger this was seeing VolsR\u2019s\n(<a href=\"https:\/\/www.instructables.com\/member\/VolosR\/\">https:\/\/www.instructables.com\/member\/VolosR\/<\/a>)\nlittle Nano based \u201csemi\u201d multi-meter solution on\nInstructables.com.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"800\" height=\"600\" src=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2020\/01\/NanOMeter-Main.jpg\" alt=\"\" class=\"wp-image-1417\" srcset=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2020\/01\/NanOMeter-Main.jpg 800w, https:\/\/www.protowrxs.com\/wp-content\/uploads\/2020\/01\/NanOMeter-Main-300x225.jpg 300w, https:\/\/www.protowrxs.com\/wp-content\/uploads\/2020\/01\/NanOMeter-Main-768x576.jpg 768w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/figure>\n\n\n\n<p>His circuit info\nwasn\u2019t completely accurate and he has since developed a more\nadvanced printed circuit board version, but there was enough to get\nme started on putting a little multi function meter \/ tester\ntogether. I followed his basic concept and used his code as the core\nas it worked well, and then added a few more functions I needed or\nwanted. I even used his basic layout of his original board as it just\nworked well. \n<\/p>\n\n\n\n<p><strong>At this point the little box can:  <\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<ol><li>Measure DC voltage (with reverse voltage diode protection)<\/li><li>Read an analog input and show the value, as well as the min, max and average values<\/li><li>Measure the resistance of a resistor<\/li><li>Measure the voltage drop of a diode or LED (and test the LED there too)<\/li><li>Act as a beeping \/ LED continuity tester<\/li><li>Generate a PWM output<\/li><li>Test a servo<\/li><li>Test a ping \/ SR04 sensor<\/li><li>Drive a stepper motor driver\\<\/li><li>Monitor the external battery supply voltage on the Vin pin<\/li><li>Allow adjustments to the data dump timer (more later)<\/li><li>Do an I2C bus scan and show attached device addresses.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"672\" height=\"286\" src=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2020\/01\/NanOMeter-Volts.jpg\" alt=\"\" class=\"wp-image-1418\" srcset=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2020\/01\/NanOMeter-Volts.jpg 672w, https:\/\/www.protowrxs.com\/wp-content\/uploads\/2020\/01\/NanOMeter-Volts-300x128.jpg 300w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><figcaption>Sample view of the Volt Meter mode<\/figcaption><\/figure>\n\n\n\n<p>Additionally the\ndevice is outputting data for the current mode to the serial port\n(USB or TTL) that can be used to log sensor data over time. It can\nalso be minimally controlled over the serial port with mode toggle or\nselection, PWM width change, servo pulse changes, and logging time\nperiod changes. The data is dumped in a CSV format with the mode\nname, millis(), data1, data2, data3, data4 format. Using the millis()\nvalue one could time chart the data if desired. You could also use a\nwireless serial bridge such as a 2.4G or Bluetooth version and log\nthat data back remotely as well I guess.<\/p>\n\n\n\n<p>The I2C bus is\nexposed next to the display but at this point the Nano is at 99% of\nmemory used on my compiler (30624 or 30720 bytes), so there is not\nmuch room for growth. Your compiler mileage may vary. I\u2019m\ncompiling under Arduino 1.8.7 on Ubuntu 18.04 with the Adafruit 1.0.0\nSoftServo library and the 1.1.3 Stepper library. You can comment the\n\u201cuseFonts\u201d #ifdef to remove the font usage and use the normal\ntext scaling instead. It does save quite a bit of space.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"626\" height=\"266\" src=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2020\/01\/NanOMeter-Analog.jpg\" alt=\"\" class=\"wp-image-1419\" srcset=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2020\/01\/NanOMeter-Analog.jpg 626w, https:\/\/www.protowrxs.com\/wp-content\/uploads\/2020\/01\/NanOMeter-Analog-300x127.jpg 300w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><figcaption>Sample of the analog read view<\/figcaption><\/figure>\n\n\n\n<p>Unfortunately the\nlibraries, along with the fonts, eat up a lot of memory on the\ndevice. The images do not make any difference so removing them\ndoesn\u2019t help a lot. One could remove the fonts and have more\nprogramming space if desired I think. Only 69% of the dynamic memory\nis being used so I do not believe there will be any stability issues.\nObviously the code could be optimized but I\u2019m pretty done with it\nat this point. In reality only the A3 and A6 pins are left to be used\nso there isn\u2019t much left to work with there either. My code is not\npretty nor optimized but it works so I\u2019ll leave it at that.<\/p>\n\n\n\n<p><strong>Current pin uses are:<\/strong><\/p>\n\n\n\n<p>\t(P) = PWM Pin<\/p>\n\n\n\n<p>\/\/  0    &#8211; Rx &#8211; On header pin lower right &#8211; Used to receive commands from serial console, etc<br>\/\/  1    &#8211; Tx &#8211; On header pin lower right &#8211; Dumps CSV data to here<br>\/\/  2    &#8211; Left Button<br>\/\/  3(P)- Middle Button (on interrupt)<br>\/\/  4    &#8211; Right Button<br>\/\/  5(P)- Software Servo Pin<br>\/\/  6(P)- PWM output on three pin header<br>\/\/  7    &#8211; Ping Trigger<br>\/\/  8    &#8211; Ping Echo<br>\/\/  9(P)- Stepper IN1<br>\/\/ 10(P)- Stepper IN3<br>\/\/ 11(P)- Stepper IN2<br>\/\/ 12    &#8211; Stepper IN4<br>\/\/ 13    &#8211; Used for speaker output and LED display<br>\/\/ A0   &#8211; Main Analog Input<br>\/\/ A1   &#8211; External Battery Power Supply Voltage 100k\/10k divider<br>\/\/ A2   &#8211; Input for Diode and Resistor testing<br>\/\/ A3   &#8211; SPARE<br>\/\/ A4   &#8211; I2C bus<br>\/\/ A5   &#8211; I2C bus<br>\/\/ A6   &#8211; SPARE<br>\/\/ A7   &#8211; Voltage Meter input &#8211; on 100k\/10k divider<\/p>\n\n\n\n<p>I used Adafruit\u2019s\nSoftServo library as the normal servo library kills some PWM pins and\nI wasn\u2019t sure if they would be needed. It works well for this use\nand I\u2019ve used it on other robots as well. The AdaFruit OLED library\nis used for the SSD1306 device which is the 128 x 32 pixel version.\nVolsR\u2019s updated version uses the larger 128&#215;64 version but\npersonally I would rather have the board space than more display\nspace for this project.<\/p>\n\n\n\n<p>To add the images I\n\u201ctemporarily borrowed\u201d some icon art from online (I\u2019ll give\nthem back when I\u2019m done) and converted them to the HEX format\nneeded using the handy image2cpp online at at\n<a href=\"https:\/\/diyusthad.com\/image2cpp\">https:\/\/diyusthad.com\/image2cpp<\/a>.\nWorks great and good enough results for me.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">The Circuit<\/p>\n\n\n\n<p>I haven\u2019t drawn a\nfull schematic up but each test point is pretty simply. Using the\nabove pin outs one should be able to replicate it. The voltage\ndividers on the volt meter and external battery are simple 100K \/ 10K\nvoltage dividers. The buttons simply go from the pins to ground and\nwe use the internal pull up resistors on the Nano. I did not use any\npull up resistors on the I2C display and it works fine.  The tiny\nspeaker connects directly to pin13 and to ground. It does show a\npositive terminal so I connected it like that. The dropping resistor\nfor the diode \/ led is a 2.2K in mine, just tweak the code as needed.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">The Buttons<\/p>\n\n\n\n<p>With only three\ninput buttons there are limits BUT in reality you can get six (6)\noptions out of them at least. The middle button is hooked to an\ninterrupt that toggles the \u201cmode\u201d for the box. The left (down)\nand right (up) buttons selection options within the modes if there\nare any, i.e. in PWM they change the pulse widths, etc.\nSimultaneously pressing the Up and Down toggle the \u201cPot Mode\u201d\nallowing a pot to be connected to the analog input to control the\nPWM, Servo and data dump timer modes. Just makes it easier to test\nthings. Pressing the down and select toggles the beeping sounds on\nand off, including the continuity mode. In analog reading mode the\ndown button resets the averages.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">The Down Sides<\/p>\n\n\n\n<p>There are obviously\nsome down sides to the little box. For one the voltage measurements\naren\u2019t the most accurate. I\u2019m not sure if it\u2019s the voltage drop\non little 1N914 diode I\u2019m using for reverse protection or something\nelse. I do have an adjustment in the code to offset the diode and\nit\u2019s accurate at lower voltages but off at higher voltages. I know\nvoltage drop can vary by voltage but wasn\u2019t aware it was that much.\n<\/p>\n\n\n\n<p class=\"has-medium-font-size\">The Conclusion<\/p>\n\n\n\n<p>So far the little\nNanOMeter has been pretty handy. I\u2019ve built a couple probe wires\nout of header jumper wires to more easily use the volt meter and\ncontinuity tester piece. Also built a header adapter for the analog\ninput and resister\/diode\/continuity connectors from male headers that\ncan be inserted to flip the gender of the connectors without surgery.\nI also added an additional header that provides power and ground\ndirectly from the battery (7.4v old Canon camera battery) that I can\nuse to power bigger voltage \/ current requirements without leaning on\nthe Nano\u2019s regulator too much. Great for driving stepper motor\ncontrollers and could be used to drive H bridge motor drivers as\nwell.<\/p>\n\n\n\n<p>So if you need a\nsimple voltmeter\/analog tester\/ohm meter\/diode drop\/continuity\ntester\/PWM tester\/Sevro tester\/SR04 tester\/stepper tester\/data\nlogger\/I2C bus scanner, this could be useful.<\/p>\n\n\n\n<p>The NanOMeter now\nhas a prominent place on my bench and is quite handy when I need to\ncheck an address on an I2C device, validate a resistor value, test an\nanalog based sensor etc.<\/p>\n\n\n\n<p><em>Cheers \u2013 ProtoWrxs<\/em><\/p>\n\n\n\n<div class=\"wp-block-file\"><a href=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2020\/01\/NanOMeter2020.zip\">NanOMeter2020<\/a><a href=\"https:\/\/www.protowrxs.com\/wp-content\/uploads\/2020\/01\/NanOMeter2020.zip\" class=\"wp-block-file__button\" download>Download<\/a><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/const String curVer = \"2020-01-01\";  \/\/ Final code clean up and documentation -back to 99% used memory so done\n\/\/                                     \/\/ Added #ifdef useFonts option to save memory and insure better compiling options\n\/\/                                     \/\/ Still no guarantee but works now on multiple Ubuntu boxes \/ library versions for me\n\/\/const String curVer = \"2019-12-30\";  \/\/ Added sound mute with SEL \/ UP combo and added code for DOWN \/ SEL if desired\n\/\/                                      Added I2C scanner option to display devices\n\/\/const String curVer = \"2019-12-29\";   \/\/ Documented as much as I could, changed PWM pulse control to single increments +\/-\n\/\/                                      Changed analog stats to be in Min \/ Avg \/ Max on the screen, moved PWM from pin 9 to 6\n\/\/                                      Allows 9,10,11,12 for Stepper outputs\n\/\/const String curVer = \"2019-12-28\"; \/\/ Added Servo, Ping, Logging, and Serial controls\n\/\/const String curver = \"2019-12-27\"; \/\/ Initial version copied from Instructable site, cleaned up tabs and documented code\n\n\/\/ NanOMeter - Multi Function Nano Based Test base\n\/\/ Stephen W Nolen \/ ProtoWrxs\n\/\/ Core code based on VolosR work on Instructables (https:\/\/www.instructables.com\/member\/VolosR\/)\n\/\/ I used the basic lay of VolosR's board as well as it just works\n\/\/ He has an updated version but I personally like the 128x32 size screen better allowing for more component room\n\/\/\n\/\/ Features Includes:\n\/\/   0 Volt meter\n\/\/   1 Analog Sensor\n\/\/   2 Resistor \/ Ohm Tester\n\/\/   3 Diode Voltage Drop \/ LED Tester\n\/\/   4 Continuity Tester with Beep\n\/\/   5 PWM generator\n\/\/   6 Servo Tester\n\/\/   7 Ping  \/ Sonar Tester (SR04 at least)\n\/\/   8 Stepper Motor Tester\n\/\/   9 External Battery Voltage Display\n\/\/  10 Data Logging time adjustment\n\/\/  11 I2C bus scanner\n\/\/ Modes 0 - 9 dump data to the serial port (USB or TTL level pins lower right)\n\/\/ Mode 10 Allows adjustment from 500 (1\/2 second) to a minute interval adjustments\n\/\/ Data dump format is:\n\/\/ Mode, millis(), data1, data2, data3, data4\n\/\/ All except analog dump a single data item\n\/\/ Analog dumps the read, min, average, and max data items\n\/\/ Ohms dumps \"inf\" if nothing attached, resistance otherwise\n\/\/ Continutity dumps voltage drop with 0.00 being continuity\n\/\/ NOTHING is dumped during mode 10 time adjustment\n\/\/ I2C dumps addresses CSV but does NOT use the Data Logging timer\n\n\/\/ Device has some limited remote serial controls\n\/\/ M will dump the mode just like the middle select button\n\/\/ 0-9 will select the mode listed above\n\/\/ A will select the dump timer mode\n\/\/ For Mode 5, 6, and 10, the \"-\" emulates pressed the down button and a \"+\" emulates the UP button\n\/\/ The \"=\" command resets pulses or settings to their default for the mode you are in.\n\n\n\/\/***************************************************************************************\/\/\n\/\/ Pin Uses\n\/\/  0   - Rx - On header pin lower right - Used to receive commands from serial console or other devices\n\/\/  1   - Tx - On header pin lower right - Dumps CSV data to here - runs at 115200, change in code if  needed\n\/\/  2   - Right Button\n\/\/  3(P)- Middle Button (on interrupt)\n\/\/  4   - Left Button\n\/\/  5(P)- Software Servo Pin\n\/\/  6(P)- PWM output on three pin header\n\/\/  7   - Ping Trigger\n\/\/  8   - Ping Echo\n\/\/  9(P)- Stepper IN1\n\/\/ 10(P)- Stepper IN3\n\/\/ 11(P)- Stepper IN2\n\/\/ 12   - Stepper IN4\n\/\/ 13   - Used for speaker output and LED display\n\/\/ A0   - Main Analog Input\n\/\/ A1   - External Battery Power Suppy Voltage 100k\/10k divider\n\/\/ A2   - Input for Diode and Resistor testing\n\/\/ A3   -\n\/\/ A4   - I2C bus\n\/\/ A5   - I2C bus\n\/\/ A6   -\n\/\/ A7   - Voltage Meter input - on 100k\/10k divider\n\/\/ \n\n\n\/\/ Load the libraries\n\/\/#include &lt;SPI.h>          \/\/ Not used for now\n#include &lt;Wire.h>\n\/\/#include &lt;Adafruit_GFX.h>\n#include &lt;Stepper.h>\n#include &lt;Adafruit_SSD1306.h>\n\n\/\/ 2020-01-01 - Comment out to use basic scaled fonts\n\/\/ Not as pretty but saves memory and may be needed for some combos\n#define useFonts\n#ifdef useFonts\n  #include &lt;Fonts\/FreeSans9pt7b.h>\n  #include &lt;Fonts\/FreeSans12pt7b.h>\n#endif\n\n#include &lt;Adafruit_SoftServo.h>\n\/\/ Note: To get full 180 degree movement on the servo I have modified the Adafruit_Softservo.ccp file as follows:\n\/\/ micros = map(a, 0, 180, 500, 2500)\n\/\/ The old 1000, 2000 mapping provides 90 degree movement only\n\n\/\/ setup OLED - 128 x 32 is what we have here\n#define OLED_RESET 4\nAdafruit_SSD1306 display(OLED_RESET);\n\n\/\/ Setup SoftServo for servo work\nAdafruit_SoftServo myServo;  \/\/ 2019-12-28 - Using this as Servo kills PWM on 9 and 10 on Arduino\n\n\/\/#if (SSD1306_LCDHEIGHT != 32)\n\/\/#error(\"Height incorrect, please fix Adafruit_SSD1306.h!\");\n\/\/#endif\n\n\/\/ Setup Images - Most were converted via https:\/\/diyusthad.com\/image2cpp\nconst unsigned char PROGMEM nanoImg [] { \n0x00, 0x00, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0x00,\n0x30, 0x0e, 0x00, 0x00, 0x30, 0x0e, 0x00, 0x00, 0x30, 0x0e, 0x00, 0x00, 0x30, 0x0e, 0x00, 0x00,\n0x3f, 0xfe, 0x38, 0x0e, 0x3f, 0xfe, 0x38, 0x0e, 0x3f, 0xfe, 0x38, 0x0e, 0x3f, 0xfe, 0x38, 0x0e,\n0x3f, 0xfe, 0x38, 0x0e, 0x3f, 0xfe, 0x10, 0x04, 0x38, 0x0e, 0x10, 0x04, 0x3b, 0xee, 0x10, 0x04,\n0x3b, 0xee, 0x10, 0x04, 0x33, 0xe6, 0x18, 0x0c, 0x03, 0xe0, 0x1f, 0xfc, 0x03, 0xe0, 0x01, 0xc0,\n0x00, 0x80, 0x01, 0xc0, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80,\n0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xff, 0xff, 0x80, 0x00, 0x7f, 0xff, 0x00,\n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n};\n\n\/\/ 'datalog', 32x32px\nconst unsigned char PROGMEM dataImg [] {\n0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x03, 0xff, 0x00, 0x00, 0x0f, 0x03, 0xc0, 0x00,\n0x1c, 0x00, 0xe0, 0x00, 0x30, 0xfc, 0x30, 0x00, 0x63, 0xff, 0x18, 0x00, 0x07, 0x03, 0x80, 0x00,\n0x0c, 0x00, 0xc3, 0x00, 0x00, 0xfc, 0x47, 0x80, 0x01, 0xce, 0x0f, 0xc0, 0x01, 0x82, 0x1e, 0xe0,\n0x00, 0x30, 0x7c, 0x70, 0x00, 0x78, 0xfc, 0xf8, 0x00, 0x79, 0xff, 0xfc, 0x00, 0x33, 0xff, 0xce,\n0x00, 0x07, 0xff, 0x8e, 0x00, 0x0f, 0xff, 0xfc, 0x00, 0x1f, 0xff, 0xf8, 0x00, 0x3f, 0xff, 0xf0,\n0x00, 0x3f, 0xff, 0xe0, 0x00, 0x3f, 0xff, 0xe0, 0x00, 0x3f, 0xff, 0xe0, 0x00, 0x1f, 0xff, 0xc0,\n0x00, 0x3f, 0xff, 0x80, 0x00, 0x3f, 0xff, 0x00, 0x00, 0x1f, 0xfe, 0x00, 0x00, 0x3f, 0xfc, 0x00,\n0x00, 0x77, 0xf8, 0x00, 0x00, 0xe2, 0x70, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n};\n\n\nconst unsigned char PROGMEM pwmImg [] {\n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n0x00, 0x00, 0x00, 0x00, 0x0f, 0xfe, 0x00, 0x00, 0x0f, 0xfe, 0x00, 0x00, 0x0f, 0xfe, 0x00, 0x00,\n0x0e, 0x0e, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00,\n0x0e, 0x0e, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00,\n0x00, 0x0e, 0x00, 0x70, 0x00, 0x0e, 0x00, 0x70, 0x00, 0x0e, 0x00, 0x70, 0x00, 0x0e, 0x00, 0x70,\n0x00, 0x0e, 0x00, 0x70, 0x00, 0x0e, 0x00, 0x70, 0x00, 0x0e, 0x00, 0x70, 0x00, 0x0e, 0x00, 0x70,\n0x00, 0x0f, 0xff, 0xf0, 0x00, 0x0f, 0xff, 0xf0, 0x00, 0x0f, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00,\n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n};\n\n\/\/ Clock image - not used for now\nconst unsigned char PROGMEM clockImg [] = {\n0x0F, 0x80, 0x01, 0xF0, 0x39, 0xC0, 0x03, 0x9C, 0x61, 0x80, 0x01, 0x86, 0x43, 0x1F, 0xF8, 0xC2,\n0xC6, 0x70, 0x0E, 0x63, 0x8D, 0xC0, 0x03, 0xB1, 0x9B, 0x00, 0x00, 0xD9, 0xF6, 0x01, 0x80, 0x6F,\n0xEC, 0x01, 0x80, 0x37, 0x58, 0x01, 0x80, 0x1A, 0x10, 0x01, 0x80, 0x08, 0x30, 0x01, 0x80, 0x0C,\n0x20, 0x01, 0x80, 0x04, 0x20, 0x01, 0x80, 0x04, 0x20, 0x01, 0x80, 0x04, 0x60, 0x01, 0x80, 0x06,\n0x60, 0x01, 0x80, 0x06, 0x60, 0x7F, 0x80, 0x06, 0x60, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x06,\n0x20, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x04, 0x30, 0x00, 0x00, 0x0C, 0x10, 0x00, 0x00, 0x08,\n0x18, 0x00, 0x00, 0x18, 0x08, 0x00, 0x00, 0x10, 0x0C, 0x00, 0x00, 0x30, 0x06, 0x00, 0x00, 0x60,\n0x0F, 0x80, 0x01, 0xF0, 0x18, 0xE0, 0x07, 0x18, 0x30, 0x7C, 0x3E, 0x0C, 0x20, 0x0F, 0xF0, 0x04\n};\n\nconst unsigned char PROGMEM batteryImg [] = {\n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xF0, 0x40, 0x00, 0x00, 0x10, 0x47, 0x3C, 0xE0, 0x18,\n0x47, 0xBD, 0xE0, 0x18, 0x45, 0xA5, 0xA0, 0x1E, 0x45, 0xA5, 0xA0, 0x1A, 0x45, 0xA5, 0xA0, 0x1A,\n0x45, 0xA5, 0xA0, 0x1A, 0x45, 0xA5, 0xA0, 0x1A, 0x45, 0xA5, 0xA0, 0x1E, 0x47, 0xBD, 0xE0, 0x18,\n0x47, 0x3C, 0xE0, 0x18, 0x40, 0x00, 0x00, 0x10, 0x3F, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00,\n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n};\n\n\/\/const unsigned char PROGMEM battery2Img [] {\n\/\/0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x07, 0xff, 0xff, 0xf3, 0x81, 0xff, 0x80, 0x0c, 0x80, 0x3f,\n\/\/0x80, 0x0c, 0xe2, 0x1f, 0x80, 0x0c, 0x7d, 0x0f, 0x80, 0x1e, 0x39, 0x0f, 0x80, 0x1f, 0x81, 0x8f,\n\/\/0x80, 0x1f, 0xff, 0x0f, 0x80, 0x3f, 0xff, 0x0f, 0x80, 0x1f, 0xff, 0x0f, 0x80, 0x4f, 0xff, 0x0f,\n\/\/0x80, 0x07, 0xfe, 0x0f, 0x80, 0x81, 0xfe, 0x0f, 0x80, 0x80, 0x00, 0x0f, 0x80, 0x00, 0x04, 0x0f,\n\/\/0x81, 0x08, 0x04, 0x0f, 0x81, 0x03, 0x08, 0x0f, 0x80, 0x00, 0x08, 0x0f, 0x83, 0x00, 0x00, 0x0f,\n\/\/0x82, 0x00, 0x10, 0x0f, 0x80, 0x40, 0x10, 0x0f, 0x84, 0x10, 0x00, 0x0f, 0x84, 0x07, 0xe0, 0x0f,\n\/\/0x84, 0x00, 0x20, 0x0f, 0x84, 0x00, 0x00, 0x0f, 0xc6, 0x00, 0x40, 0x0f, 0xc3, 0x00, 0x40, 0x0f,\n\/\/0xf1, 0xe0, 0x80, 0x0f, 0xfe, 0x3f, 0x7f, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff\n\/\/};\n\n\/\/ Not used for now\n\/\/const unsigned char PROGMEM temperatureImg [] = {\n\/\/0x00, 0x01, 0x80, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x04, 0x20, 0x00,\n\/\/0x00, 0x04, 0x20, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x04, 0x20, 0x00,\n\/\/0x00, 0x04, 0x20, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x04, 0x20, 0x00,\n\/\/0x00, 0x04, 0x20, 0x00, 0x00, 0x05, 0xA0, 0x00, 0x00, 0x05, 0xA0, 0x00, 0x00, 0x05, 0xA0, 0x00,\n\/\/0x00, 0x05, 0xA0, 0x00, 0x00, 0x05, 0xA0, 0x00, 0x00, 0x05, 0xA0, 0x00, 0x00, 0x0D, 0xB0, 0x00,\n\/\/0x00, 0x19, 0x98, 0x00, 0x00, 0x33, 0xCC, 0x00, 0x00, 0x26, 0x64, 0x00, 0x00, 0x6C, 0x36, 0x00,\n\/\/0x00, 0x68, 0x16, 0x00, 0x00, 0x68, 0x16, 0x00, 0x00, 0x2C, 0x34, 0x00, 0x00, 0x27, 0xE4, 0x00,\n\/\/0x00, 0x33, 0xCC, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x01, 0x80, 0x00\n\/\/};\n\nconst unsigned char PROGMEM continuityImg [] = {\n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n0x00, 0x1F, 0xF8, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0xC0, 0x0F, 0xFF, 0xFF, 0xF0,\n0x1F, 0xC0, 0x03, 0xF8, 0x7F, 0x00, 0x00, 0xFE, 0xFC, 0x00, 0x00, 0x3F, 0xF8, 0x07, 0xE0, 0x1F,\n0xF0, 0x3F, 0xFC, 0x0F, 0x00, 0xFF, 0xFF, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x03, 0xF0, 0x0F, 0xC0,\n0x07, 0xC0, 0x03, 0xE0, 0x03, 0x80, 0x01, 0xC0, 0x01, 0x0F, 0xF0, 0x80, 0x00, 0x1F, 0xF8, 0x00,\n0x00, 0x3F, 0xFC, 0x00, 0x00, 0x3C, 0x3C, 0x00, 0x00, 0x38, 0x1C, 0x00, 0x00, 0x01, 0x80, 0x00,\n0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00,\n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n};\n\nconst unsigned char PROGMEM resistorImg [] = {\n0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x06, 0x04, 0x00, 0x00, 0x0F, 0x88,\n0x00, 0x00, 0x18, 0xD0, 0x00, 0x00, 0x38, 0x60, 0x00, 0x00, 0x6C, 0x30, 0x00, 0x00, 0xC6, 0x18,\n0x00, 0x00, 0x83, 0x08, 0x00, 0x01, 0x81, 0x8C, 0x00, 0x03, 0x00, 0xCC, 0x00, 0x07, 0x80, 0x78,\n0x00, 0x0C, 0xC0, 0x30, 0x00, 0x18, 0x60, 0x60, 0x00, 0x38, 0x30, 0xC0, 0x00, 0x6C, 0x1B, 0x80,\n0x01, 0xC6, 0x0E, 0x00, 0x03, 0x03, 0x0C, 0x00, 0x07, 0x01, 0x98, 0x00, 0x0D, 0x80, 0xF0, 0x00,\n0x18, 0xC0, 0x60, 0x00, 0x30, 0x60, 0xC0, 0x00, 0x30, 0x31, 0x80, 0x00, 0x10, 0x19, 0x00, 0x00,\n0x18, 0x0F, 0x00, 0x00, 0x0C, 0x06, 0x00, 0x00, 0x06, 0x0C, 0x00, 0x00, 0x0B, 0x18, 0x00, 0x00,\n0x11, 0xF0, 0x00, 0x00, 0x20, 0x60, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00\n};\n\nconst unsigned char PROGMEM diodeImg [] = {\n0x00, 0x07, 0xE0, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x3F, 0xFC, 0x00, 0x00, 0x78, 0x1E, 0x00,\n0x00, 0xE0, 0x07, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0xC0, 0x03, 0x00, 0x01, 0xC0, 0x03, 0x80,\n0x01, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x03, 0x80,\n0x01, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x03, 0x80, 0x07, 0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFF, 0xE0,\n0x07, 0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n0x00, 0x1C, 0x38, 0x00, 0x00, 0x1C, 0x38, 0x00, 0x00, 0x1C, 0x38, 0x00, 0x00, 0x1C, 0x38, 0x00,\n0x00, 0x1C, 0x38, 0x00, 0x00, 0x1C, 0x38, 0x00, 0x00, 0x1C, 0x38, 0x00, 0x00, 0x1C, 0x38, 0x00,\n0x00, 0x1C, 0x38, 0x00, 0x00, 0x1C, 0x38, 0x00, 0x00, 0x1C, 0x38, 0x00, 0x00, 0x1C, 0x38, 0x00\n};\n\n\/\/ 'electric-rc-model-servo-image_csp34733171', 32x25px\nconst unsigned char PROGMEM servoImg [] = {\n0x00, 0x00, 0x7c, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x38, 0x00,\n0x00, 0x07, 0xff, 0x80, 0x00, 0x0f, 0xff, 0x80, 0x00, 0x0f, 0xff, 0x80, 0x0f, 0xff, 0xff, 0x80,\n0x0f, 0xff, 0xff, 0x80, 0x0f, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc,\n0x07, 0xff, 0xff, 0x80, 0x0f, 0xff, 0xff, 0x80, 0x0f, 0xff, 0xff, 0x80, 0x0f, 0xff, 0xff, 0x80,\n0x0f, 0xff, 0xff, 0x80, 0x0f, 0xff, 0xff, 0x80, 0x0f, 0xff, 0xff, 0x80, 0x0f, 0xff, 0xff, 0x80,\n0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0x80, 0x0f, 0xff, 0xff, 0x80, 0x0f, 0xff, 0xff, 0x80,\n0x07, 0xff, 0xff, 0x80\n};\n\nconst unsigned char PROGMEM voltImg [] = {\n0x1f, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xf8, 0x18, 0x00, 0x00, 0x18,\n0x18, 0x00, 0x00, 0x18, 0x18, 0x0f, 0xf0, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x60, 0x06, 0x18,\n0x18, 0x40, 0x02, 0x18, 0x18, 0xc1, 0x81, 0x18, 0x18, 0x81, 0x81, 0x18, 0x19, 0x81, 0x81, 0x98,\n0x19, 0x01, 0x80, 0x98, 0x19, 0x03, 0xc0, 0x98, 0x18, 0x07, 0xe0, 0x18, 0x18, 0x0f, 0xf0, 0x18,\n0x18, 0x00, 0x00, 0x18, 0x1f, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xf8,\n0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf0, 0x0f, 0xf8, 0x1f, 0xe0, 0x07, 0xf8, 0x1f, 0xe0, 0x07, 0xf8,\n0x1f, 0xe0, 0x07, 0xf8, 0x1f, 0xe0, 0x07, 0xf8, 0x1f, 0xe0, 0x07, 0xf8, 0x1f, 0xf0, 0x0f, 0xf8,\n0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0xfe, 0x7f, 0xf8, 0x1f, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xf8,\n};\n\nconst unsigned char PROGMEM radarImg [] {\n0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x70, 0x00, 0x00, 0x7f, 0x7e, 0x00, 0x00, 0xff, 0x7f, 0x00,\n0x01, 0xfe, 0x7f, 0xc0, 0x03, 0xe7, 0x67, 0xe0, 0x07, 0x9b, 0x79, 0xf0, 0x0f, 0x35, 0x7e, 0xb0,\n0x0f, 0x75, 0x7e, 0x78, 0x1e, 0xfe, 0x7d, 0xb8, 0x1d, 0xf8, 0x5b, 0xbc, 0x3d, 0xf7, 0x67, 0xdc,\n0x3b, 0xef, 0x67, 0xdc, 0x3b, 0xff, 0xdb, 0xde, 0x3b, 0xdf, 0x3b, 0xde, 0x00, 0x00, 0x00, 0x00,\n0x3b, 0xdf, 0x7b, 0xde, 0x3b, 0xff, 0x7b, 0xde, 0x3b, 0xef, 0x7e, 0x5c, 0x3d, 0xf7, 0x75, 0x1c,\n0x3d, 0xfb, 0x4e, 0xbc, 0x1e, 0xe4, 0x3f, 0xb8, 0x1e, 0xd7, 0xff, 0x78, 0x0f, 0x6f, 0x7e, 0xf0,\n0x07, 0x9f, 0x7d, 0xf0, 0x07, 0xef, 0x73, 0xe0, 0x03, 0xf8, 0x1f, 0xc0, 0x00, 0xff, 0x7f, 0x80,\n0x00, 0x7f, 0x7e, 0x00, 0x00, 0x1f, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n};\n\n\/\/ 'stepper', 32x32px\nconst unsigned char PROGMEM stepperImg [] {\n0x00, 0x03, 0xc0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x03, 0xc0, 0x00,\n0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x1f, 0xf7, 0xef, 0xf8, 0x1f, 0xe7, 0xe7, 0xf8,\n0x3f, 0x87, 0xe1, 0xfc, 0x3f, 0x07, 0xe0, 0xfc, 0x3f, 0x07, 0xe0, 0xfc, 0x3f, 0x01, 0x80, 0xfc,\n0x3f, 0x80, 0x01, 0xfc, 0x7f, 0xc0, 0x03, 0xfe, 0x7f, 0xf8, 0x1f, 0xfe, 0x7f, 0xff, 0xff, 0xfe,\n0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00,\n0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe,\n0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe,\n0x7f, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xfe, 0x01, 0xff, 0xff, 0x80, 0x01, 0xff, 0xff, 0x80,\n};\n\n\/\/ 'speaker', 32x32px\nconst unsigned char PROGMEM speakerImg [] {\n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n0x00, 0x01, 0x80, 0x40, 0x00, 0x03, 0x80, 0xe0, 0x00, 0x07, 0x80, 0x70, 0x00, 0x1f, 0x80, 0x70,\n0x00, 0x3f, 0x87, 0x38, 0x00, 0x7f, 0x87, 0x18, 0x00, 0xff, 0x83, 0x9c, 0x01, 0xff, 0x91, 0x8c,\n0x3f, 0xff, 0xb9, 0xcc, 0x3f, 0xff, 0x98, 0xcc, 0x3f, 0xff, 0x9c, 0xce, 0x3f, 0xff, 0x8c, 0xce,\n0x3f, 0xff, 0x8c, 0xce, 0x3f, 0xff, 0x8c, 0xee, 0x3f, 0xff, 0x8c, 0xce, 0x3f, 0xff, 0x9c, 0xce,\n0x3f, 0xff, 0x98, 0xcc, 0x3f, 0xff, 0xb9, 0xcc, 0x01, 0xff, 0xb1, 0x8c, 0x00, 0x7f, 0x83, 0x9c,\n0x00, 0x3f, 0x87, 0x18, 0x00, 0x1f, 0x87, 0x38, 0x00, 0x0f, 0x80, 0x70, 0x00, 0x07, 0x80, 0x70,\n0x00, 0x03, 0x80, 0xe0, 0x00, 0x01, 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n};\n\n\/\/ 'nospeaker', 33x32px\nconst unsigned char PROGMEM nospeakerImg [] {\n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x0c,\n0x00, 0x80, 0x00, 0x00, 0x06, 0x01, 0x80, 0x60, 0x00, 0x03, 0x03, 0x80, 0x70, 0x00, 0x01, 0x87,\n0x80, 0x38, 0x00, 0x00, 0xcf, 0x83, 0x18, 0x00, 0x00, 0x6f, 0x83, 0x9c, 0x00, 0x00, 0x37, 0x81,\n0x8c, 0x00, 0x00, 0xdb, 0x89, 0xcc, 0x00, 0x1f, 0xed, 0x9c, 0xce, 0x00, 0x1f, 0xf6, 0x9c, 0xe6,\n0x00, 0x1f, 0xfb, 0x0e, 0x66, 0x00, 0x1f, 0xfd, 0x8e, 0x66, 0x00, 0x1f, 0xfe, 0xc6, 0x66, 0x00,\n0x1f, 0xff, 0x66, 0x66, 0x00, 0x1f, 0xff, 0xb6, 0x66, 0x00, 0x1f, 0xff, 0x98, 0x66, 0x00, 0x1f,\n0xff, 0x8c, 0xe6, 0x00, 0x1f, 0xff, 0x96, 0xce, 0x00, 0x00, 0x7f, 0x83, 0x4c, 0x00, 0x00, 0x3f,\n0x81, 0x8c, 0x00, 0x00, 0x1f, 0x82, 0xdc, 0x00, 0x00, 0x0f, 0x83, 0x68, 0x00, 0x00, 0x07, 0x80,\n0x30, 0x00, 0x00, 0x03, 0x80, 0x58, 0x00, 0x00, 0x00, 0x80, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00,\n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n};\n\n\/\/ 'satImg', 32x32px\nconst unsigned char PROGMEM satImg [] {\n0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x07, 0x00, 0x33, 0x00, 0x3f, 0x80,\n0x6f, 0x00, 0x79, 0xc0, 0x6c, 0x01, 0xe0, 0xc0, 0x0d, 0x83, 0x81, 0xe0, 0x01, 0xce, 0x01, 0xe0,\n0x00, 0xfc, 0x03, 0xe0, 0x00, 0x78, 0x03, 0x20, 0x00, 0x78, 0x06, 0x30, 0x00, 0xfc, 0x0e, 0x30,\n0x01, 0xce, 0x1c, 0x30, 0x03, 0x84, 0x38, 0x60, 0x03, 0x00, 0x70, 0x60, 0x06, 0x00, 0xe0, 0x60,\n0x0c, 0x01, 0xc0, 0x60, 0x0c, 0x03, 0x80, 0xc0, 0x18, 0x07, 0x01, 0xc0, 0x18, 0x1e, 0x01, 0x80,\n0x18, 0x38, 0x03, 0xc0, 0x19, 0xf0, 0x0e, 0xc0, 0x1f, 0xc0, 0x1c, 0x60, 0x0f, 0x80, 0xf8, 0x60,\n0x03, 0xff, 0xe0, 0x30, 0x00, 0xff, 0xe0, 0x30, 0x00, 0x00, 0xc0, 0x18, 0x00, 0x00, 0xc0, 0x1c,\n0x00, 0x01, 0x80, 0x0c, 0x00, 0x01, 0xc0, 0x0e, 0x00, 0x03, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00\n};\n\n\/\/ Init vars\n\/\/int   Pause =300;    \/\/ Pause after display - change as needed\nbyte  Pause =300;    \/\/ Hard pause delay in some modes\nint   Raw   = 0;     \/\/ Used to read Raw values\nfloat Vin   = 0;     \/\/ Internal Calc\nfloat Vout  = 0;     \/\/ External calc\nfloat R1    = 2200;  \/\/ Divider for top side of resistor and diode tester - May want to tweak based on your actual reading\nfloat R2    = 0;     \/\/ Default for lower side of resistor and diode, gets calc\n\n\nfloat Vin2  = 0.00;     \/\/ Used for voltage meter calcs\nfloat Vout2 = 0.00;     \n                        \/\/float Res1= 100000.00;\/\/ resistance of R1 (100K) \n\/\/float Res1  = 105789.00;\/\/ Tweaked to actual readin\nfloat Res1 = 100000.00;\n                        \/\/float Res2= 10000.00; \/\/ resistance of R2 (10K) \nfloat Res2  = 10000.00;  \/\/ Tweaked to actual readin\n\nint   Val = 0;        \/\/ Working vars\nfloat buffer= 0;\n\nint maximum=1;        \/\/ Min and Max for analog reads defaults\nint minimum=1024;\n\nint Mode=0;           \/\/ Mode - default to 0 \nint maxModes = 11;    \/\/ Maximum modes for rollover\n\nunsigned long numberOfTimes=0;\nunsigned long sum=0;\nint avg=0;\n\nint Pulse=125;         \/\/ Default PWM puluse width\nint servoPulse = 90;   \/\/ Used for Servo testing\n\nbyte TRIGGER_PIN = 7;  \/\/ SR04 \/ Sonar trigger pin\nbyte ECHO_PIN    = 8 ; \/\/ SRO4 \/ Sonar echo return pin\n\/\/long mydistance   = 0;\nint mydistance = 0;\n\nlong dataTimer;           \/\/ used for logging data to the serial port, set trigger in mode\nlong dataTrigger = 1000;  \/\/ default to every second\n\nlong i2cTimer;    \/\/ used for I2C bus scan refreshes - could use the dataTimer I suppose but if set high then slow refresh\n\nbyte inCommand;   \/\/ serial.read input command for remote control\n\nboolean potMode   = false; \/\/ Where to read for PWM and Servo - true = pot, false = buttons, UP\/DOWN together to toggle\nboolean soundOn   = true;  \/\/ Can toggle sound on \/ off - DOWN then SEL buttons\n\n\/\/ Setup stepper motor option on 9,11,10,12\n\/\/ NOTE!: You will need a separate supply to drive the motor or you may blow the Nano regulator\nconst int stepsPerRevolution = 2048;  \/\/ change this to fit the number of steps per revolution\nStepper myStepper(stepsPerRevolution, 9, 11, 10, 12);\nint stepCount = 0;\n\nvoid setup()   \n{  \n  \/\/ Start up the display\n  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  \/\/ initialize with the I2C addr 0x3C (for the 128x32)\n\n  \/\/ Show opening screen\n  display.clearDisplay();\n      display.drawBitmap(98, 0,  nanoImg, 32, 30, 1);\n      display.setTextColor(WHITE);\n      display.setCursor(0,0);\n\/\/      display.print(\"Ver:\" + curVer); \/\/ Saves some bytes for memory like this\n      display.print(\"Ver:2020-01-01\");\n      #ifdef useFonts\n        display.setCursor(0,24);\n        display.setFont(&amp;FreeSans9pt7b);\n      #else\n        display.setCursor(0,14);\n        display.setTextSize(2);\n      #endif\n      display.print(\"NanOMeter\");\n  display.display();\n\n  Serial.begin(115200);   \/\/ For data logging and remote control\n  \n  \/\/ Input buttons\n  pinMode(2,INPUT_PULLUP);\n  pinMode(3,INPUT_PULLUP);\n  pinMode(4,INPUT_PULLUP);\n  \n  \/\/ speaker and built in LED working together\n  pinMode(13,OUTPUT);\n\n  \/\/ Attach servo port\n  myServo.attach(5);\n\n  \/\/ Setup stepper speed\n  myStepper.setSpeed(6);\n\n  \/\/ Interrrupt routine to read the middle button\n  attachInterrupt(1, buttonPress, FALLING);\n\n  delay(3000);\n  display.clearDisplay();\n  display.display();\n  dataTimer = millis();\n  i2cTimer = millis();\n}\n\nvoid loop()\n{\n    \/\/ Up AND Select - \n    if ((digitalRead(2)==0) &amp;&amp; (digitalRead(3)==0))\n    {\n      \/\/ room to toggle one more item here but no memory\n      \n      delay(250);\n    }\n    \n    \/\/ Select AND Down - Toggle sound on\/off - draw speaker icon to show result\n    if ((digitalRead(3)==0) &amp;&amp; (digitalRead(4)==0))\n    {\n      soundOn = !soundOn;\n      toner(13,800,50);\n      display.clearDisplay(); \n        if (soundOn)\n        {display.drawBitmap(96, 0,  speakerImg, 32, 32, 1);}\n        else\n        {display.drawBitmap(96, 0,  nospeakerImg, 33, 32, 1);}        \n      display.display();\n      delay(1000);\n    }\n    \n    \/\/ UP and DOWN - Check \/ toggle potMode here - not needed in each mode\n    if ((digitalRead(2)==0) &amp;&amp; (digitalRead(4)==0))\n    {\n      potMode = !potMode;   \/\/ toggle where we are getting information\n      toner(13,800,50);\n      delay(250);\n    }\n\n  \/\/ If we have a serial command then read it in\n  if (Serial.available() > 0) \n  {\n    inCommand = Serial.read(); \/\/ read the incoming byte:\n    \/\/ M just bumps the mode - not overlly useful but how I started\n    if (inCommand == 'M')\n    {\n      Mode++;\n      toner(13,2250,50);\n      if(Mode > maxModes)\n      {\n        Mode=0;\n      }\n    }\n    \/\/ 0 - 9 goes directly into the requested mode, A jumps to the Adjust Data Log Timer mode\n    \/\/ Obviously it would be nice to have direct commands such as 5:200 to set PWM to 200 BUT running out of memory for code\n    \/\/ And I don't want to burn a lot of time optimizing things\n    if (inCommand == '0'){toner(13,2250,50);Mode = 0;} \/\/ Volt meter\n    if (inCommand == '1'){toner(13,2250,50);Mode = 1;} \/\/ Analog read mode\n    if (inCommand == '2'){toner(13,2250,50);Mode = 2;} \/\/ Resistor read mode\n    if (inCommand == '3'){toner(13,2250,50);Mode = 3;} \/\/ Diode drop mode\n    if (inCommand == '4'){toner(13,2250,50);Mode = 4;} \/\/ Continuity mode\n    if (inCommand == '5'){toner(13,2250,50);Mode = 5;} \/\/ PWM mode\n    if (inCommand == '6'){toner(13,2250,50);Mode = 6;} \/\/ Servo tester mode\n    if (inCommand == '7'){toner(13,2250,50);Mode = 7;} \/\/ Ping-SR04 mode\n    if (inCommand == '8'){toner(13,2250,50);Mode = 8;} \/\/ Stepper test mode\n    if (inCommand == '9'){toner(13,2250,50);Mode = 9;} \/\/ Battery test mode\n    if (inCommand == 'A'){toner(13,2250,50);Mode = 10;}\/\/ Adjust data logging\n    if (inCommand == 'I'){toner(13,2250,50);Mode = 11;}\/\/ I2C scan mode\n  }\n\n  \/\/ Process the Modes - These should really call subs for this but works for me for now\n   \n  \/\/********************************************\/\/\n  \/\/ Volt Meter - Uses A7 as input and 100K \/ 10K voltage divider\n  \/\/********************************************\/\/\n  \/\/\n  if(Mode==0)\n  {\n    float volt3=readVcc()\/1000.0;\n    Val = analogRead(A7);\n    Vout2 = (Val * volt3) \/ 1024.0; \/\/ see text\n    Vin2  = Vout2 \/ (Res2\/(Res1+Res2)); \n    \/\/ Trying to compensate for the 1N914 reverse voltage protection diode used on probes\n    \/\/ This seems to need to compensate for the actual voltage more as higher votages are slightly off\n    \/\/ Not a big deal for my needs but be aware of that issue\n    \/\/ You can use your diode voltage drop feature to see what the diode says at the 5v point at least\n    if (Vin2 > 0.0)\n    {\n      \/\/Vin2 += 0.33;\n      Vin2 += 0.0;\n    }\n    display.clearDisplay(); \n      display.drawBitmap(96, 0,  voltImg, 32, 32, 1);\n      display.setFont();\n      display.setTextSize(1);\n      display.setTextColor(WHITE);\n      display.setCursor(0,0);\n      display.print(\"Volts:\");\n      display.setCursor(50,0);\n      display.print(volt3);\n      display.print(\"v\");\n      #ifdef useFonts\n        display.setCursor(0,24);\n        display.setFont(&amp;FreeSans12pt7b);\n      #else\n        display.setCursor(0,10);\n        display.setTextSize(2);\n      #endif      \n      display.print(Vin2);\n      display.print(\"v\");\n    display.display();\n\n    \/\/ Send logging data to serial port\n    if (getET(dataTimer) > dataTrigger)\n    {\n      Serial.print(\"Volts,\");\n      Serial.print(millis());\n      Serial.print(\",\");\n      Serial.println(Vin2);\n      dataTimer = millis();\n    }\n    delay(Pause);\n  }\n\n  \/\/********************************************\/\/\n  \/\/ Analog input - Reads A0 and displays the analog read information along with min,max, and avg\n  \/\/********************************************\/\/\n  if(Mode==1)\n  {\n    if((digitalRead(4)==0) || (inCommand == '=')) \/\/ button to reset stats or inCommand of =1\n    { \n      delay(100); minimum=1024; maximum=0; numberOfTimes=0; sum=0; \n    }\n    display.clearDisplay();\n      \/\/display.drawBitmap(43, 0,  analogImg, 32, 28, 1);\n      display.setFont();\n      display.setTextColor(WHITE);\n      display.setCursor(0,0);\n      display.setTextSize(1);\n      display.print(\"Analog:\");\n      int value=analogRead(A0);\n      numberOfTimes=numberOfTimes+1;\n      sum=sum+value;\n      avg=sum\/numberOfTimes;\n      if(value>maximum)\n        maximum=value;\n      if(value&lt;minimum)\n        minimum=value;\n      display.setFont();\n      int lineWide=map(value,0,1024,0,128);\n      display.setCursor(70,0);\n        display.print(\"MIN:\");\n      display.setCursor(95,0);\n        display.print(minimum);\n      display.setCursor(70,10);\n        display.print(\"AVG:\");\n      display.setCursor(95,10);\n        display.print(avg);\n      display.setCursor(70,20);\n        display.print(\"MAX:\");\n      display.setCursor(95,20);\n        display.print(maximum);\n      #ifdef useFonts\n        display.setCursor(0,24);\n        display.setFont(&amp;FreeSans9pt7b);\n      #else\n        display.setCursor(0,10);\n        display.setTextSize(2);\n      #endif\n        display.print(value);\n\/\/      display.drawLine(0,31,lineWide,31,1);\n      lineWide = map(value,0,1024,0,30);\n      for (int myLine = 50; myLine &lt; 65; myLine++)\n      {\n        display.drawLine(myLine,31,myLine,30-lineWide,1);\n      }\n   display.display();\n\n    \/\/ Send logging data to serial port\n    if (getET(dataTimer) > dataTrigger)\n    {\n      Serial.print(\"Analog,\");\n      Serial.print(millis());\n      Serial.print(\",\");\n      Serial.print(value);\n      Serial.print(\",\");\n      Serial.print(minimum);\n      Serial.print(\",\");\n      Serial.print(avg);\n      Serial.print(\",\");\n      Serial.println(maximum);\n      dataTimer = millis();\n    }\n\n   \/\/ Auto reset average every so often\n   if(numberOfTimes>100000)\n    {\n      numberOfTimes=0;\n      sum=0;\n    }\n  \n  }\n\n  \/\/********************************************\/\/\n  \/\/ Ohm Meter - Reads A2 value and calclates the resistor value\n  \/\/********************************************\/\/\n  if(Mode==2)\n  {\n    display.clearDisplay(); \n      display.setFont();\n      display.setCursor(0,0);\n      display.setTextSize(1);\n      display.print(\"Ohms:\");\n      display.drawBitmap(96, 0,  resistorImg, 32, 32, 1);\n      Raw= analogRead(A2);\n      Vin=readVcc()\/1000.0;\n      buffer= Raw * Vin;\n      Vout= (buffer)\/1024.0;\n      buffer= (Vin\/Vout) -1;\n      R2= R1 * buffer;\n      #ifdef useFonts\n        display.setCursor(0,24);\n        display.setFont(&amp;FreeSans12pt7b);\n      #else\n        display.setCursor(0,10);\n        display.setTextSize(2);\n      #endif\n      if(R2&lt;700000)\n        display.print(R2);\n      if(R2>700000)\n        display.print(\"Empty\");\n    display.display();\n    delay(Pause);\n\n    \/\/ Send logging data to serial port\n    if (getET(dataTimer) > dataTrigger)\n    {\n      Serial.print(\"Ohms,\");\n      Serial.print(millis());\n      Serial.print(\",\");\n      Serial.println(R2);\n      dataTimer = millis();\n    }\n    \n  }\n\n  \/\/********************************************\/\/\n  \/\/ Diode Voltage Drop - Read the A2 input and calcs the voltage drop across an diode or LED\n  \/\/********************************************\/\/\n  if(Mode==3)\n  {\n    display.clearDisplay();\n      display.drawBitmap(96, 0,  diodeImg, 32, 32, 1);\n      display.setFont();\n      display.setCursor(0,0);\n      display.setTextSize(1);\n      display.print(\"Voltage Drop:\");\n      Raw= analogRead(A2);\n      Vin=readVcc()\/1000.0;\n      buffer= Raw * Vin;\n      Vout= (buffer)\/1024.0;\n      #ifdef useFonts\n        display.setCursor(0,24);\n        display.setFont(&amp;FreeSans12pt7b);\n      #else\n        display.setCursor(0,10);\n        display.setTextSize(2);\n      #endif\n\n      if(Vout==0)\n      {\n          display.print(\"Empty\/0\");\n      }\n      else\n      {\n         display.print(Vin-Vout);\n      }\n    display.display();\n\n    \/\/ Send logging data to serial port\n    if (getET(dataTimer) > dataTrigger)\n    {\n      Serial.print(\"VoltDrop,\");\n      Serial.print(millis());\n      Serial.print(\",\");\n      Serial.println(Vout);\n      dataTimer = millis();\n    }\n\n    delay(Pause);\n  }\n\n  \/\/********************************************\/\/\n  \/\/ Continuity Testor - Reads A2 and uses resistance &lt; 1 to determine continuity\n  \/\/********************************************\/\/\n  if(Mode==4)\n  {\n    display.clearDisplay();\n      Raw= analogRead(A2);\n      Vin=readVcc()\/1000.0;\n      buffer= Raw * Vin;\n      Vout= (buffer)\/1024.0;\n      float continuity=Vin-Vout;\n      display.drawBitmap(96, 0,  continuityImg, 32, 32, 1);\n      display.setFont();\n      display.setCursor(0,0);\n      display.setTextSize(1);\n      display.print(\"Continuity: \");\n      display.print(Vout);\n      #ifdef useFonts\n        display.setCursor(0,24);\n        display.setFont(&amp;FreeSans12pt7b);\n      #else\n        display.setCursor(0,10);\n        display.setTextSize(2);\n      #endif\n\n      if(continuity&lt;1)\n      {\n        toner(13,2250,65000);\n        display.print(\"Yes\");\n      }\n     if(continuity>1)\n     {\n        noTone(13);\n        display.print(\"None \");        \n     }\n   display.display();\n\n   \/\/ Send logging data to serial port\n   if (getET(dataTimer) > dataTrigger)\n    {\n      Serial.print(\"Continuity,\");\n      Serial.print(millis());\n      Serial.print(\",\");\n      Serial.println(continuity);\n      dataTimer = millis();\n    }\n\n }\n\n  \/\/********************************************\/\/\n  \/\/ PWM output - PWM output for driving things - this is NOT servo BUT will kind of work with servo\n  \/\/********************************************\/\/\n  if(Mode==5)\n  {\n    if ((digitalRead(2)==0) || (inCommand == '+'))\n    { \n      if(Pulse&lt;255)\n      {\n        toner(13,1800,10);\n        Pulse += 1; \n      } \n    }\n\n    if((digitalRead(4)==0) || (inCommand == '-'))\n    { \n      if(Pulse>1)\n      {\n        toner(13,1400,10);\n        Pulse -= 1; \n      } \n    }\n    \/\/ Recenter on = command\n    if(inCommand == '=')\n    {\n      Pulse=127;\n    }\n    \/\/ If we have a pot on the analog input, use it to control the servo\n    if (potMode)\n    {\n      Val = analogRead(A0);\n      Pulse = map(Val,0,1023,0,255);\n    }\n \n    int lineWide2=0;\n    analogWrite(6,Pulse);\n    display.clearDisplay();\n      \/\/display.drawBitmap(72, 1,  pwmImg, 58, 30, 1);\n      display.drawBitmap(96, 1,  pwmImg, 32, 32, 1);\n      display.setFont();\n      display.setCursor(0,0);\n      display.setTextSize(1);\n      display.print(\"Pulse Width:\");\n      if (potMode)\n      {\n        display.print(\"(Pot)\");\n      }\n      #ifdef useFonts\n        display.setCursor(0,24);\n        display.setFont(&amp;FreeSans12pt7b);\n      #else\n        display.setCursor(0,10);\n        display.setTextSize(2);\n      #endif\n\n      display.print(Pulse);\n      lineWide2= map(Pulse,0,255,0,128);\n      display.drawLine(0,31,lineWide2,31,1);\n   display.display();\n\n   \/\/ Send logging data to serial port\n   if (getET(dataTimer) > dataTrigger)\n    {\n      Serial.print(\"PWM,\");      \n      Serial.print(millis());\n      Serial.print(\",\");\n      Serial.println(Pulse);\n      dataTimer = millis();\n    }\n\n  }   \n\n  \/\/********************************************\/\/\n  \/\/ Servo Tester - Software Servo output on pin 5 - drives servo header\n  \/\/********************************************\/\/\n  if(Mode==6)\n  {\n    if((digitalRead(2)==0) || (inCommand == '+'))\n    { \n      if(servoPulse&lt;180)\n      {\n        \/\/toner(13,1800,10);\n        servoPulse += 1; \n      } \n    }\n\n    if((digitalRead(4)==0) || (inCommand == '-'))\n    { \n      if(servoPulse>1)\n      {\n        \/\/toner(13,1400,10);\n        servoPulse -= 1; \n      } \n    }\n    \/\/ Recenter on = command\n    if(inCommand == '=')\n    {\n      servoPulse=90;\n    }\n\n    \/\/ If we have a pot on the analog input, use it to control the servo\n    if (potMode)\n    {\n      Val = analogRead(A0);\n      servoPulse = map(Val,0,1023,0,180);\n    }\n\n    int lineWide2=0;\n    myServo.write(servoPulse);\n    \n    display.clearDisplay();\n      display.drawBitmap(96, 1,  servoImg, 32, 25, 1);\n      \/\/display.drawBitmap(72, 1,  pwmImg, 58, 30, 1);\n      display.setFont();\n      display.setCursor(0,0);\n      display.setTextSize(1);\n      display.print(\"Servo:\");\n      if (potMode)\n      {\n        display.print(\"(Pot)\");\n      }\n      #ifdef useFonts\n        display.setCursor(0,24);\n        display.setFont(&amp;FreeSans12pt7b);\n      #else\n        display.setCursor(0,10);\n        display.setTextSize(2);\n      #endif\n      \n      display.print(servoPulse);\n      lineWide2= map(servoPulse,0,180,0,128);\n      display.drawLine(0,31,lineWide2,31,1);\n   display.display();\n   myServo.refresh();\n   \n   \/\/ Send logging data to serial port\n\n   if (getET(dataTimer) > dataTrigger)\n   {\n      Serial.print(\"Servo,\");\n      Serial.print(millis());\n      Serial.print(\",\");\n      Serial.println(servoPulse);\n      dataTimer = millis();\n   }\n }   \n\n  \/\/********************************************\/\/\n  \/\/ SR 04 ping tester\n  \/\/********************************************\/\/\n  if(Mode==7)\n  {\n    display.clearDisplay();\n      display.drawBitmap(96, 0,  radarImg, 32, 32, 1);\n      display.setFont();\n      display.setCursor(0,0);\n      display.setTextSize(1);\n      display.print(\"Ping Distance:\");\n      #ifdef useFonts\n        display.setCursor(0,24);\n        display.setFont(&amp;FreeSans12pt7b);\n      #else\n        display.setCursor(0,10);\n        display.setTextSize(2);\n      #endif\n\n      mydistance = ReadSonar();\n      display.print(mydistance);\n      display.print(\" cm\");\n    display.display();\n    delay(Pause);\n\n    \/\/ Send logging data to serial port\n    if (getET(dataTimer) > dataTrigger)\n    {\n      Serial.print(\"Sonar,\");\n      Serial.print(millis());\n      Serial.print(\",\");\n      Serial.println(mydistance);\n      dataTimer = millis();\n    }\n\n  }\n\n  \/\/********************************************\/\/\n  \/\/ Stepper - Stepper on pins 9,10,11,12 - Upper right side of Nano\n  \/\/********************************************\/\/\n  if(Mode==8)\n  {\n    if((digitalRead(2)==0) || (inCommand == '+'))\n    { \n      myStepper.step(1);\n      stepCount += 1;\n    }\n\n    if((digitalRead(4)==0) || (inCommand == '-'))\n    { \n      myStepper.step(-1);\n      stepCount -= 1;\n    }\n\n    int lineWide2=0;\n\n    display.clearDisplay();\n      display.drawBitmap(96, 1,  stepperImg, 32, 32, 1);\n      display.setFont();\n      display.setCursor(0,0);\n      display.setTextSize(1);\n      display.print(\"Stepper:\");\n      #ifdef useFonts\n        display.setCursor(0,24);\n        display.setFont(&amp;FreeSans12pt7b);\n      #else\n        display.setCursor(0,10);\n        display.setTextSize(2);\n      #endif\n\n      display.print(stepCount);\n      lineWide2= map(stepCount,-2048,2048,0,128);\n      display.drawLine(0,31,lineWide2,31,1);\n   display.display();\n   \n   \/\/ Send logging data to serial port\n   if (getET(dataTimer) > dataTrigger)\n   {\n      Serial.print(\"Stepper,\");\n      Serial.print(millis());\n      Serial.print(\",\");\n      Serial.println(stepCount);\n      dataTimer = millis();\n   }\n }   \n\n\n  \/\/********************************************\/\/\n  \/\/ Internal Battery Vcc - Reads internal voltage somehow and displays\n  \/\/ This cannot be the actual BATTERY voltage - must be internal based on other input?\n  \/\/********************************************\/\/\n\/\/  if(Mode==8)\n\/\/  {\n\/\/    \n\/\/    display.clearDisplay();\n\/\/      display.drawBitmap(96, 0,  batteryImg, 32, 32, 1);\n\/\/      display.setFont();\n\/\/      display.setCursor(0,0);\n\/\/      display.setTextSize(1);\n\/\/      display.print(\"Battery:\");\n\/\/      #ifdef useFonts\n\/\/      display.setCursor(0,24);\n\/\/        display.setFont(&amp;FreeSans12pt7b);\n\/\/      #else\n\/\/        display.setCursor(0,10);\n\/\/        display.setTextSize(2);\n\/\/      #endif\n\/\/\n\/\/      float volt2=readVcc()\/1000.0;\n\/\/      display.print(volt2);\n\/\/      display.setCursor(55,28);\n\/\/      display.print(\"V\");\n\/\/    display.display();\n\/\/    delay(Pause);\n\n\/\/    \/\/ Send logging data to serial port\n\/\/    if (getET(dataTimer) > dataTrigger)\n\/\/    {\n\/\/      Serial.print(\"IntBatt\");\n\/\/      Serial.print(\",\");\n\/\/      Serial.print(millis());\n\/\/      Serial.print(\",\");\n\/\/      Serial.println(volt2);\n\/\/      dataTimer = millis();\n\/\/    }\n\n\/\/  }\n\n  \/\/********************************************\/\/\n  \/\/ External Battery Vcc - Reads internal voltage somehow and displays\n  \/\/********************************************\/\/\n  if(Mode==9)\n  {\n    float volt3=readVcc()\/1000.0;\n    Val = analogRead(A1);\n    Vout2 = (Val * volt3) \/ 1024.0; \/\/ see text\n    Vin2  = Vout2 \/ (Res2\/(Res1+Res2)); \n    \/\/Vin2 += 0.64;            \/\/ Drop for protection diode\n    \/\/Vin2 -= 0.10;             \/\/ resting value no connection\n    if (Vin2 > 0.9)\n    {\n      Vin2 += 0.33;\n    }\n    display.clearDisplay(); \n      display.drawBitmap(96, 0,  batteryImg, 32, 32, 1);\n      display.setFont();\n      display.setTextColor(WHITE);\n      display.setCursor(0,0);\n      display.setTextSize(1);\n      display.print(\"Ext Battery:\");\n      #ifdef useFonts\n        display.setCursor(0,24);\n        display.setFont(&amp;FreeSans12pt7b);\n      #else\n        display.setCursor(0,10);\n        display.setTextSize(2);\n      #endif\n      display.print(Vin2);\n      display.print(\"v\");\n    display.display();\n    delay(Pause);\n\n    \/\/ Send logging data to serial port\n    if (getET(dataTimer) > dataTrigger)\n    {\n      Serial.print(\"ExtBatt,\");\n      Serial.print(millis());\n      Serial.print(\",\");\n      Serial.println(Vin2);\n      dataTimer = millis();\n    }\n  }\n\n  \/\/********************************************\/\/\n  \/\/ Adjust data dump timer\n  \/\/********************************************\/\/\n  if(Mode==10)\n  {\n    \/\/ If we have a pot on the analog input, use it to control the servo\n    if (potMode)\n    {\n      Val = analogRead(A0);\n      Pulse = map(Val,0,1023,0,255);\n    }\n\n    if((digitalRead(2)==0) || (inCommand == '+'))\n    { \n      if(dataTrigger&lt;60000)   \/\/ Max one minute\n      {\n        toner(13,1300,10);\n        dataTrigger += 10; \n      } \n    }\n\n    if((digitalRead(4)==0) || (inCommand == '-'))\n    { \n      if(dataTrigger>500)   \/\/ Min 1\/2 second\n      {\n        toner(13,1400,10);        \n        dataTrigger -= 10;\n      } \n    }\n\n    \/\/ If we have a pot on the analog input, use it to control the servo\n    if (potMode)\n    {\n      Val = analogRead(A0);\n      dataTrigger = map(Val,0,1000,500,60000);\n      dataTrigger = constrain(dataTrigger,500,60000);\n    }\n\n    if (inCommand == '='){dataTrigger = 1000;}\n    \n    int lineWide2=0;\n    display.clearDisplay();\n      display.drawBitmap(96, 1,  dataImg, 32, 32, 1);\n      display.setFont();\n      display.setCursor(0,0);\n      display.setTextSize(1);\n      display.print(\"Data Log:\");\n      if (potMode)\n      {\n        display.print(\"(Pot)\");\n      }\n      #ifdef useFonts\n        display.setCursor(0,24);\n        display.setFont(&amp;FreeSans12pt7b);\n      #else\n        display.setCursor(0,10);\n        display.setTextSize(2);\n      #endif\n      display.print(dataTrigger);\n      display.print(\" mS\");\n      lineWide2= map(dataTrigger,500,5000,0,128);\n      display.drawLine(0,31,lineWide2,31,1);\n   display.display();\n  }\n\n  \/\/********************************************\/\/\n  \/\/ I2C Bus Scan\n  \/\/********************************************\/\/\n  if(Mode==11)\n  {\n    if (getET(i2cTimer) > 2000) \/\/ Just scan every two seconds, not every loop\n    {\n      i2cScan();\n      i2cTimer = millis();\n    }\n  }\n \n}\n\/\/********************************************\/\/\n\/\/ END OF MAIN LOOP\n\/\/********************************************\/\/\n\n\/\/ Interrupt routine to read the middle button and change Modes\nvoid buttonPress()\n{\n  static unsigned long last_interrupt_time = 0;\n  unsigned long interrupt_time = millis();\n  \/\/ If interrupts come faster than 200ms, assume it's a bounce and ignore\n  if (interrupt_time - last_interrupt_time > 220) \n  {\n    Mode++;\n    toner(13,2250,50);\n    if(Mode > maxModes)\n    Mode=0;\n  }\n  last_interrupt_time = interrupt_time;\n}\n\n\nlong readVcc() \n{\n  \/\/ Read 1.1V reference against AVcc\n  \/\/ set the reference to Vcc and the measurement to the internal 1.1V reference\n  #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)\n    ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);\n  #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)\n    ADMUX = _BV(MUX5) | _BV(MUX0);\n  #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)\n    ADMUX = _BV(MUX3) | _BV(MUX2);\n  #else\n    ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);\n  #endif  \n\n  delay(2); \/\/ Wait for Vref to settle\n  ADCSRA |= _BV(ADSC); \/\/ Start conversion\n  while (bit_is_set(ADCSRA,ADSC)); \/\/ measuring\n\n  uint8_t low  = ADCL; \/\/ must read ADCL first - it then locks ADCH  \n  uint8_t high = ADCH; \/\/ unlocks both\n\n  long result = (high&lt;&lt;8) | low;\n\n  result = 1125300L \/ result; \/\/ Calculate Vcc (in mV); 1125300 = 1.1*1023*1000\n  return result; \/\/ Vcc in millivolts\n}\n\nlong ReadSonar()\n{\n  long duration, distance;\n  pinMode(TRIGGER_PIN, OUTPUT);\n  digitalWrite(TRIGGER_PIN, LOW);\n  delayMicroseconds(2);\n  digitalWrite(TRIGGER_PIN, HIGH);\n  delayMicroseconds(10);\n  digitalWrite(TRIGGER_PIN, LOW);\n  pinMode(ECHO_PIN, INPUT);\n  duration = pulseIn(ECHO_PIN, HIGH);\n  distance = duration \/ 58.2;\n \n  return distance;\n\n}\n\n\/\/ ** returns the ET in millis for timer variable passed\nlong getET(long mytimer)\n{\n  long result;\n  result = (millis() - mytimer);\n  return result;\n}\n\n\/\/ Regular old I2C scanning routine and display\nvoid i2cScan()\n{\n  byte error;\n  int address;\n  int nDevices;\n\n display.clearDisplay();\n   display.drawBitmap(96, 1,  satImg, 32, 32, 1);\n   display.setFont();\n   display.setCursor(0,0);\n   display.setTextSize(1);\n   display.print(\"I2C Scan:\");\n   display.setCursor(0,12);\n\n   Serial.print(\"I2C,\");\n   Serial.print(millis());\n\n    nDevices = 0;\n    for(address = 1; address &lt; 127; address++ )\n    {\n      Wire.beginTransmission(address);\n      error = Wire.endTransmission();\n\n      if (error == 0)\n      {\n        if (address&lt;16)\n        {\n          Serial.print(\",0\");\n          display.print(\"0\");\n        }\n        else\n        {\n          Serial.print(\",\");\n        }\n        Serial.print(address,HEX);\n        display.print(address,HEX);\n        display.print(\" \");\n        nDevices++;\n        if (nDevices == 5)      \/\/ \n        {\n          display.println();\n        }\n      }\n  }\n  display.display();\n  Serial.println();\n}\n\n\/\/ tone() replacement to allow muting sound via soundOn\nvoid toner(byte mypin, int mysound, int mylen)\n{\n  if (soundOn)\n  {\n    tone(mypin, mysound, mylen);\n  }\n}\n\n\/\/****************************************************************************\/\/\n\/\/ End of the world as we know it..\u0086\u0084\u00ff\u00b0\u0017\u0001<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>(Pronounced Nan OM eter \u2013 Like speedometer of course) Having historically kludged together a breadboard, or dead bug wired something to simply test an SR04, measure a resistance, or test a servo or stepper driver, I finally decided I\u2019d do something a little more permanent. What trigger this was seeing VolsR\u2019s (https:\/\/www.instructables.com\/member\/VolosR\/) little Nano based &hellip; <a href=\"https:\/\/www.protowrxs.com\/index.php\/2020\/01\/01\/nanometer-2020\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;NanOMeter 2020&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"spay_email":""},"categories":[24,23],"tags":[20,22,21],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/posts\/1416"}],"collection":[{"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/comments?post=1416"}],"version-history":[{"count":4,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/posts\/1416\/revisions"}],"predecessor-version":[{"id":1424,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/posts\/1416\/revisions\/1424"}],"wp:attachment":[{"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/media?parent=1416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/categories?post=1416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.protowrxs.com\/index.php\/wp-json\/wp\/v2\/tags?post=1416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}