{"id":137,"date":"2024-09-23T14:31:58","date_gmt":"2024-09-23T14:31:58","guid":{"rendered":"https:\/\/theroyalscode.com\/students\/a_mermur\/?p=137"},"modified":"2024-09-23T14:31:58","modified_gmt":"2024-09-23T14:31:58","slug":"rgb-strip","status":"publish","type":"post","link":"https:\/\/theroyalscode.com\/students\/a_mermur\/2024\/09\/23\/rgb-strip\/","title":{"rendered":"RGB strip"},"content":{"rendered":"\n<p>hi i programed adafruit circut rgb strip and its changes color <br><br><br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import time\nimport board\nimport neopixel\n\n# Pin where the LED strip is connected\npixel_pin = board.D6  # Adjust based on your pin\nnum_pixels = 20       # Adjust based on the number of LEDs on your strip\nbrightness = 0.2     # Brightness level, from 0 to 1.0\n\n# Create a NeoPixel object\npixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=brightness, auto_write=False)\n\ndef color_wipe(color, wait):\n    \"\"\"Fill the strip with one color, then turn off.\"\"\"\n    for i in range(num_pixels):\n        pixels&#91;i] = color\n        pixels.show()\n        time.sleep(wait)\n\ndef rainbow_cycle(wait):\n    \"\"\"Draw rainbow colors across all pixels.\"\"\"\n    for j in range(255):\n        for i in range(num_pixels):\n            pixel_index = (i * 256 \/\/ num_pixels) + j\n            pixels&#91;i] = wheel(pixel_index &amp; 255)\n        pixels.show()\n        time.sleep(wait)\n\ndef wheel(pos):\n    \"\"\"Generate rainbow colors across 0-255 positions.\"\"\"\n    if pos &lt; 85:\n        return (255 - pos * 3, pos * 3, 0)\n    elif pos &lt; 170:\n        pos -= 85\n        return (0, 255 - pos * 3, pos * 3)\n    else:\n        pos -= 170\n        return (pos * 3, 0, 255 - pos * 3)\n\n\nwhile True:\n    # Wipe the strip with red color\n    color_wipe((255, 0, 0), 0.05)\n    time.sleep(1)\n\n\n    # Wipe the strip with blue color\n    color_wipe((0, 0, 255), 0.05)\n    time.sleep(1)\n\n    # Wipe the strip with purple color\n    color_wipe((128, 0, 128), 0.05)\n    time.sleep(1)\n\n\n    # Wipe the strip with indigo color\n    color_wipe((75, 0, 130), 0.05)\n    time.sleep(1)\n\n    # Run the rainbow cycle effect\n    rainbow_cycle(0.001)\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>hi i programed adafruit circut rgb strip and its changes color<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-137","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/theroyalscode.com\/students\/a_mermur\/wp-json\/wp\/v2\/posts\/137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theroyalscode.com\/students\/a_mermur\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theroyalscode.com\/students\/a_mermur\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/a_mermur\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/a_mermur\/wp-json\/wp\/v2\/comments?post=137"}],"version-history":[{"count":1,"href":"https:\/\/theroyalscode.com\/students\/a_mermur\/wp-json\/wp\/v2\/posts\/137\/revisions"}],"predecessor-version":[{"id":138,"href":"https:\/\/theroyalscode.com\/students\/a_mermur\/wp-json\/wp\/v2\/posts\/137\/revisions\/138"}],"wp:attachment":[{"href":"https:\/\/theroyalscode.com\/students\/a_mermur\/wp-json\/wp\/v2\/media?parent=137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/a_mermur\/wp-json\/wp\/v2\/categories?post=137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/a_mermur\/wp-json\/wp\/v2\/tags?post=137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}