ModMyPi LTD | GPIO & Python (1/9)

von Satoshi Nakamoto

ModMyPi LTD | GPIO & Python (1/9)

Run your first python program “hiya world”



Issues you will want:



Raspberry Pi + SD Card

Keyboard + Mouse

Monitor + HDMI Cable

Energy Provide



Stipulations:



Newest model of Rasbian put in in your SD Card
Raspberry Pi setup with a keyboard, mouse and monitor



 



1. Begin by opening a Terminal, by click on the icon within the taskbar







2. Begin by creating a brand new listing, that is the place we're going to retailer all our scripts for this collection of tutorials, make a listing referred to as gpio_python_code:




mkdir gpio_python_code



3. We are able to use the command ls -l to view the contents of the present listing:




ls -l



You must be capable to see the listing you created



4. Now we have to change our present listing to the newly created gpio_python_code listing:




cd gpio_python_code



5. Utilizing the contact command, we are able to create an empty file. This will probably be the place we're going to code our Whats up World script.




contact 1_helloworld.py



6. As soon as we have now created our empty file, we are able to use the command nano, to open it in a textual content editor.




nano 1_helloworld.py



7. Now enter the next code:




#!/usr/bin/python
#Print Whats up world
print "Whats up World!"



8. Press ctrl+X to exit, you may be prompted to avoid wasting the file, merely press Y, after which be you may be prompted to provide the file a reputation.

It's going to mechanically use its present identify 1_helloworld.py, so simply hit enter to just accept.



9. To execute your script, merely enter the next command:




sudo python 1_helloworld.py





Source link



Read the full article
Porträt von Satoshi Nakamoto

Satoshi Nakamoto

Zur Person

Satoshi Nakamoto