Changes

Jump to: navigation, search

Raspberry Pi - Week 3

1,320 bytes added, 14:18, 26 April 2013
Further Python Help
[[Raspberry_Pi#Course_of_Instruction | <<< back to Raspberry Pi]]
 
==Review==
Connecting Installed an OS image, created a user account with super-user permissions. Connected to the pi from a local computer via ssh. Copied files with sshSCP.
==Graphical Interface through the Network==
==logging onto raspberry pi from vnc client==
*You need a vnc client. This will connect to the vnc server which is currently running on your raspberry pi.
*Adafruit suggests "VNCViewer", available for free for most platforms from .*Download and install VNCViewer. http://www.realvnc.com/.*Download and install VNCViewer.download/viewer/
*Run the software.
*In the "VNC Server:" field, enter the IP address for your PI and the port display number you started vncserver on. For instance <code>192.168.2.2:1</code> is IP 192.168.2.2, port display 1.
**You selected the port when you started vncserver on the pi.
*Click connect.
*If you have installed python, you have IDLE. most likely on your laptop as well.
*Raspbian comes with two python installs, Python 2.7 and Python 3. We are going to use 2.7. 3 is the future.
 *Example, taking photos and sending them to the laptop. take_photos_and_send.py [[:File:photo_loop.tar]]*SubprocessUses <code>subprocess.call</code>, and <code>time.sleep</code>**python subprocess documentation - http://docs.python.org/2/library/subprocess.html*time documentation - http://docs.python.org/2/library/time.html
==Festival example==
[http://wiki.roberttwomey.com/images/5/5d/Speech_loop.tar speech_loop.tar ]*For both of these examples, you will need to edit the path to the festival command. *The program was written on my Laptop, so I used the path to festival there. ''/Users/rtwomey/...''. On the raspberry pi the festival install path is ''/usr/bin/festival''.*You can find the path to a program with the <code>which</code> command. For ex:**<code>which festival</code>**gives you the current festival install directory.*'''speech_loop.py''' - counts up from 0.*'''speech_potato.py'''. try it and see ;)
==Client - Server architecture==
*My Convex Mirror project uses a client-server architecture:
[[:Filehttp://wiki.roberttwomey.com/images/3/36/Convex_mirror_client_server.tar convex_mirror_client_server.tar]]
*Server on raspberry pi. '''convex_mirror_server.py'''
**opens a socket on a certain port, and waits for requests from clients.
==Further Python Help==
*[http://learnpythonthehardway.org/book/ Learn Python the Hard Way]*Interactive introduction, in browser - [http://www.learnpython.org/learnpython.org].*Code Academy's [http://www.codecademy.com/tracks/python python track]**start with [[Python Syntax | http://www.codecademy.com/courses/introduction-to-python-6WeG3?curriculum_id=4f89dab3d788890003000096Python Syntax]]course.*A Gentle Introduction to Programming Using Python, MIT OCW [http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-189-a-gentle-introduction-to-programming-using-python-january-iap-2011/index.htmA Gentle Introduction to Programming Using Python], MIT Open Course Ware (OCW).*Python.org links for [http://wiki.python.org/moin/BeginnersGuide/NonProgrammers Python for Non-Programmers]. A lot to sort through, you pick one.

Navigation menu