{"id":2301,"date":"2021-09-27T13:55:06","date_gmt":"2021-09-27T13:55:06","guid":{"rendered":"https:\/\/mc.scsiraidguru.com\/?page_id=2301"},"modified":"2024-03-03T23:44:13","modified_gmt":"2024-03-03T23:44:13","slug":"pi-pwm","status":"publish","type":"page","link":"https:\/\/mc.scsiraidguru.com\/index.php\/raspberry-pi\/pi-pwm\/","title":{"rendered":"pi_pwm"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"2301\" class=\"elementor elementor-2301\" data-elementor-post-type=\"page\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-a559571 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"a559571\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-02ce610\" data-id=\"02ce610\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-ea6aab1 elementor-widget elementor-widget-text-editor\" data-id=\"ea6aab1\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>The Raspberry Pi does not have analog ports. So you use Pulse Width Modulation.\u00a0<\/p><p>You want a 1.6V signal on a Raspberry Pi 3.3V GPIO.\u00a0\u00a0 It would be approximately, 50% duty cycle or 3.3V * 50% = 1.65V.\u00a0\u00a0 You can setup an instance like<\/p><p>\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-8f95239 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"8f95239\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-d5bd128\" data-id=\"d5bd128\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-515337b elementor-widget elementor-widget-text-editor\" data-id=\"515337b\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<pre>GPIO.setmode(GPIO.BOARD)\nGPIO.setup(11, GPIO.OUT)\npi_pwm = GPIO.PWM(11,100)   # 100 Hz = 10 ms\npi_pwm.start(50)    # duty cycle of 50%\n\npi_pwm.ChangeDutyCycle(100) # duty cycle changed to 100%\npi.pwm.ChangeFrequency(1000) # change frequency to 1000 Hz or 1 ms\n\npi.pwm.stop() # to stop it\nGPIO.cleanup() # to remove the code from the pi or cleanup.<\/pre>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-27cb534 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"27cb534\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-1c32408\" data-id=\"1c32408\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-bb84190 elementor-widget elementor-widget-text-editor\" data-id=\"bb84190\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><em class=\"property\">class<\/em><code class=\"descclassname\">gpiozero.<\/code><code class=\"descname\">PWMLED<\/code><span class=\"sig-paren\">(<\/span><em>pin<\/em>,\u00a0<em>*<\/em>,\u00a0<em>active_high=True<\/em>,\u00a0<em>initial_value=0<\/em>,\u00a0<em>frequency=100<\/em>,\u00a0<em>pin_factory=None<\/em><span class=\"sig-paren\">)<\/span><a class=\"reference internal\" href=\"https:\/\/gpiozero.readthedocs.io\/en\/stable\/_modules\/gpiozero\/output_devices.html#PWMLED\"><span class=\"viewcode-link\">[source]<\/span><\/a><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-ad53576 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"ad53576\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-c5d9ad0\" data-id=\"c5d9ad0\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-c898128 elementor-widget elementor-widget-text-editor\" data-id=\"c898128\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<pre>from gpiozero import PWMLED\nfrom time import sleep\n\nled = PWMLED(24)\n\nwhile True:\n    led.value = 0 # off sleep(1)\n    led.value = 0.5 # half brightness\n    sleep(1)\n    led.value = 1 # full brightness\n    sleep(1)<\/pre>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>The Raspberry Pi does not have analog ports. So you use Pulse Width Modulation.\u00a0 You want a 1.6V signal on a Raspberry Pi 3.3V GPIO.\u00a0\u00a0 It would be approximately, 50% duty cycle or 3.3V * 50% = 1.65V.\u00a0\u00a0 You can setup an instance like \u00a0 GPIO.setmode(GPIO.BOARD) GPIO.setup(11, GPIO.OUT) pi_pwm = GPIO.PWM(11,100) # 100 Hz = [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":85,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"0","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"custom","ocean_center_header_left_menu":"0","ocean_custom_header_template":"7151","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","osh_disable_topbar_sticky":"default","osh_disable_header_sticky":"default","osh_sticky_header_style":"default","osh_sticky_header_effect":"","osh_custom_sticky_logo":0,"osh_custom_retina_sticky_logo":0,"osh_custom_sticky_logo_height":0,"osh_background_color":"","osh_links_color":"","osh_links_hover_color":"","osh_links_active_color":"","osh_links_bg_color":"","osh_links_hover_bg_color":"","osh_links_active_bg_color":"","osh_menu_social_links_color":"","osh_menu_social_hover_links_color":"","footnotes":""},"class_list":["post-2301","page","type-page","status-publish","hentry","entry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>pi_pwm -<\/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:\/\/mc.scsiraidguru.com\/index.php\/raspberry-pi\/pi-pwm\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"pi_pwm -\" \/>\n<meta property=\"og:description\" content=\"The Raspberry Pi does not have analog ports. So you use Pulse Width Modulation.\u00a0 You want a 1.6V signal on a Raspberry Pi 3.3V GPIO.\u00a0\u00a0 It would be approximately, 50% duty cycle or 3.3V * 50% = 1.65V.\u00a0\u00a0 You can setup an instance like \u00a0 GPIO.setmode(GPIO.BOARD) GPIO.setup(11, GPIO.OUT) pi_pwm = GPIO.PWM(11,100) # 100 Hz = [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mc.scsiraidguru.com\/index.php\/raspberry-pi\/pi-pwm\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-03T23:44:13+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/mc.scsiraidguru.com\\\/index.php\\\/raspberry-pi\\\/pi-pwm\\\/\",\"url\":\"https:\\\/\\\/mc.scsiraidguru.com\\\/index.php\\\/raspberry-pi\\\/pi-pwm\\\/\",\"name\":\"pi_pwm -\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/mc.scsiraidguru.com\\\/#website\"},\"datePublished\":\"2021-09-27T13:55:06+00:00\",\"dateModified\":\"2024-03-03T23:44:13+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/mc.scsiraidguru.com\\\/index.php\\\/raspberry-pi\\\/pi-pwm\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/mc.scsiraidguru.com\\\/index.php\\\/raspberry-pi\\\/pi-pwm\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/mc.scsiraidguru.com\\\/index.php\\\/raspberry-pi\\\/pi-pwm\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/mc.scsiraidguru.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Raspberry Pi\",\"item\":\"https:\\\/\\\/mc.scsiraidguru.com\\\/index.php\\\/raspberry-pi\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"pi_pwm\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/mc.scsiraidguru.com\\\/#website\",\"url\":\"https:\\\/\\\/mc.scsiraidguru.com\\\/\",\"name\":\"SCSIraidGURU MC World\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/mc.scsiraidguru.com\\\/#\\\/schema\\\/person\\\/f21e3238456a7c2adea5944cb376cddc\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/mc.scsiraidguru.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/mc.scsiraidguru.com\\\/#\\\/schema\\\/person\\\/f21e3238456a7c2adea5944cb376cddc\",\"name\":\"Michael McKenney\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\/\\/mc.scsiraidguru.com\\/wp-content\\/uploads\\/2021\\/09\\/20210925_105558.jpg\",\"url\":\"https:\\/\\/mc.scsiraidguru.com\\/wp-content\\/uploads\\/2021\\/09\\/20210925_105558.jpg\",\"contentUrl\":\"https:\\/\\/mc.scsiraidguru.com\\/wp-content\\/uploads\\/2021\\/09\\/20210925_105558.jpg\",\"width\":2560,\"height\":1440,\"caption\":\"Michael McKenney\"},\"logo\":{\"@id\":\"https:\\/\\/mc.scsiraidguru.com\\/wp-content\\/uploads\\/2021\\/09\\/20210925_105558.jpg\"},\"sameAs\":[\"http:\\\/\\\/mc.scsiraidguru.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"pi_pwm -","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:\/\/mc.scsiraidguru.com\/index.php\/raspberry-pi\/pi-pwm\/","og_locale":"en_US","og_type":"article","og_title":"pi_pwm -","og_description":"The Raspberry Pi does not have analog ports. So you use Pulse Width Modulation.\u00a0 You want a 1.6V signal on a Raspberry Pi 3.3V GPIO.\u00a0\u00a0 It would be approximately, 50% duty cycle or 3.3V * 50% = 1.65V.\u00a0\u00a0 You can setup an instance like \u00a0 GPIO.setmode(GPIO.BOARD) GPIO.setup(11, GPIO.OUT) pi_pwm = GPIO.PWM(11,100) # 100 Hz = [&hellip;]","og_url":"https:\/\/mc.scsiraidguru.com\/index.php\/raspberry-pi\/pi-pwm\/","article_modified_time":"2024-03-03T23:44:13+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/mc.scsiraidguru.com\/index.php\/raspberry-pi\/pi-pwm\/","url":"https:\/\/mc.scsiraidguru.com\/index.php\/raspberry-pi\/pi-pwm\/","name":"pi_pwm -","isPartOf":{"@id":"https:\/\/mc.scsiraidguru.com\/#website"},"datePublished":"2021-09-27T13:55:06+00:00","dateModified":"2024-03-03T23:44:13+00:00","breadcrumb":{"@id":"https:\/\/mc.scsiraidguru.com\/index.php\/raspberry-pi\/pi-pwm\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mc.scsiraidguru.com\/index.php\/raspberry-pi\/pi-pwm\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/mc.scsiraidguru.com\/index.php\/raspberry-pi\/pi-pwm\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mc.scsiraidguru.com\/"},{"@type":"ListItem","position":2,"name":"Raspberry Pi","item":"https:\/\/mc.scsiraidguru.com\/index.php\/raspberry-pi\/"},{"@type":"ListItem","position":3,"name":"pi_pwm"}]},{"@type":"WebSite","@id":"https:\/\/mc.scsiraidguru.com\/#website","url":"https:\/\/mc.scsiraidguru.com\/","name":"SCSIraidGURU MC World","description":"","publisher":{"@id":"https:\/\/mc.scsiraidguru.com\/#\/schema\/person\/f21e3238456a7c2adea5944cb376cddc"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mc.scsiraidguru.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/mc.scsiraidguru.com\/#\/schema\/person\/f21e3238456a7c2adea5944cb376cddc","name":"Michael McKenney","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mlbxg5wzacc0.i.optimole.com\/cb:FyJ0.12d22\/w:auto\/h:auto\/q:mauto\/f:best\/https:\/\/mc.scsiraidguru.com\/wp-content\/uploads\/2021\/09\/20210925_105558.jpg","url":"https:\/\/mlbxg5wzacc0.i.optimole.com\/cb:FyJ0.12d22\/w:auto\/h:auto\/q:mauto\/f:best\/https:\/\/mc.scsiraidguru.com\/wp-content\/uploads\/2021\/09\/20210925_105558.jpg","contentUrl":"https:\/\/mlbxg5wzacc0.i.optimole.com\/cb:FyJ0.12d22\/w:auto\/h:auto\/q:mauto\/f:best\/https:\/\/mc.scsiraidguru.com\/wp-content\/uploads\/2021\/09\/20210925_105558.jpg","width":2560,"height":1440,"caption":"Michael McKenney"},"logo":{"@id":"https:\/\/mlbxg5wzacc0.i.optimole.com\/cb:FyJ0.12d22\/w:auto\/h:auto\/q:mauto\/f:best\/https:\/\/mc.scsiraidguru.com\/wp-content\/uploads\/2021\/09\/20210925_105558.jpg"},"sameAs":["http:\/\/mc.scsiraidguru.com"]}]}},"_links":{"self":[{"href":"https:\/\/mc.scsiraidguru.com\/index.php\/wp-json\/wp\/v2\/pages\/2301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mc.scsiraidguru.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mc.scsiraidguru.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mc.scsiraidguru.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mc.scsiraidguru.com\/index.php\/wp-json\/wp\/v2\/comments?post=2301"}],"version-history":[{"count":66,"href":"https:\/\/mc.scsiraidguru.com\/index.php\/wp-json\/wp\/v2\/pages\/2301\/revisions"}],"predecessor-version":[{"id":7686,"href":"https:\/\/mc.scsiraidguru.com\/index.php\/wp-json\/wp\/v2\/pages\/2301\/revisions\/7686"}],"up":[{"embeddable":true,"href":"https:\/\/mc.scsiraidguru.com\/index.php\/wp-json\/wp\/v2\/pages\/85"}],"wp:attachment":[{"href":"https:\/\/mc.scsiraidguru.com\/index.php\/wp-json\/wp\/v2\/media?parent=2301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}