{"id":247,"date":"2018-11-30T00:23:38","date_gmt":"2018-11-30T08:23:38","guid":{"rendered":"https:\/\/doubleecpu.com\/?page_id=247"},"modified":"2019-09-25T01:05:26","modified_gmt":"2019-09-25T08:05:26","slug":"blinking-led","status":"publish","type":"page","link":"https:\/\/doubleecpu.com\/index.php\/raspberrypi\/blinking-led\/","title":{"rendered":"Blinking LED"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Raspberry Pi GPIO Pins<\/h3>\n\n\n\n<p>Programming the GPIO pins on the Raspberry Pi using Python.&nbsp;<br>To Install Python on Rasbian<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">    sudo apt-get install python3<\/pre>\n\n\n\n<p>Setup the circuit by connecting the positive end of a LED up to GPIO 4 (pin 7) and the negative end to a 330k ohm resistor and to a ground (pin 6,8, or any GND) similar to the diagram below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"658\" height=\"767\" src=\"https:\/\/doubleecpu.com\/wp-content\/uploads\/2019\/09\/RPI3_GPIO4_LED_Resistor_Breadboard.png\" alt=\"\" class=\"wp-image-1755\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Create a python&nbsp;file<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">    sudo nano led_blink.py<\/pre>\n\n\n\n<p>And insert the code:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">    #import the GPIO and time package\n    import RPi.GPIO as GPIO\n    import time\n    GPIO.setmode(GPIO.BOARD)\n    GPIO.setup(7, GPIO.OUT)\n    # loop through 50 times, on\/off for 1 second\n    for i in range(50):\n        GPIO.output(7,True)\n        time.sleep(1)\n        GPIO.output(7,False)\n        time.sleep(1)\n    GPIO.cleanup()<\/pre>\n\n\n\n<p>Now save and exit file. (Nano exit by pressing ctrl+x and then Answer yes to write to file by typing y)<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"> Running the python script <\/h3>\n\n\n\n<p>Running the python script the circuit should power on the LED. The python script is run by executing the following command. It is also important to run it as the superuser using&nbsp;<em>sudo.<\/em><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">    sudo python led_blink.py\n<\/pre>\n\n\n\n<figure class=\"wp-block-video\"><video controls src=\"https:\/\/doubleecpu.com\/wp-content\/uploads\/2019\/09\/20190925_005253.mp4\"><\/video><\/figure>\n\n\n\n<p>This concludes the GPIO pinout Tutorial.<\/p>\n\n\n\n<p><a href=\"https:\/\/doubleecpu.com\/index.php\/raspberrypi3bsensors\/\">Check further GPIO programming using Sensors&nbsp;<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Raspberry Pi GPIO Pins Programming the GPIO pins on the Raspberry Pi using Python.&nbsp;To Install Python on Rasbian sudo apt-get install python3 Setup the circuit by connecting the positive end of a LED up to GPIO 4 (pin 7) and the negative end to a 330k ohm resistor and to a ground (pin 6,8, or &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/doubleecpu.com\/index.php\/raspberrypi\/blinking-led\/\" class=\"more-link\">Read more<span class=\"screen-reader-text\"> &#8220;Blinking LED&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":151,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-247","page","type-page","status-publish","hentry"],"featured_media_urls":[],"_links":{"self":[{"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/pages\/247","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/comments?post=247"}],"version-history":[{"count":0,"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/pages\/247\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/pages\/151"}],"wp:attachment":[{"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/media?parent=247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}