Welcome Amigos' !!!!
Hope you have completed the configuration stage.
Now lets code our first ***
Step1:Create a separate directory to mange all the program we do using the terminal command
Step2: Now get into the created folder
>> cd myprograms
Step3: To create a first program type
>> sudo nano myfirst.py
+ In this sudo indicates "SUPER USER" so the command mention will be used with administrator permission.
+ nano is the command to create new files.
+ myfirst.py is the name of my first program with extension .py, since it is a python program.
Step4: Lets begin!!! please see the syntax below before going for actual program
import RPi.GPIO as GPIO # importing GPIO module- remember that this is case sensitive
import time # Importing Time module
GPIO.setmode(GPIO.BOARD) # you can use this if you want to use pi's direct pin numbers
or
GPIO.setmode(GPIO.BCM) # you can use this, if you want to use the CPU pin numbering
(sometimes there will be a need for switching modes, there we can make use of this)
GPIO.setup(channel, GPIO.IN) # to set the input channel
GPIO.setup(channel, GPIO.OUT) # to set the output channel
GPIO.cleanup() # this line will refresh and reset the system by removing imported modules, consider this as a good programming style
see you
---
Arun
Hope you have completed the configuration stage.
Now lets code our first ***
Step1:Create a separate directory to mange all the program we do using the terminal command
>> mkdir myprograms
>> cd myprograms
Step3: To create a first program type
>> sudo nano myfirst.py
+ In this sudo indicates "SUPER USER" so the command mention will be used with administrator permission.
+ nano is the command to create new files.
+ myfirst.py is the name of my first program with extension .py, since it is a python program.
Step4: Lets begin!!! please see the syntax below before going for actual program
import RPi.GPIO as GPIO # importing GPIO module- remember that this is case sensitive
import time # Importing Time module
GPIO.setmode(GPIO.BOARD) # you can use this if you want to use pi's direct pin numbers
or
GPIO.setmode(GPIO.BCM) # you can use this, if you want to use the CPU pin numbering
(sometimes there will be a need for switching modes, there we can make use of this)
GPIO.setup(channel, GPIO.IN) # to set the input channel
GPIO.setup(channel, GPIO.OUT) # to set the output channel
GPIO.cleanup() # this line will refresh and reset the system by removing imported modules, consider this as a good programming style
see you
---
Arun
No comments:
Post a Comment