{"id":406,"date":"2016-04-28T17:00:39","date_gmt":"2016-04-28T08:00:39","guid":{"rendered":"http:\/\/anatomy.med.gunma-u.ac.jp\/protocols\/?p=406"},"modified":"2016-06-14T11:03:42","modified_gmt":"2016-06-14T02:03:42","slug":"%e9%80%9a%e9%81%8e%e3%82%bb%e3%83%b3%e3%82%b5%e3%83%bc%e3%81%a7%e6%a9%9f%e5%99%a8%e3%82%92%e9%a7%86%e5%8b%95","status":"publish","type":"post","link":"https:\/\/anatomy.med.gunma-u.ac.jp\/protocols\/?p=406","title":{"rendered":"\u901a\u904e\u30bb\u30f3\u30b5\u30fc\u3067\u6a5f\u5668\u3092\u5236\u5fa1"},"content":{"rendered":"<p>\u5b9f\u9a13\u88c5\u7f6e\u306e\u52d5\u4f5c\u306b\u5408\u308f\u305b\u3066\u30c7\u30b8\u30bf\u30eb\u30ab\u30e1\u30e9\u3067\u81ea\u52d5\u7684\u306b\u64ae\u5f71\u3055\u305b\u308b\u305f\u3081\u3001\u901a\u904e\u30bb\u30f3\u30b5\u30fc\u3068Arduino\u3067\u30ab\u30e1\u30e9\u3068\u88c5\u7f6e\u3068\u3092\u540c\u671f\u3055\u305b\u305f\u3002<\/p>\n<p><!--more-->\u30bb\u30f3\u30b5\u30fc\u306f\uff12\u3064\u3042\u308a\u3001\u5199\u771f\u5965\u304c\u30b7\u30e3\u30c3\u30bf\u30fc\u534a\u62bc\u3057\u7528\u3001\u624b\u524d\u304c\u30ea\u30ea\u30fc\u30b9\u7528\u3002\u9806\u306b\u53cd\u5fdc\u3057\u305f\u3068\u304d\u306b\u3060\u3051\u30b7\u30e3\u30c3\u30bf\u30fc\u304c\u5207\u308c\u308b\uff08\u5f80\u5fa9\u52d5\u4f5c\u306e\u6a5f\u5668\u306e\u3068\u304d\u306b\u5fa9\u8def\u3067\u30b7\u30e3\u30c3\u30bf\u30fc\u304c\u5207\u308c\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u305f\u3081\uff09\u3002\u91d1\u5177\u3092\u4ecb\u3057\u3066\u3001\u5b9f\u9a13\u88c5\u7f6e\u306b\u56fa\u5b9a\u3059\u308b\u3002\u30a2\u30eb\u30df\u306e\u30d7\u30ec\u30fc\u30c8\u306f\u7279\u88fd\u3002\u9ed2\u3044\u9244\u88fd\u306e\u91d1\u5177\u306f\u5e02\u8ca9\u54c1\u3002\u5b9f\u9a13\u88c5\u7f6e\u306e\u52d5\u4f5c\u90e8\u306b\u906e\u5149\u677f\u3092\u53d6\u308a\u4ed8\u3051\u3001\u30bb\u30f3\u30b5\u30fc\u306e\u30b9\u30ea\u30c3\u30c8\u306e\u9593\u3092\u901a\u904e\u3059\u308b\u3088\u3046\u306b\u3059\u308b\u3002\u3053\u306e\u30bb\u30f3\u30b5\u30fc\u306f\u906e\u5149\u6642\u306bON\u306e\u4fe1\u53f7\u304c\u3067\u308b\u3002<\/p>\n<figure id=\"attachment_492\" aria-describedby=\"caption-attachment-492\" style=\"width: 2048px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2015\/05\/IMG_3439.jpg\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"wp-image-492 size-full\" src=\"https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2015\/05\/IMG_3439.jpg?resize=840%2C473\" alt=\"IMG_3439\" width=\"840\" height=\"473\" srcset=\"https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2015\/05\/IMG_3439.jpg?w=1920&amp;ssl=1 1920w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2015\/05\/IMG_3439.jpg?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2015\/05\/IMG_3439.jpg?resize=768%2C432&amp;ssl=1 768w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2015\/05\/IMG_3439.jpg?resize=1024%2C576&amp;ssl=1 1024w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2015\/05\/IMG_3439.jpg?resize=1200%2C675&amp;ssl=1 1200w\" sizes=\"(max-width: 840px) 100vw, 840px\" \/><\/a><figcaption id=\"caption-attachment-492\" class=\"wp-caption-text\">\u30aa\u30e0\u30ed\u30f3\u88fd\u30d5\u30a9\u30c8\u30de\u30a4\u30af\u30ed\u30bb\u30f3\u30b5\uff08\u900f\u904e\u578b\uff09EE-SX460-P1\u3092\uff12\u3064\u4e26\u3079\u3066\u30d7\u30ec\u30fc\u30c8\u306b\u53d6\u308a\u4ed8\u3051\u308b\u3002\u30b1\u30fc\u30d6\u30eb\u306e\u8272\uff1a\u8d64 = Vcc\u3001\u6a59 = OUT\u3001\u9ec4 = GND<\/figcaption><\/figure>\n<p>Arduino\u3092\u4f7f\u3063\u3066\u3001\u30bb\u30f3\u30b5\u30fc\u304b\u3089\u306e\u4fe1\u53f7\u3092\u30b7\u30e3\u30c3\u30bf\u30fc\u306e\u5236\u5fa1\u306b\u5909\u63db\u3059\u308b\u3002<\/p>\n<ul>\n<li>\u30d7\u30c3\u30b7\u30e5\u30b9\u30a4\u30c3\u30c1\uff08\u8d64\uff09\u30fbLED\uff08\u8d64\uff09\uff1a\u5236\u5fa1\u30aa\u30f3\u30fb\u30aa\u30d5<\/li>\n<li>\u30d7\u30c3\u30b7\u30e5\u30b9\u30a4\u30c3\u30c1\uff08\u9ed2\u30fb\u4e2d\u592e\uff09\u30fbLED\uff08\u9752\uff09\uff1a\u30b7\u30e3\u30c3\u30bf\u30fc\u534a\u62bc\u3057\u72b6\u614b\u3092\u6301\u7d9a\uff08\u30ab\u30e1\u30e9\u306e\u534a\u62bc\u3057\u307e\u3067\u306e\u52d5\u4f5c\u3092\u7701\u304f\u3068\u304d\uff09<\/li>\n<li>LED\uff08\u9ec4\uff09\uff1a\u534a\u62bc\u3057\u306e\u4f4d\u7f6e\u306e\u30bb\u30f3\u30b5\u30fc\u304c\u53cd\u5fdc\u3001\u30ab\u30e1\u30e9\u3092\u534a\u62bc\u3057\u72b6\u614b\u306b<\/li>\n<li>LED\uff08\u7dd1\uff09\uff1a\u30ea\u30ea\u30fc\u30b9\u306e\u4f4d\u7f6e\u306e\u30bb\u30f3\u30b5\u30fc\u304c\u53cd\u5fdc\u3001\u30b7\u30e3\u30c3\u30bf\u30fc\u3092\u5207\u308b<\/li>\n<li>\u30d7\u30c3\u30b7\u30e5\u30b9\u30a4\u30c3\u30c1\uff08\u9ed2\u30fb\u7aef\uff09\uff1a\u30de\u30cb\u30e5\u30a2\u30eb\u30b7\u30e3\u30c3\u30bf\u30fc<\/li>\n<li>DIP\u30b9\u30a4\u30c3\u30c11\uff1a\u30bb\u30f3\u30b5\u30fc\u3068\u53cd\u5fdc\u5bfe\u8c61\u7269\u306e\u660e\u6697\u304c\u9006\u306e\u6642\u306bON\uff08\u5909\u66f4\u5f8c\u306f\u30ea\u30bb\u30c3\u30c8\u30b9\u30a4\u30c3\u30c1\u3092\u62bc\u3059\uff09<\/li>\n<li>DIP\u30b9\u30a4\u30c3\u30c12\uff1a\u30bb\u30f3\u30b5\u30fc\u3092\u9006\u65b9\u5411\u306b\u53d6\u308a\u4ed8\u3051\u305f\u3068\u304d\u306bON\uff08\u5909\u66f4\u5f8c\u306f\u30ea\u30bb\u30c3\u30c8\u30b9\u30a4\u30c3\u30c1\u3092\u62bc\u3059\uff09<\/li>\n<li>\u534a\u56fa\u5b9a\u62b5\u6297\uff1a\u30bb\u30f3\u30b5\u30fc\u306e\u611f\u5ea6\u8abf\u7bc0\uff08EE-SX460-P1\u306e\u5834\u5408\u306f\u4e2d\u592e\u306e\u4f4d\u7f6e\uff09<\/li>\n<\/ul>\n<figure id=\"attachment_558\" aria-describedby=\"caption-attachment-558\" style=\"width: 1838px\" class=\"wp-caption alignnone\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"wp-image-558 size-full\" src=\"https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/c5809adfc132084a3f2f5a14176b8c7d.png?resize=840%2C563\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2016-06-02 17.52.44\" width=\"840\" height=\"563\" srcset=\"https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/c5809adfc132084a3f2f5a14176b8c7d.png?w=1838&amp;ssl=1 1838w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/c5809adfc132084a3f2f5a14176b8c7d.png?resize=300%2C201&amp;ssl=1 300w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/c5809adfc132084a3f2f5a14176b8c7d.png?resize=768%2C515&amp;ssl=1 768w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/c5809adfc132084a3f2f5a14176b8c7d.png?resize=1024%2C686&amp;ssl=1 1024w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/c5809adfc132084a3f2f5a14176b8c7d.png?resize=1200%2C804&amp;ssl=1 1200w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/c5809adfc132084a3f2f5a14176b8c7d.png?w=1680 1680w\" sizes=\"(max-width: 840px) 100vw, 840px\" \/><figcaption id=\"caption-attachment-558\" class=\"wp-caption-text\">\u56de\u8def\u56f3<\/figcaption><\/figure>\n<figure id=\"attachment_559\" aria-describedby=\"caption-attachment-559\" style=\"width: 1280px\" class=\"wp-caption alignnone\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"wp-image-559 size-full\" src=\"https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/IMG_3695.jpeg?resize=840%2C630\" alt=\"IMG_3695\" width=\"840\" height=\"630\" srcset=\"https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/IMG_3695.jpeg?w=1280&amp;ssl=1 1280w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/IMG_3695.jpeg?resize=300%2C225&amp;ssl=1 300w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/IMG_3695.jpeg?resize=768%2C576&amp;ssl=1 768w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/IMG_3695.jpeg?resize=1024%2C768&amp;ssl=1 1024w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/IMG_3695.jpeg?resize=1200%2C900&amp;ssl=1 1200w\" sizes=\"(max-width: 840px) 100vw, 840px\" \/><figcaption id=\"caption-attachment-559\" class=\"wp-caption-text\">\u5b9f\u88c5\u4f8b<\/figcaption><\/figure>\n<p>\u30ab\u30e1\u30e9\u3068\u306e\u63a5\u7d9a\u306b\u306f\u3001\u30ab\u30e1\u30e9\u306e\u30ea\u30e2\u30b3\u30f3\u3092\u5229\u7528\u3059\u308b\u3002\u30cb\u30b3\u30f3\u306e\u5834\u5408\u306f\u3001\u7aef\u5b50\u3092\u77ed\u7d61\u3055\u305b\u308b\u3060\u3051\u306e\u30ea\u30e2\u30fc\u30c8\u30b1\u30fc\u30d6\u30eb\u304c\u3042\u308b\u306e\u3067\u3001\u305d\u308c\u3092\u5229\u7528\u3059\u308b\u3002\u305f\u3060\u3057\u30cb\u30b3\u30f3\u5074\u306b\u6975\u6027\u304c\u3042\u308b\uff08RJ-45\u306e\u7aef\u5b503\u2192\u30ea\u30e2\u30fc\u30c8\u30b1\u30fc\u30d6\u30eb\u306e\u9ec4\uff1b4+6\u2192\u9ed2\uff1b5\u2192\u9752\uff09\u3002\u30ad\u30e4\u30ce\u30f3\u3082\u7aef\u5b50\u3092\u77ed\u7d61\u3055\u305b\u308b\u3060\u3051\u3002USB\u306a\u3069\u3067\u63a5\u7d9a\u3059\u308b\u30ea\u30e2\u30b3\u30f3\u3067\u306f\u3001<a href=\"http:\/\/anatomy.med.gunma-u.ac.jp\/protocols\/?p=359\">\u30ea\u30e2\u30b3\u30f3\u306e\u30b7\u30e3\u30c3\u30bf\u30fc\u30b9\u30a4\u30c3\u30c1\u306e\u7aef\u5b50\u304b\u3089\u5c0e\u7dda\u3092\u5f15\u304d\u51fa\u305b\u3070<\/a>\u3001\u540c\u69d8\u306b\u63a5\u7d9a\u3067\u304d\u308b\u3002<\/p>\n<figure id=\"attachment_563\" aria-describedby=\"caption-attachment-563\" style=\"width: 2048px\" class=\"wp-caption alignnone\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"wp-image-563 size-full\" src=\"https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/IMG_3527-1.jpg?resize=840%2C630\" alt=\"IMG_3527\" width=\"840\" height=\"630\" srcset=\"https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/IMG_3527-1.jpg?w=1920&amp;ssl=1 1920w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/IMG_3527-1.jpg?resize=300%2C225&amp;ssl=1 300w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/IMG_3527-1.jpg?resize=768%2C576&amp;ssl=1 768w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/IMG_3527-1.jpg?resize=1024%2C768&amp;ssl=1 1024w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/IMG_3527-1.jpg?resize=1200%2C900&amp;ssl=1 1200w\" sizes=\"(max-width: 840px) 100vw, 840px\" \/><figcaption id=\"caption-attachment-563\" class=\"wp-caption-text\">\u30cb\u30b3\u30f3\u306e\u30ea\u30e2\u30fc\u30c8\u30b1\u30fc\u30d6\u30eb\u3068\u306e\u63a5\u7d9a\u4f8b<\/figcaption><\/figure>\n<figure id=\"attachment_412\" aria-describedby=\"caption-attachment-412\" style=\"width: 3264px\" class=\"wp-caption alignnone\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"wp-image-412 size-full\" src=\"https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2015\/05\/IMG_2093.jpg?resize=840%2C630\" alt=\"IMG_2093\" width=\"840\" height=\"630\" srcset=\"https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2015\/05\/IMG_2093.jpg?w=1920&amp;ssl=1 1920w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2015\/05\/IMG_2093.jpg?resize=300%2C225&amp;ssl=1 300w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2015\/05\/IMG_2093.jpg?resize=1024%2C768&amp;ssl=1 1024w\" sizes=\"(max-width: 840px) 100vw, 840px\" \/><figcaption id=\"caption-attachment-412\" class=\"wp-caption-text\">\u30bd\u30cb\u30fc\u306e\u30ea\u30e2\u30b3\u30f3\u3068\u306e\u63a5\u7d9a\u4f8b<\/figcaption><\/figure>\n<h5>\u53cd\u5c04\u30bb\u30f3\u30b5\u30fc\u306e\u4f7f\u7528\u4f8b<\/h5>\n<p>\u901a\u904e\u30bb\u30f3\u30b5\u30fc\u306e\u4ee3\u308f\u308a\u306b\u53cd\u5c04\u30bb\u30f3\u30b5\u30fc\u3092\u4f7f\u3046\u3053\u3068\u3082\u3067\u304d\u308b\u3002<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"alignnone wp-image-499 size-full\" src=\"https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/e30241f791445986894e3f3de9cdf7e9.png?resize=840%2C369\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2016-05-06 16.44.56\" width=\"840\" height=\"369\" srcset=\"https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/e30241f791445986894e3f3de9cdf7e9.png?w=1920&amp;ssl=1 1920w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/e30241f791445986894e3f3de9cdf7e9.png?resize=300%2C132&amp;ssl=1 300w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/e30241f791445986894e3f3de9cdf7e9.png?resize=768%2C337&amp;ssl=1 768w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/e30241f791445986894e3f3de9cdf7e9.png?resize=1024%2C449&amp;ssl=1 1024w, https:\/\/i0.wp.com\/anatomy.med.gunma-u.ac.jp\/protocols\/wp-content\/uploads\/2016\/04\/e30241f791445986894e3f3de9cdf7e9.png?resize=1200%2C527&amp;ssl=1 1200w\" sizes=\"(max-width: 840px) 100vw, 840px\" \/><\/p>\n<h5>\u30b9\u30b1\u30c3\u30c1<\/h5>\n<pre>\/*\n Photosensor_shutter\n\n This sketch is written to control the camera shutter by photosensors.\n\n This work is licensed under a Creative Commons Attribution 4.0 International License.\n &lt;http:\/\/creativecommons.org\/licenses\/by\/4.0\/&gt;\n\n (c) 2016, Tohru Murakami, Gunma University.\n*\/\n\n\/\/ Hardware constants. Adjust these values per installations.\n\nconst int latentcy = 100; \/\/ msec\nconst float baselineVoltage = 2.5; \/\/ threshold voltage of the photosensor; 0 \u2013 5.0\n\n\/\/ Pin assignments\n\n\/\/ DIPSW Switch inputs\n\nconst int DIPSW_sensorTypeMismatch = 12;\nconst int DIPSW_sensorDirection = 13;\n\n\/\/ Switch inputs\nconst int SWPin_autoControl = 3; \/\/ the auto-control switch\nconst int SWPin_contHalfPush = 4; \/\/ the continuous-half-push switch\nconst int SWPin_manualRelease = 5; \/\/ the manual-shutter-release switch\n\n\/\/ Switch indicator outputs\nconst int ledPin_autoControl = 7; \/\/ the auto-control indicator\nconst int ledPin_contHalfPush = 6; \/\/ the continuous-half-push indicator\n\n\/\/ Shutter indicator outputs\nconst int ledPin_halfPush = 8; \/\/ the half-push indicator\nconst int ledPin_release = 9; \/\/ the shutter-release indicator\n\n\/\/ Shutter outputs\nconst int optoPin_halfPush = 11; \/\/ the half-push optocoupler\nconst int optoPin_release = 10; \/\/ the shutter-release optocoupler\n\n\/\/ Sensor inputs (for default installation)\nint sensorPin_halfPush = A1; \/\/ the half-push photosensor\nint sensorPin_release = A0; \/\/ the shutter-release photosensor\n\n\/\/ Serial communication rate\n\nconst int serialSpeed = 9600;\n\n\/\/ Shutter status aliases\n\nconst int interval = 0;\nconst int standby = 1;\n\n\/\/ DIPSW switch values (0 for default installation)\n\nint sensorTypeMismatch = 0;\nint sensorDirection = 0;\n\n\/\/ Variables\n\nint releaseCounter = 0; \/\/ count shutter release\nint shutterStatus = interval;\nint autoControl = 0;\nint contHalfPush = 0;\nint manualRelease = 0;\nint sensorVal_halfPush; \/\/ 10 bit unsigned integer\nint sensorVal_release; \/\/ 10 bit unsigned integer\nfloat voltage_halfPush; \/\/ 0.0\u20135.0\nfloat voltage_release; \/\/ 0.0\u20135.0\n\nvoid setup() {\n\n int temp;\n\n \/\/ Assign output pins\n pinMode(optoPin_halfPush, OUTPUT);\n pinMode(optoPin_release, OUTPUT);\n pinMode(ledPin_autoControl, OUTPUT);\n pinMode(ledPin_contHalfPush, OUTPUT);\n pinMode(ledPin_halfPush, OUTPUT);\n pinMode(ledPin_release, OUTPUT);\n\n \/\/ Assign switche pins\n pinMode(DIPSW_sensorTypeMismatch, INPUT);\n \/\/ HIGH = light-ON sensor for dark signal or dark-ON for light signal; LOW = matched\n pinMode(DIPSW_sensorDirection, INPUT); \/\/HIGH reverse; LOW default\n pinMode(SWPin_autoControl, INPUT); \/\/HIGH automatic; LOW no shutter control\n pinMode(SWPin_contHalfPush, INPUT); \/\/HIGH continuous half push; LOW sensor-controled half push\n pinMode(SWPin_manualRelease, INPUT); \/\/HIGH shutter release\n\n \/\/ initialize output pins\n digitalWrite(ledPin_autoControl, LOW);\n digitalWrite(ledPin_contHalfPush, LOW);\n digitalWrite(optoPin_halfPush, LOW);\n digitalWrite(ledPin_halfPush, LOW);\n digitalWrite(optoPin_release, LOW);\n digitalWrite(ledPin_release, LOW);\n\n \/\/ read the DIP switches\n sensorTypeMismatch = digitalRead(DIPSW_sensorTypeMismatch); \/\/ LOW = default, HIGH = mismatch\n sensorDirection = digitalRead(DIPSW_sensorDirection); \/\/ LOW = default, HIGH = reverse\n\n \/\/ adjust the sensor direction\n if (sensorDirection == HIGH) {\n temp = sensorPin_halfPush; \/\/ Swap the sensor pin assignments\n sensorPin_halfPush = sensorPin_release;\n sensorPin_release = temp;\n }\n\n \/\/ initialize serial communication\n Serial.begin(serialSpeed);\n\n \/\/ print message when done.\n Serial.println(\"Photosensor-driven shutter controler ready!\");\n}\n\nvoid loop() {\n\n \/\/ read the switches\n\n manualRelease = digitalRead(SWPin_manualRelease);\n autoControl = digitalRead(SWPin_autoControl);\n contHalfPush = digitalRead(SWPin_contHalfPush);\n\n if (manualRelease == HIGH) { \/\/ releaes the shutter when the manual shutter release switch is pressed.\n\n Serial.print(\"Manual \");\n release();\n\n } else if (autoControl == HIGH) {\n\n digitalWrite(ledPin_autoControl, HIGH);\n\n if (contHalfPush == HIGH) { \/\/ leave the half-push HIGH when the continuous-half-push switch is ON\n\n digitalWrite(ledPin_contHalfPush, HIGH);\n digitalWrite(optoPin_halfPush, HIGH);\n\n } else if (shutterStatus == interval) {\n\n digitalWrite(ledPin_contHalfPush, LOW);\n digitalWrite(optoPin_halfPush, LOW);\n\n };\n\n \/\/ read the sensor values and convert them to voltage levels\n\n sensorVal_halfPush = analogRead(sensorPin_halfPush);\n sensorVal_release = analogRead(sensorPin_release);\n\n voltage_halfPush = (sensorVal_halfPush \/ 1024.0) * 5.0;\n voltage_release = (sensorVal_release \/ 1024.0) * 5.0;\n\n \/\/ print the voltage levels on the serial port\n\n \/\/ Serial.print(\"half push sensor: \");\n \/\/ Serial.print(voltage_halfPush);\n \/\/ Serial.print(\", release sensor: \");\n \/\/ Serial.println(voltage_release);\n\n if (sensorTypeMismatch == HIGH) { \/\/ invert the sensor voltages when sensorTypeMismatch is bright ON\n\n voltage_halfPush = 5.0 - voltage_halfPush;\n voltage_release = 5.0 - voltage_release;\n\n };\n\n\n if (voltage_halfPush &gt; baselineVoltage &amp;&amp; voltage_release &lt;= baselineVoltage &amp;&amp; shutterStatus == interval) {\n \/\/ turn half-push HIGH when the half-push sensor detects something.\n\n digitalWrite(optoPin_halfPush, HIGH);\n digitalWrite(ledPin_halfPush, HIGH);\n\n shutterStatus = standby;\n\n };\n\n if (voltage_release &gt; baselineVoltage &amp;&amp; shutterStatus == standby) {\n \/\/ release the shutter when the release sensor detects something.\n\n release();\n\n shutterStatus = interval;\n\n };\n\n } else { \/\/ make everything zero when autoControl SW is off.\n\n Serial.println(\"OFF\");\n digitalWrite(ledPin_autoControl, LOW);\n digitalWrite(ledPin_contHalfPush, LOW);\n digitalWrite(optoPin_halfPush, LOW);\n digitalWrite(ledPin_halfPush, LOW);\n digitalWrite(optoPin_release, LOW);\n digitalWrite(ledPin_release, LOW);\n\n shutterStatus = interval;\n\n };\n}\n\nvoid release() {\n\n digitalWrite(optoPin_halfPush, HIGH);\n digitalWrite(ledPin_halfPush, HIGH);\n\n delay(latentcy); \/\/ give the optocoupler a moment to activate\n\n digitalWrite(optoPin_release, HIGH);\n digitalWrite(ledPin_release, HIGH);\n\n delay(latentcy); \/\/ give the optocoupler a moment to activate\n\n digitalWrite(optoPin_release, LOW);\n digitalWrite(ledPin_release, LOW);\n digitalWrite(ledPin_halfPush, LOW);\n\n if (contHalfPush != HIGH) {\n\n digitalWrite(optoPin_halfPush, LOW);\n\n };\n\n Serial.print(\"# \");\n Serial.println(releaseCounter++);\n\n}\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b9f\u9a13\u88c5\u7f6e\u306e\u52d5\u4f5c\u306b\u5408\u308f\u305b\u3066\u30c7\u30b8\u30bf\u30eb\u30ab\u30e1\u30e9\u3067\u81ea\u52d5\u7684\u306b\u64ae\u5f71\u3055\u305b\u308b\u305f\u3081\u3001\u901a\u904e\u30bb\u30f3\u30b5\u30fc\u3068Arduino\u3067\u30ab\u30e1\u30e9\u3068\u88c5\u7f6e\u3068\u3092\u540c\u671f\u3055\u305b\u305f\u3002<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[25,5],"tags":[21,24,22,23],"class_list":["post-406","post","type-post","status-publish","format-standard","hentry","category-diy","category-microscopy","tag-arduino","tag-automatic","tag-photosensor","tag-remote"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4fFyn-6y","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/anatomy.med.gunma-u.ac.jp\/protocols\/index.php?rest_route=\/wp\/v2\/posts\/406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/anatomy.med.gunma-u.ac.jp\/protocols\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anatomy.med.gunma-u.ac.jp\/protocols\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anatomy.med.gunma-u.ac.jp\/protocols\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/anatomy.med.gunma-u.ac.jp\/protocols\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=406"}],"version-history":[{"count":34,"href":"https:\/\/anatomy.med.gunma-u.ac.jp\/protocols\/index.php?rest_route=\/wp\/v2\/posts\/406\/revisions"}],"predecessor-version":[{"id":566,"href":"https:\/\/anatomy.med.gunma-u.ac.jp\/protocols\/index.php?rest_route=\/wp\/v2\/posts\/406\/revisions\/566"}],"wp:attachment":[{"href":"https:\/\/anatomy.med.gunma-u.ac.jp\/protocols\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anatomy.med.gunma-u.ac.jp\/protocols\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anatomy.med.gunma-u.ac.jp\/protocols\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}