{"id":10249,"date":"2014-07-07T14:43:55","date_gmt":"2014-07-07T14:43:55","guid":{"rendered":"http:\/\/178.62.14.192\/?p=10249"},"modified":"2014-07-07T14:43:55","modified_gmt":"2014-07-07T14:43:55","slug":"access-pwm-on-the-raspberrypi-using-c","status":"publish","type":"post","link":"https:\/\/www.recantha.co.uk\/blog\/?p=10249","title":{"rendered":"Access PWM on the #RaspberryPi using C++"},"content":{"rendered":"<p>Hussam Al-Hertani has blogged a C++ class he&#8217;s written to access pin 18 on the Raspberry Pi. This is the only hardware PWM pin on the Pi.\u00a0<a href=\"http:\/\/hertaville.com\/2014\/07\/07\/rpipwm\/\" target=\"_blank\">Read about it here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hussam Al-Hertani has blogged a C++ class he&#8217;s written to access pin 18 on the Raspberry Pi. This is the only hardware PWM pin on the Pi.\u00a0Read about it here.<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"https:\/\/www.recantha.co.uk\/blog\/?p=10249\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":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}},"categories":[39,51],"tags":[],"class_list":["post-10249","post","type-post","status-publish","format-standard","hentry","category-programming","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Access PWM on the #RaspberryPi using C++ - Raspberry Pi Pod<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.recantha.co.uk\/blog\/?p=10249\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Access PWM on the #RaspberryPi using C++ - Raspberry Pi Pod\" \/>\n<meta property=\"og:description\" content=\"Hussam Al-Hertani has blogged a C++ class he&#8217;s written to access pin 18 on the Raspberry Pi. This is the only hardware PWM pin on the Pi.\u00a0Read about it here.Read more &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.recantha.co.uk\/blog\/?p=10249\" \/>\n<meta property=\"og:site_name\" content=\"Raspberry Pi Pod\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/recantha\/\" \/>\n<meta property=\"article:published_time\" content=\"2014-07-07T14:43:55+00:00\" \/>\n<meta name=\"author\" content=\"Michael Horne\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@recantha\" \/>\n<meta name=\"twitter:site\" content=\"@recantha\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Michael Horne\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.recantha.co.uk\/blog\/?p=10249#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.recantha.co.uk\/blog\/?p=10249\"},\"author\":{\"name\":\"Michael Horne\",\"@id\":\"https:\/\/www.recantha.co.uk\/blog\/#\/schema\/person\/c27c4ef2ee1c18b130f1fcd5dcdbb263\"},\"headline\":\"Access PWM on the #RaspberryPi using C++\",\"datePublished\":\"2014-07-07T14:43:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.recantha.co.uk\/blog\/?p=10249\"},\"wordCount\":38,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/www.recantha.co.uk\/blog\/#organization\"},\"articleSection\":[\"Programming\",\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.recantha.co.uk\/blog\/?p=10249#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.recantha.co.uk\/blog\/?p=10249\",\"url\":\"https:\/\/www.recantha.co.uk\/blog\/?p=10249\",\"name\":\"Access PWM on the #RaspberryPi using C++ - Raspberry Pi Pod\",\"isPartOf\":{\"@id\":\"https:\/\/www.recantha.co.uk\/blog\/#website\"},\"datePublished\":\"2014-07-07T14:43:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.recantha.co.uk\/blog\/?p=10249#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.recantha.co.uk\/blog\/?p=10249\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.recantha.co.uk\/blog\/?p=10249#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.recantha.co.uk\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Access PWM on the #RaspberryPi using C++\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.recantha.co.uk\/blog\/#website\",\"url\":\"https:\/\/www.recantha.co.uk\/blog\/\",\"name\":\"Raspberry Pi Pod\",\"description\":\"Experiences with the Raspberry Pi micro computer and microcontroller\",\"publisher\":{\"@id\":\"https:\/\/www.recantha.co.uk\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.recantha.co.uk\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.recantha.co.uk\/blog\/#organization\",\"name\":\"Raspberry Pi Pod\",\"url\":\"https:\/\/www.recantha.co.uk\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.recantha.co.uk\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/i0.wp.com\/www.recantha.co.uk\/blog\/wp-content\/uploads\/2016\/03\/cropped-PiPod-Logo-v3.png?fit=800%2C337&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/www.recantha.co.uk\/blog\/wp-content\/uploads\/2016\/03\/cropped-PiPod-Logo-v3.png?fit=800%2C337&ssl=1\",\"width\":800,\"height\":337,\"caption\":\"Raspberry Pi Pod\"},\"image\":{\"@id\":\"https:\/\/www.recantha.co.uk\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/recantha\/\",\"https:\/\/x.com\/recantha\",\"https:\/\/www.linkedin.com\/in\/recantha\/\",\"https:\/\/www.youtube.com\/channel\/UCK4F9blabxzmk8Inzhs8tpg\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.recantha.co.uk\/blog\/#\/schema\/person\/c27c4ef2ee1c18b130f1fcd5dcdbb263\",\"name\":\"Michael Horne\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.recantha.co.uk\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/479778b0677caadde0ceb54c4129804ef674914607e3ed0998808148357d10d8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/479778b0677caadde0ceb54c4129804ef674914607e3ed0998808148357d10d8?s=96&d=mm&r=g\",\"caption\":\"Michael Horne\"},\"url\":\"https:\/\/www.recantha.co.uk\/blog\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Access PWM on the #RaspberryPi using C++ - Raspberry Pi Pod","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:\/\/www.recantha.co.uk\/blog\/?p=10249","og_locale":"en_US","og_type":"article","og_title":"Access PWM on the #RaspberryPi using C++ - Raspberry Pi Pod","og_description":"Hussam Al-Hertani has blogged a C++ class he&#8217;s written to access pin 18 on the Raspberry Pi. This is the only hardware PWM pin on the Pi.\u00a0Read about it here.Read more &rarr;","og_url":"https:\/\/www.recantha.co.uk\/blog\/?p=10249","og_site_name":"Raspberry Pi Pod","article_publisher":"https:\/\/www.facebook.com\/recantha\/","article_published_time":"2014-07-07T14:43:55+00:00","author":"Michael Horne","twitter_card":"summary_large_image","twitter_creator":"@recantha","twitter_site":"@recantha","twitter_misc":{"Written by":"Michael Horne"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.recantha.co.uk\/blog\/?p=10249#article","isPartOf":{"@id":"https:\/\/www.recantha.co.uk\/blog\/?p=10249"},"author":{"name":"Michael Horne","@id":"https:\/\/www.recantha.co.uk\/blog\/#\/schema\/person\/c27c4ef2ee1c18b130f1fcd5dcdbb263"},"headline":"Access PWM on the #RaspberryPi using C++","datePublished":"2014-07-07T14:43:55+00:00","mainEntityOfPage":{"@id":"https:\/\/www.recantha.co.uk\/blog\/?p=10249"},"wordCount":38,"commentCount":1,"publisher":{"@id":"https:\/\/www.recantha.co.uk\/blog\/#organization"},"articleSection":["Programming","Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.recantha.co.uk\/blog\/?p=10249#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.recantha.co.uk\/blog\/?p=10249","url":"https:\/\/www.recantha.co.uk\/blog\/?p=10249","name":"Access PWM on the #RaspberryPi using C++ - Raspberry Pi Pod","isPartOf":{"@id":"https:\/\/www.recantha.co.uk\/blog\/#website"},"datePublished":"2014-07-07T14:43:55+00:00","breadcrumb":{"@id":"https:\/\/www.recantha.co.uk\/blog\/?p=10249#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.recantha.co.uk\/blog\/?p=10249"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.recantha.co.uk\/blog\/?p=10249#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.recantha.co.uk\/blog"},{"@type":"ListItem","position":2,"name":"Access PWM on the #RaspberryPi using C++"}]},{"@type":"WebSite","@id":"https:\/\/www.recantha.co.uk\/blog\/#website","url":"https:\/\/www.recantha.co.uk\/blog\/","name":"Raspberry Pi Pod","description":"Experiences with the Raspberry Pi micro computer and microcontroller","publisher":{"@id":"https:\/\/www.recantha.co.uk\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.recantha.co.uk\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.recantha.co.uk\/blog\/#organization","name":"Raspberry Pi Pod","url":"https:\/\/www.recantha.co.uk\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.recantha.co.uk\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/i0.wp.com\/www.recantha.co.uk\/blog\/wp-content\/uploads\/2016\/03\/cropped-PiPod-Logo-v3.png?fit=800%2C337&ssl=1","contentUrl":"https:\/\/i0.wp.com\/www.recantha.co.uk\/blog\/wp-content\/uploads\/2016\/03\/cropped-PiPod-Logo-v3.png?fit=800%2C337&ssl=1","width":800,"height":337,"caption":"Raspberry Pi Pod"},"image":{"@id":"https:\/\/www.recantha.co.uk\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/recantha\/","https:\/\/x.com\/recantha","https:\/\/www.linkedin.com\/in\/recantha\/","https:\/\/www.youtube.com\/channel\/UCK4F9blabxzmk8Inzhs8tpg"]},{"@type":"Person","@id":"https:\/\/www.recantha.co.uk\/blog\/#\/schema\/person\/c27c4ef2ee1c18b130f1fcd5dcdbb263","name":"Michael Horne","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.recantha.co.uk\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/479778b0677caadde0ceb54c4129804ef674914607e3ed0998808148357d10d8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/479778b0677caadde0ceb54c4129804ef674914607e3ed0998808148357d10d8?s=96&d=mm&r=g","caption":"Michael Horne"},"url":"https:\/\/www.recantha.co.uk\/blog\/?author=1"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2RsaV-2Fj","jetpack-related-posts":[{"id":6064,"url":"https:\/\/www.recantha.co.uk\/blog\/?p=6064","url_meta":{"origin":10249,"position":0},"title":"Software PWM on a #RaspberryPi","author":"Michael Horne","date":"23 September 2013","format":false,"excerpt":"Mark Williams has been looking at how to generate signals to create PWM-like effects on the Pi. This lets him control the brightness of LEDs without using the PWM pin, albeit in a simulated kind of way. I'll let him explain it on his blog. His sample code is in\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/www.recantha.co.uk\/blog\/?cat=39"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3248,"url":"https:\/\/www.recantha.co.uk\/blog\/?p=3248","url_meta":{"origin":10249,"position":1},"title":"Controlling servo motors on the #RaspberryPi","author":"Michael Horne","date":"28 March 2013","format":false,"excerpt":"As part of my \"SpacePi\" Raspberry Pi astronomy project, I want to be able to control the orientation of the camera module remotely. I want to be able to sit away from the camera rig and control where it is pointing using a web interface and (optionally, and because I\u2026","rel":"","context":"In &quot;Camera module&quot;","block_context":{"text":"Camera module","link":"https:\/\/www.recantha.co.uk\/blog\/?cat=8"},"img":{"alt_text":"Better PWM on the Raspberry Pi","src":"\/blog\/wp-content\/uploads\/2013\/03\/PanTilt-1L1.jpg","width":350,"height":200},"classes":[]},{"id":3546,"url":"https:\/\/www.recantha.co.uk\/blog\/?p=3546","url_meta":{"origin":10249,"position":2},"title":"Using a vintage voltmeter with the #RaspberryPi","author":"Michael Horne","date":"12 April 2013","format":false,"excerpt":"Tom Lee at the Sunlight Foundation has been tinkering with an old voltmeter and getting it to work with the Raspberry Pi, using the PWM pin as the driver. Read more at their blog","rel":"","context":"In &quot;Geeky Techiness&quot;","block_context":{"text":"Geeky Techiness","link":"https:\/\/www.recantha.co.uk\/blog\/?cat=22"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":12449,"url":"https:\/\/www.recantha.co.uk\/blog\/?p=12449","url_meta":{"origin":10249,"position":3},"title":"Driving NeoPixels from Docker on the Raspberry Pi","author":"Michael Horne","date":"26 April 2015","format":false,"excerpt":"The guys over at Hypriot have been using Docker a lot. In this instance, they use Node.JS to drive a set of NeoPixels from the Pi. In the example, they use the Pi's 5V power supply to provide the power directly (although this is not recommended) and an Adafruit level\u2026","rel":"","context":"In &quot;Accessories&quot;","block_context":{"text":"Accessories","link":"https:\/\/www.recantha.co.uk\/blog\/?cat=54"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.hypriot.com\/images\/neopixel\/neopixel640.gif?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.hypriot.com\/images\/neopixel\/neopixel640.gif?resize=350%2C200 1x, https:\/\/i0.wp.com\/blog.hypriot.com\/images\/neopixel\/neopixel640.gif?resize=525%2C300 1.5x"},"classes":[]},{"id":10933,"url":"https:\/\/www.recantha.co.uk\/blog\/?p=10933","url_meta":{"origin":10249,"position":4},"title":"Running Neopixels from the Raspberry Pi without an Arduino","author":"Michael Horne","date":"5 September 2014","format":false,"excerpt":"https:\/\/www.youtube.com\/watch?v=DXXu4sjGUWw Here's what could be a game-changer in the land of blinkies.\u00a0Tony from North-West USA has taken the work of an Adafruit forum user, adapted it slightly and is now driving Neopixels natively from the Pi. It uses the Raspberry Pi's PWM pin (number 18) and a non-inverted hex buffer\u2026","rel":"","context":"In &quot;Making&quot;","block_context":{"text":"Making","link":"https:\/\/www.recantha.co.uk\/blog\/?cat=50"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/img.youtube.com\/vi\/DXXu4sjGUWw\/0.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1951,"url":"https:\/\/www.recantha.co.uk\/blog\/?p=1951","url_meta":{"origin":10249,"position":5},"title":"A Guide to the #Arduino by guru Ben Heck with notes from me!","author":"Michael Horne","date":"7 February 2013","format":false,"excerpt":"In this video, electronics guru Ben Heck\u00a0examines and explains the Arduino including Outputs, Inputs, PWM and Analog Input. You can view the video below, but I suggest reading the next bit for some background and hints. I recommend watching from the 1 minute mark as the beginning is an intro\u2026","rel":"","context":"In &quot;Arduino&quot;","block_context":{"text":"Arduino","link":"https:\/\/www.recantha.co.uk\/blog\/?cat=55"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.recantha.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.recantha.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.recantha.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.recantha.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.recantha.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10249"}],"version-history":[{"count":0,"href":"https:\/\/www.recantha.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10249\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.recantha.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.recantha.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.recantha.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}