Skip to main content

Simple GPIO input/output program for raspberry pi

By: prayag nao

Today we are going to discuss about simple I/O program of raspberry pi.here is pin diagram of raspberry.



so we are going to talk about GPIO I/O program then we need 2 pins,one for output and one for input from button.

material required:
  • Raspberry pi.
  • A push Button.
  • some connector wires.
  • A LED.
connections:
  • connect 5v pin of raspberry pi to one pin of push button.
  • Now connect one end of push button ti 11th pin of raspberry pi.
  • Now connect 13th pin to +ev pin of led and ground to -ev pin of led (you should use a resistance of 330omhs in series with LED).
Programming:

  •  open text editor of raspberry pi and paste the following code.
      import GPIO.RPi as GPIO            ##import GPIO library
      import time
      GPIO.setmode(GPIO.BOARD)    ##use board pin numbering
      GPIO.setup(11,GPIO.IN)          ##set 11th pin as Input pin
      GPIO.setup(13,GPIO.OUT)       ## set 13th pin as output pin

      while 1:
        if GPIO.input(11):
             GPIO.output(13,1)  ## Turn on led
             time.sleep(1)           ## 1 second delay
             GPIO.output(13,0)  ## Turn off led
             time.sleep(1)        
  • Now save the following code with name of input.py.
  • Run this code as root user and you will see when we press button led will start blinking in 1 second delay.
For any query pls comment below.

Comments

Popular posts from this blog

Real life Jarvis-Talk With Your Computer like Jarvis in Iron Man ....!

By:Prayag nao                                            Code to Make your Computer like Jarvis New Speech macro..>> Choose Advanced and change the code like this.. <speechMacros>   <command>     <listenFor></listenFor>   </command> </speechMacros> You have to add a commands  <listenFor>........</listenFor> - computer listens the words you specify here and respond accordingly. <speak>............</speak> - computer speaks what is written in this field according to the command which it got. Similarly, You can Edit more commands in the same way.   <speechMacros> <command> <listenFor>What's going on dude</listenFor> <speak>Nothing special tony</speak> </command> </speechMacros> This is just a basic command,If you want more advanced commands.you have to use Java Scripts and VB scripts . Tell me Time : This is d

HOW INTERNAL EXPANDING BRAKE WORKS

By:Prayag nao An internal expanding brake consists of two shoes S 1 and S 2 . The outer surface of the shoes are lined with some friction material (usually with Ferodo) to increase the coefficient of friction and to prevent wearing away of the metal. Each shoe is pivoted at one end about a fixed fulcrum O 1 and O 2 and made to contact a cam at the other end. When the cam rotates, the shoes are pushed outwards against the rim of the drum. The friction between the shoes and the drum produces the braking torque and hence reduces the speed of the drum. The shoes are normally held in off position by a spring . The drum encloses the entire mechanism to keep out dust and moisture. This type of brake is commonly used in motor cars and light trucks.   We shall now consider the forces acting on such a brake, when the drum rotates in the anticlockwise direction . It may be noted that for the anticlockwise direction, the left hand shoe is known as leading or primary shoe

HOW TO SEND FAKE SMS VIA WEB

SEND FAKE SMS VIA WEB: You are looking for free SMS spoofing sites. You want to send fake SMS text messages, targeted for recipients to U.S, Canada, Australia or anywhere in the world without paying a single cent? There was nowhere you could find it, but now you have a chance. When SMS Spoofing site FakeMSG.com launched the first iPhone application to send spoof sms through BigBoss (for jailbroken iPhones), it was giving out one free SMS credit for every unique iPhone app user, but soon ended the offer due to widespread craze and abuse. visit URL: http://www.bulksms.com/      2.  now select BulkSMS International (€) under Select your regional site here now      3.now sign up and get a code on your phone via sms.entring code on site you will get 5 free credit.    4.now you can send fake sms to anyone .ENJOY.........!!!!! Warning: Send Fake SMS is probably illegal and we don’t advise you to do