Hardware Reference
In-Depth Information
Listing 16-4 continued
if event.key == K_6 :
ser.write('6')
# data from alternate three pendulums
if event.key == K_h :
ser.write('S') # stop arduino from sending
running = False
if event.key == K_j :
ser.write('G') # start arduino sending
running = True
if event.key == K_HOME :
ser.write('S') # stop arduino from sending
print “save sketch to file”
if picture == 1 : # first time to save this session
fileName = raw_input(“Enter file name ;
for this session “)
try:
pygame.image.save(screen,'harmo/'+;
fileName+str(picture)+'.png')
except:
os.system('mkdir harmo')
pygame.image.save(screen,'harmo/'+;
fileName+str(picture)+'.png')
print “saving sketch as “,'harmo/'+;
fileName+str(picture)+'.png'
picture +=1;
ser.write('G') # start arduino sending
if __name__ == '__main__':
main()
If you get an error at the line
import serial
hen you will have to install it by typing
sudo apt-get python-serial
Search WWH ::




Custom Search