![]() This is the fully functional, albeit very basic, implementation of the classic Atari Breakout game. ![]() This will make your programs shorter, clearer and easier to read, which, in turn will make them easier to debug. Writing your own libraries makes it easier to integrate snippets of code into the main program. Python scans PYTHONPATH to see what directories it has to search for libraries, so from now on when you write a new program, dial.py will be available immediately, without you having to copy it over to your new project's directory from elsewhere. ![]() , if you see /home/pi/lib/python (or whatever your home directory is) on its own or among a bunch of other directories, then all's well. Now add the line: export PYTHONPATH=$PYTHONPATH: $HOME/lib/pythonĪt the end of your. Create a directory for your modules in your home directory, for example: $ mkdir -p $HOME/lib/python The second advantage is that it makes code re-usable: dump dial.py into your project's directory or, better yet, copy it to a directory Python routinely scans for libraries, and it will be made available to all your apps. The first advantage of converting the dial.py program into the dial.py library is that it helps break the project into manageable pieces. Twiddle the dial, try again, and you'll get another number, and so on. This number gives you the position of the dial on the potentiometer. ![]() The program will output a number between 0 and 1 (well, more realistically between 0 and 0.9999). Visit the directory where you have stored the file and run: $ python dial.py Figure 4: A detailed view of how to hook the 3202 to your Pi. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |