{"id":257,"date":"2021-08-01T15:14:26","date_gmt":"2021-08-01T15:14:26","guid":{"rendered":"https:\/\/schoental.wordpress.com\/?p=257"},"modified":"2025-03-30T12:22:09","modified_gmt":"2025-03-30T12:22:09","slug":"servotester","status":"publish","type":"post","link":"https:\/\/www.corbuhobby.nl\/index.php\/2021\/08\/01\/servotester\/","title":{"rendered":"Servotester"},"content":{"rendered":"\n<p>Om de servo&#8217;s te kunnen testen, op 90 graden instellen voor montage en om de eindstanden van de wissels te bepalen is een servotester gebouwd op basis van de Arduino Nano en in een doosje uit de 3D printer gestopt.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Hier een <a href=\"https:\/\/youtu.be\/f3WmS1uuN_k\" target=\"_blank\" rel=\"noreferrer noopener\">filmpje<\/a>. Aan de oorspronkelijke sketch van  Michal Rinott en  Scott Fitzgerald is code toegevoegd om het OLED schermpje  SSD1306 aan te sturen.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" src=\"https:\/\/www.corbuhobby.nl\/wp-content\/uploads\/2021\/07\/20210729_110543.jpg?w=525\" alt=\"\" class=\"wp-image-231\" \/><\/figure><\/div>\n\n\n\n<p>Onderdelenlijst:<\/p>\n\n\n\n<div class=\"wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile\"><figure class=\"wp-block-media-text__media\"><img decoding=\"async\" src=\"https:\/\/schoental.files.wordpress.com\/2021\/07\/20210729_110711.jpg?w=525\" alt=\"\" class=\"wp-image-233 size-full\" \/><\/figure><div class=\"wp-block-media-text__content\">\n<ul class=\"wp-block-list\"><li>Arduino Nano<\/li><li>Potentiometer 10-20 kohm<\/li><li>3pins Dupont stekker M<\/li><li>Powerbank of USB lader<\/li><li>Doosje<\/li><li>Draaiknop<\/li><\/ul>\n\n\n\n<p><\/p>\n<\/div><\/div>\n\n\n\n<p>De sketch:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/*\n Controlling a servo position using a potentiometer (variable resistor)\n by Michal Rinott &lt;http:\/\/people.interaction-ivrea.it\/m.rinott&gt;\n\n modified on 8 Nov 2013\n by Scott Fitzgerald\n http:&#047;&#047;www.arduino.cc\/en\/Tutorial\/Knob\n\n Modified on 21 Nov 2020 by corbutrain to include OLED display\n Note: connect OLED display VDD to Arduino 3.3V !\n\n Connections\n 3.3V - VCC OLED orange\n A0   - Potmeter runner grey\n A4   - SDA OLED blue\n A5   - SLK OLED green\n 5V   - Potmeter, Servo Out red\n GND  - Potmeter, OLED, Servo Out white\n D9   - Servo Out yellow\n USB  - Power Source or PC\n*\/\n\n#include &lt;Servo.h&gt;\n\/\/ for OLED display:\n#include &lt;Adafruit_GFX.h&gt;\n#include &lt;Adafruit_SSD1306.h&gt;\nAdafruit_SSD1306 display(4); \/\/ OLED DISPLAY INIT\n\nServo myservo;  \/\/ create servo object to control a servo\n\nconst int LED_ON = 7;  \/\/ half cycle expressed in number of loops to have LED on\n\nint potpin = 0;  \/\/ analog pin used to connect the potentiometer\nint val;    \/\/ variable to read the value from the analog pin\nint count;       \/\/ counter to flash de LED_BUILTIN\n\nvoid setup() {\n\/\/  Serial.begin(9600);\n\/\/  while (!Serial) {\n\/\/    ; \/\/ wait for serial port to connect. Needed for native USB port only\n\/\/  }\n  myservo.attach(9);  \/\/ attaches the servo on pin 9 to the servo object\n  \/\/ initialize digital pin LED_BUILTIN as an output.\n  pinMode(LED_BUILTIN, OUTPUT);\n  count = 0;\n  digitalWrite(LED_BUILTIN, LOW);    \/\/ turn the LED off by making the voltage LOW\n  \n  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  \/\/ initialize OLED display\n  display.clearDisplay();\n  display.setTextColor(WHITE,BLACK);\n  display.setTextSize(4);\n  display.setCursor(36,16);\n}\n\nvoid loop() {\n  val = analogRead(potpin);            \/\/ reads the value of the potentiometer (value between 0 and 1023)\n  val = map(val, 0, 1023, 0, 180);     \/\/ scale it to use it with the servo (value between 0 and 180)\n  display.print(val);\n  display.display();\n  myservo.write(val);                  \/\/ sets the servo position according to the scaled value\n  delay(15);                           \/\/ waits for the servo to get there\n  count = count + 1;\n  if (count &lt; LED_ON)  \n    digitalWrite(LED_BUILTIN, LOW);    \/\/ turn the LED off by making the voltage LOW\n  if (count &gt; LED_ON) \n    digitalWrite(LED_BUILTIN, HIGH);   \/\/ turn the LED on (HIGH is the voltage level)\n  if (count &gt; (LED_ON * 2))            \/\/ check on full clock cycle and set counter\n    count = 0;\n  display.clearDisplay();\n  display.setCursor(36,16); \n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Om de servo&#8217;s te kunnen testen, op 90 graden instellen voor montage en om de eindstanden van de wissels te bepalen is een servotester gebouwd op basis van de Arduino Nano en in een doosje uit de 3D printer gestopt.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[55,49],"tags":[9,42,13,26,29],"class_list":["post-257","post","type-post","status-publish","format-standard","hentry","category-servo","category-spoor","tag-3d-printer","tag-arduino","tag-bouw","tag-servo","tag-techniek"],"_links":{"self":[{"href":"https:\/\/www.corbuhobby.nl\/index.php\/wp-json\/wp\/v2\/posts\/257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.corbuhobby.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.corbuhobby.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.corbuhobby.nl\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.corbuhobby.nl\/index.php\/wp-json\/wp\/v2\/comments?post=257"}],"version-history":[{"count":1,"href":"https:\/\/www.corbuhobby.nl\/index.php\/wp-json\/wp\/v2\/posts\/257\/revisions"}],"predecessor-version":[{"id":744,"href":"https:\/\/www.corbuhobby.nl\/index.php\/wp-json\/wp\/v2\/posts\/257\/revisions\/744"}],"wp:attachment":[{"href":"https:\/\/www.corbuhobby.nl\/index.php\/wp-json\/wp\/v2\/media?parent=257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.corbuhobby.nl\/index.php\/wp-json\/wp\/v2\/categories?post=257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.corbuhobby.nl\/index.php\/wp-json\/wp\/v2\/tags?post=257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}