Page 67 - Computing Book 8
P. 67

Programming Robots and Single-Board Computers                                        Class 8


               Bread Board: Breadboards are one of the most fundamental pieces when learning how to build
               circuits. A breadboard is a construction base for prototyping of
               electronics for temporary testing. The following diagram
               shows how a breadboard is connected.
               Jumper Wire: A jump wire (also known as jumper wire, or jumper) is
               an electrical wire, or group of them in a cable, with a connector or
               pin at each end (or sometimes without them – simply "tinned"),
               which is normally used to connect the components of a breadboard or other
               prototype or test circuit. Jumper wires typically have a solid core which means they
               have 1 single strand of wire as opposed to the usual multiple thin strands used in electrical
               circuits. This makes them easy to bend into a particular shape.
               Practical Task: Perform the above-mentioned program using raspberry pi and necessary equipment
               as mentioned above.
               Blinking LED Program:
               In this program, the same components will be used which we have used earlier, but this
               program is a bit different than the previous one as we will use the while loop for
               continuous repetition of the program.
               Enter the following code in Python IDLE program using the raspberry Pi:
               import RPi.GPIO as GPIO
               import time
                                                        Refer to the configuration
               GPIO.setmode(GPIO.BCM)
                                                         of the GPIO diagram→
               GPIO.setwarnings(False)
               GPIO.setup(18,GPIO.OUT)
               while True:
                   GPIO.output(18,True)
                   time.sleep(0.5)
                   GPIO.output(18,False)
                   time.sleep(0.5)
               Practical Task: Perform the above-mentioned program using raspberry pi and necessary equipment
               as mentioned above.
               Button Controlled LED:
               In this program, the same components will be used which we have used earlier, except the button.
               In this program, we will control the blinking or turning on and off the LED using a button.
               Enter the following code in Python IDLE program using the raspberry Pi:
               import RPi.GPIO as gpio
               import time as t
               gpio.setmode(gpio.BCM)
               gpio.setwarnings(False)
               gpio.setup(18,gpio.IN)
               gpio.setup(23,gpio.OUT)
               while True:
                   if gpio.input(18):
                       gpio.output(23,True)
                       t.sleep(.1)
                   else:
                       gpio.output(23,False)
                                                                Refer to the configuration of GPIO diagram



               The City School /Academics/Computing Curriculum/Class 8/2020-2021                Page 66 of 75
   62   63   64   65   66   67   68   69   70   71   72