{"id":135243,"date":"2023-11-09T14:57:45","date_gmt":"2023-11-09T14:57:45","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=135243"},"modified":"2023-11-09T14:57:48","modified_gmt":"2023-11-09T14:57:48","slug":"raspberry-pi-control-outputs-based-on-time","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/raspberry-pi-control-outputs-based-on-time\/","title":{"rendered":"Raspberry Pi: Control Outputs Based on Time of the Day (Python)"},"content":{"rendered":"\n<p>In this guide, you&#8217;ll learn how to easily control outputs with the Raspberry Pi GPIOs based on the time of the day. We&#8217;ll program the Raspberry Pi using Python and the <span class=\"rnthl rntliteral\">gpiozero<\/span> library. We&#8217;ll create a program that automatically turns on and off outputs according to the time of the day. As an example, we&#8217;ll control LEDs, but you can control any other digital outputs.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/09\/Raspberry-Pi-Control-Outputs-based-on-Time-of-Day.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Control Raspberry Pi Outputs Based on Time of the Day Python\" class=\"wp-image-135298\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/09\/Raspberry-Pi-Control-Outputs-based-on-Time-of-Day.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/09\/Raspberry-Pi-Control-Outputs-based-on-Time-of-Day.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/09\/Raspberry-Pi-Control-Outputs-based-on-Time-of-Day.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/09\/Raspberry-Pi-Control-Outputs-based-on-Time-of-Day.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>Before continuing with this tutorial, check the following prerequisites.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Get familiar with the Raspberry Pi board\u2014if you&#8217;re not familiar with the Raspberry Pi, you can read our <a href=\"https:\/\/randomnerdtutorials.com\/getting-started-with-raspberry-pi\/\" title=\"\"><strong>Raspberry Pi Getting Started Guide here<\/strong>.<\/a><\/li>\n\n\n\n<li>You must know how to run and create Python files on your Raspberry Pi. We like to program our Raspberry Pi via SSH using an extension on VS Code. We have a detailed tutorial about that subject: <a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-remote-ssh-vs-code\/\" title=\"\"><strong>Programming Raspberry Pi Remotely using VS Code (Remote-SSH)<\/strong><\/a>.<\/li>\n\n\n\n<li>Know how to use the Raspberry Pi GPIOs so that you know how to wire the circuit properly. Read the following tutorial: <a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pinout-gpios\/\"><strong>Raspberry Pi Pinout Guide: How to use the Raspberry Pi GPIOs?<\/strong><\/a><\/li>\n<\/ol>\n\n\n\n<p>It may also be useful taking a look at the following tutorial to get to know how to control outputs with the Raspberry Pi:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-digital-outputs-python\/\">Control Raspberry Pi Digital Outputs with Python (LED)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Wiring the Circuit<\/h2>\n\n\n\n<p>We&#8217;ll control two LEDs based on the time of the day. Instead of LEDs, you can control any other digital outputs.<\/p>\n\n\n\n<p>We&#8217;ll connect one LED to <span class=\"rnthl rntcorange\">GPIO 17<\/span>, and another to <span class=\"rnthl rntcgreen\">GPIO 27<\/span>. You can use any other suitable pins (take a look at the <a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pinout-gpios\/\" title=\"\">Raspberry Pi pinout here<\/a>).<\/p>\n\n\n\n<p>Here\u2019s a list of components you need:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/raspberry-pi-board\/\" target=\"_blank\" rel=\"noreferrer noopener\">Raspberry Pi Board<\/a>&nbsp;\u2013 read&nbsp;<a href=\"https:\/\/makeradvisor.com\/best-raspberry-pi-starter-kits\/\" target=\"_blank\" rel=\"noreferrer noopener\">Best Raspberry Pi Starter Kits<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/3mm-5mm-leds-kit-storage-box\/\" target=\"_blank\" rel=\"noreferrer noopener\">2x LED<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/resistors-kits\/\" target=\"_blank\" rel=\"noreferrer noopener\">2x 220 Ohm resistor<\/a>\u00a0(or similar)<\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/mb-102-solderless-breadboard-830-points\/\" target=\"_blank\" rel=\"noreferrer noopener\">Breadboard<\/a><\/li>\n<\/ul>\n\n\n<p>You can use the preceding links or go directly to <a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\">MakerAdvisor.com\/tools<\/a> to find all the parts for your projects at the best price!<\/p><p style=\"text-align:center;\"><a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/header-200.png?w=1200&#038;quality=100&#038;strip=all&#038;ssl=1\"><\/a><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"538\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/09\/raspberry-pi-two-LEDs_bb.jpg?resize=750%2C538&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Wire two LEDs\" class=\"wp-image-135299\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/09\/raspberry-pi-two-LEDs_bb.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/09\/raspberry-pi-two-LEDs_bb.jpg?resize=300%2C215&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Control Raspberry Pi Outputs Based on Time of the Day<\/h2>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">gpiozero<\/span> library provides a collection of interfaces for everyday components like LEDs, buttons, potentiometers, sensors, and more. We recommend that you <a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-digital-outputs-python\/\" title=\"\">follow this tutorial first<\/a>, if you&#8217;re not familiar with controlling the Raspberry Pi GPIOs using the <span class=\"rnthl rntliteral\">gpiozero<\/span> library.<\/p>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">gpiozero<\/span> library should already be installed if you\u2019re running Raspberry Pi OS \u2014 if not, you can run the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">python3 -m pip gpiozero<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">The TimeOfDay Interface<\/h3>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">gpiozero<\/span> library provides an interface called <span class=\"rnthl rntliteral\">TimeOfDay<\/span> that allows you to create a device that is active when the computer&#8217;s clock indicates that the current time is between a predefined range. We&#8217;ll see how it works with the following example.<\/p>\n\n\n\n<p>Create a new Python file on your Raspberry Pi called <em>outputs_timeofday.py<\/em> and copy the following code.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-python\"># Complete Project Details: https:\/\/RandomNerdTutorials.com\/raspberry-pi-control-outputs-based-on-time\/\n\nfrom gpiozero import LED, TimeOfDay\nfrom datetime import time\nfrom signal import pause\n\nled1 = LED(17)\nled2 = LED(27)\n\ntod1 = TimeOfDay(time(16,30), time(16,45), utc=False)\ntod2 = TimeOfDay(time(16,45), time(16,50), utc=False)\n\ntod1.when_activated = led1.on\ntod1.when_deactivated = led1.off\n\ntod2.when_activated = led2.on\ntod2.when_deactivated = led2.off\n\npause()\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/Raspberry-Pi\/control_outputs_based_on_time.py\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How the Code Works<\/h3>\n\n\n\n<p>Continue reading to learn how the code works.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Importing Libraries<\/h4>\n\n\n\n<p>First, you import the <span class=\"rnthl rntliteral\">LED<\/span> component from the <span class=\"rnthl rntliteral\">gpiozero<\/span> library to control the GPIO that the LED is connected to and the <span class=\"rnthl rntliteral\">TimeOfDay<\/span> to create a time internal device. You also need the <span class=\"rnthl rntliteral\">time<\/span> function from the <span class=\"rnthl rntliteral\">datetime<\/span> module to create <span class=\"rnthl rntliteral\">time<\/span> objects. Finally, you also need to import the <span class=\"rnthl rntliteral\">pause()<\/span> function from the <span class=\"rnthl rntliteral\">signal<\/span> module to keep your program running so that it can detect events.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>from gpiozero import LED, TimeOfDay\nfrom datetime import time\nfrom signal import pause<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Declaring the LEDs<\/h4>\n\n\n\n<p>Next, you create two <span class=\"rnthl rntliteral\">LED<\/span> objects called <span class=\"rnthl rntliteral\">led1<\/span> and <span class=\"rnthl rntliteral\">led2<\/span> that refer to <span class=\"rnthl rntcorange\">GPIO 17<\/span>, and <span class=\"rnthl rntcgreen\">GPIO 27<\/span>, respectively.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>led1 = LED(17)\nled2 = LED(27)<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Creating TimeOfDay Objects<\/h4>\n\n\n\n<p>Next, we create two objects of type <span class=\"rnthl rntliteral\">TimeOfDay<\/span>. This type of object works like pushbuttons do, but everything is done internally. They are active during a predefined period of time. For example, <span class=\"rnthl rntliteral\">tod1<\/span> is active between 16:30 and 16:45. You should also pass <span class=\"rnthl rntliteral\">utc=False<\/span> parameter, so that it uses your local time.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>tod1 = TimeOfDay(time(16,30), time(16,45), utc=False)<\/code><\/pre>\n\n\n\n<p>You can pass other useful arguments to the <span class=\"rnthl rntliteral\">TimeOfDay<\/span> class:<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>classgpiozero.TimeOfDay(<strong>start_time<\/strong>, <strong>end_time<\/strong>, *, <strong>utc<\/strong>=True, <strong>event_delay<\/strong>=10.0, pin_factory=None)<\/code><\/pre>\n\n\n\n<p>Here&#8217;s what these parameters mean:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span class=\"rnthl rntliteral\">start_time<\/span> (time) \u2013 The time from which the device will be considered active.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span class=\"rnthl rntliteral\">end_time<\/span> (time) \u2013 The time after which the device will be considered inactive.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span class=\"rnthl rntliteral\">utc<\/span> (bool) \u2013 If <span class=\"rnthl rntliteral\">True<\/span> (the default), a naive UTC time will be used for the comparison rather than a local time-zone reading. I prefer to use my local time, so I set this parameter to <span class=\"rnthl rntliteral\">False<\/span>.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span class=\"rnthl rntliteral\">event_delay<\/span> (float) \u2013 The number of seconds between file reads (defaults to 10 seconds).<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span class=\"rnthl rntliteral\">pin_factory<\/span>: this is an advanced feature that you won&#8217;t probably need to use or worry about.<\/li>\n<\/ul>\n\n\n\n<p>We create another <span class=\"rnthl rntliteral\">TimeOfDay<\/span> object that will be active between 16:45 and 16:50. You should adjust these values so that you don&#8217;t have to wait to test the project.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>tod2 = TimeOfDay(time(16,45), time(16,50), utc=False)<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Events<\/h4>\n\n\n\n<p>You can use the <span class=\"rnthl rntliteral\">when_activated<\/span> and <span class=\"rnthl rntliteral\">when_deactivated<\/span> handlers to detect when it reached the start and end time, and associate a function to run when each event is detected.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>when_activated<\/strong><\/h5>\n\n\n\n<p>In the following line, when the <span class=\"rnthl rntliteral\">tod1<\/span> is activated, <span class=\"rnthl rntliteral\">led1<\/span> turns on.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>tod1.when_activated = led1.on<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>when_deactivated<\/strong><\/h5>\n\n\n\n<p>When the <span class=\"rnthl rntliteral\">when_deactivated<\/span> event is detected (it reaches the end time), <span class=\"rnthl rntliteral\">led1<\/span> turns off.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>tod1.when_deactivated = led1.off<\/code><\/pre>\n\n\n\n<p>These events are just activated in the transition from off time to start time and start time to off time. If you start running the program and it is already in the active period, it won&#8217;t turn on because it didn&#8217;t detect the transition from the off time to the on time. To prevent this, we can use the <span class=\"rnthl rntliteral\">is_active<\/span> method to check the state of the <span class=\"rnthl rntliteral\">TimeOfDay<\/span> object (we&#8217;ll take a look at this later).<\/p>\n\n\n\n<p>We proceed in a similar way for the other LED.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>tod2.when_activated = led2.on\ntod2.when_deactivated = led2.off<\/code><\/pre>\n\n\n\n<p>Instead of turning an LED on and off you can associate any other function that you need to run when those button events are detected.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Keep the Program Running<\/h4>\n\n\n\n<p>In the end, we call the <span class=\"rnthl rntliteral\">pause()<\/span> function. It keeps the program running even after all the code has run through to detect events\u2014in this case, it\u2019s continuously checking the time with the <span class=\"rnthl rntliteral\">TimeOfDay<\/span> objects.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>pause()<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Demonstration<\/h3>\n\n\n\n<p>Save your python file. Then run it on your Raspberry Pi. Run the following command on the directory of your project file (use the name of your file):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python <em>gpios_timeofday.py<\/em><\/code><\/pre>\n\n\n\n<p>The LED connected to <span class=\"rnthl rntcorange\">GPIO 17<\/span> should light up when the time of day reaches 16:30 (in my example), and it will turn off when it reaches 16:45. The other LED, connected to <span class=\"rnthl rntcgreen\">GPIO 27<\/span>, will light up between 16:45 and 16:50.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/09\/Raspberry-Pi-Control-Outputs-Time-of-Day.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Control Outputs Based on Time of the day - Demonstration\" class=\"wp-image-135276\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/09\/Raspberry-Pi-Control-Outputs-Time-of-Day.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/09\/Raspberry-Pi-Control-Outputs-Time-of-Day.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>These events to turn on and off the LEDs are just activated in the transition from off time to start time and start time to off time. If you start running the program and it is already in the active period, it won&#8217;t turn on because it didn&#8217;t detect the transition from the off time to the on time. To prevent this, we can use the <span class=\"rnthl rntliteral\">is_active<\/span> function to check the state of the <span class=\"rnthl rntliteral\">TimeOfDay<\/span> object\u2014check the example below.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Other Useful Methods<\/h3>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">TimeOfDay<\/span> interface provides other useful methods like the <span class=\"rnthl rntliteral\">is_active<\/span> method. This returns <span class=\"rnthl rntliteral\">True<\/span> if the device is currently active and <span class=\"rnthl rntliteral\">False<\/span> otherwise.<\/p>\n\n\n\n<p>Here&#8217;s a similar example using this method:<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-python\"># Complete Project Details: https:\/\/RandomNerdTutorials.com\/raspberry-pi-control-outputs-based-on-time\/\n\nfrom gpiozero import LED, TimeOfDay\nfrom datetime import time\nfrom signal import pause\n\nled1 = LED(17)\nled2 = LED(27)\n\ntod1 = TimeOfDay(time(16,30), time(16,45), utc=False)\ntod2 = TimeOfDay(time(16,45), time(16,50), utc=False)\n\nwhile True:\n    if tod1.is_active:\n        led1.on()\n    else:\n        led1.off()\n    \n    if tod2.is_active:\n        led2.on()\n    else: \n        led2.off()\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/Raspberry-Pi\/control_outputs_based_on_time_conditions.py\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>The result will be exactly the same as the previous example. But, it will turn on the LED even if the start time has already started.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>In this tutorial, you learned how to control outputs with the Raspberry Pi based on the time of the day using the <span class=\"rnthl rntliteral\">gpiozero<\/span> library. As you can see, using the <span class=\"rnthl rntliteral\">TimeOfDay<\/span> interface is fairly straightforward. It acts like a button switch that is activated based on the time of the day.<\/p>\n\n\n\n<p>We hope you found this tutorial useful. If you would like to learn more about controlling the Raspberry Pi GPIOs, take a look at the following tutorials:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pinout-gpios\/\">Raspberry Pi Pinout Guide: How to use the Raspberry Pi GPIOs?<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-digital-outputs-python\/\">Control Raspberry Pi Digital Outputs with Python (LED)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pwm-python\/\">Raspberry Pi: PWM Outputs with Python (Fading LED)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-analog-inputs-python-mcp3008\/\">Raspberry Pi: Read Analog Inputs with Python (MCP3008)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-digital-inputs-python\/\">Raspberry Pi: Read Digital Inputs with Python (Buttons and Other Peripherals)<\/a><\/li>\n<\/ul>\n\n\n\n<p>You can check all our Raspberry Pi projects on the following link:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/projects-raspberry-pi\/\">Free Raspberry Pi Projects and Tutorials<\/a><\/li>\n<\/ul>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this guide, you&#8217;ll learn how to easily control outputs with the Raspberry Pi GPIOs based on the time of the day. We&#8217;ll program the Raspberry Pi using Python and &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Raspberry Pi: Control Outputs Based on Time of the Day (Python)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-control-outputs-based-on-time\/#more-135243\" aria-label=\"Read more about Raspberry Pi: Control Outputs Based on Time of the Day (Python)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":135298,"comment_status":"open","ping_status":"closed","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":""},"categories":[301,264,268,190],"tags":[],"class_list":["post-135243","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-0-raspberrypi","category-project","category-raspberry-pi-project","category-raspberry-pi"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/09\/Raspberry-Pi-Control-Outputs-based-on-Time-of-Day.jpg?fit=1280%2C720&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/135243","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=135243"}],"version-history":[{"count":12,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/135243\/revisions"}],"predecessor-version":[{"id":141062,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/135243\/revisions\/141062"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/135298"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=135243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=135243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=135243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}