<commit_before>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Coding the magic\n",
    "==================================\n",
    "\n",
    "\n",
    "Now wire up your LED light to the pi. First have a look at the diagram of the 40-pin interface. The diagram below is provided by element14.\n",
    "\n",
    "<img src=\"http://www.raspberry-pi-geek.com/var/rpi/storage/images/media/images/raspib-gpio/12356-1-eng-US/RasPiB-GPIO_lightbox.png\",width=500/>\n",
    "\n",
    "We will refer in the code to the physical pin number, but it is always useful to be able to look at a diagram to tell what is available to use on each pin. Anything marked \"GPIO\" is a general-purpose input/output pin that we can assign to output a signal to drive the LED. When the signal is HIGH, it will allow current to light the LED.\n",
    "\n",
    "<img src=\"img/led2.jpg\",width=500/>\n",
    "\n",
    "Choose your colors wisely. I try to use red for +5 and blue or black for ground. My blue ground wire goes to pin 6 on the pi. My red wire goes to pin 11 on the pi.\n",
    "\n",
    "The long leg of the LED should go to the resistor and then to the red wire. The short leg should go to the blue wire.\n",
    "\n",
    "Once you have that, and as long as you are executing now inside ipython, you can click on the box below and hit shift-enter to run the script and watch it flash the LED."
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "import RPi.GPIO as GPIO\n",
    "import time\n",
    "from IPython.display import clear_output\n",
    "\n",
    "# blinking function\n",
    "def blink(pin):\n",
    "    GPIO.output(pin, GPIO.HIGH)\n",
    "    time.sleep(0.5)\n",
    "    GPIO.output(pin, GPIO.LOW)\n",
    "    time.sleep(0.5)\n",
    "    return\n",
    "\n",
    "print(\"using Raspberry Pi board pin numbers\")\n",
    "GPIO.setmode(GPIO.BOARD)\n",
    "led_pin = 11\n",
    "\n",
    "print(\"set up GPIO output channel\")\n",
    "GPIO.setwarnings(False)\n",
    "GPIO.setup(led_pin, GPIO.OUT)\n",
    "\n",
    "print(\"blinking the LED\")\n",
    "for i in range(0,6):\n",
    "    print(\"blink\")\n",
    "    blink(led_pin)\n",
    "    \n",
    "GPIO.cleanup()"
   ]
  },
  {
   "cell_type": "markdown",<commit_msg>fix cell back to code type<commit_after>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Coding the magic\n",
    "==================================\n",
    "\n",
    "\n",
    "Now wire up your LED light to the pi. First have a look at the diagram of the 40-pin interface. The diagram below is provided by element14.\n",
    "\n",
    "<img src=\"http://www.raspberry-pi-geek.com/var/rpi/storage/images/media/images/raspib-gpio/12356-1-eng-US/RasPiB-GPIO_lightbox.png\",width=500/>\n",
    "\n",
    "We will refer in the code to the physical pin number, but it is always useful to be able to look at a diagram to tell what is available to use on each pin. Anything marked \"GPIO\" is a general-purpose input/output pin that we can assign to output a signal to drive the LED. When the signal is HIGH, it will allow current to light the LED.\n",
    "\n",
    "<img src=\"img/led2.jpg\",width=500/>\n",
    "\n",
    "Choose your colors wisely. I try to use red for +5 and blue or black for ground. My blue ground wire goes to pin 6 on the pi. My red wire goes to pin 11 on the pi.\n",
    "\n",
    "The long leg of the LED should go to the resistor and then to the red wire. The short leg should go to the blue wire.\n",
    "\n",
    "Once you have that, and as long as you are executing now inside ipython, you can click on the box below and hit shift-enter to run the script and watch it flash the LED."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import RPi.GPIO as GPIO\n",
    "import time\n",
    "from IPython.display import clear_output\n",
    "\n",
    "# blinking function\n",
    "def blink(pin):\n",
    "    GPIO.output(pin, GPIO.HIGH)\n",
    "    time.sleep(0.5)\n",
    "    GPIO.output(pin, GPIO.LOW)\n",
    "    time.sleep(0.5)\n",
    "    return\n",
    "\n",
    "print(\"using Raspberry Pi board pin numbers\")\n",
    "GPIO.setmode(GPIO.BOARD)\n",
    "led_pin = 11\n",
    "\n",
    "print(\"set up GPIO output channel\")\n",
    "GPIO.setwarnings(False)\n",
    "GPIO.setup(led_pin, GPIO.OUT)\n",
    "\n",
    "print(\"blinking the LED\")\n",
    "for i in range(0,6):\n",
    "    print(\"blink\")\n",
    "    blink(led_pin)\n",
    "    \n",
    "GPIO.cleanup()"
   ]
  },
  {
   "cell_type": "markdown",
{'fraction_non_alphanumeric': 0.1722671203743088, 'fraction_numerical': 0.01233517652062952, 'mean_word_length': 2.5682852807283765, 'pattern_counts': {'":': 20, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4575095', 'n_tokens_mistral': 1666, 'n_tokens_neox': 1610, 'n_words': 557}