title: Bidirectional communication between microcontroller and pyserial
body: <p>I am using Python 2.5.4 and Windows 7. </p>
  
  <p>I am trying to create a program that transmits and receives info from a microcontroller using pygame. This code works fine when the microcontroller just writes data to pygame, but when the line is included in the microcontroller code that receives information (readline), the pygame window freezes (doesn't just close the window so I could see what the problem was). I was wondering whether anyone had any experience in a microcontroller and pygame/pyserial talking and listening to each other?</p>
  
  <p>I have read a potentially similar post, but I did not understand the code and not certain if it is the same problem.  I read on these forums the term 'flow control' and I am wondering whether this is my problem?</p>
  
  <p>My code is:</p>
  
  <pre><code>import os, pygame, math, serial   
  from pygame.locals import *
  from pygame.compat import geterror
  from time import clock, time
  pygame.init()
  w = 1100   #sets pygame screen width
  h = 642   #sets pygame screen height
  screen = pygame.display.set_mode((w, h),0,32)  #make and display screen
  
  pygame.display.flip()   #Update screen
  running = 1
  font = pygame.font.Font(None, 36)
  clock = pygame.time.Clock()
  port = serial.Serial("COM2", 115200)
  
  while running:          #Loop this
     for event in pygame.event.get():    #get user input
        if event.type == pygame.QUIT:    #if user clicks the close X
             running = 0                 #make running 0 to break out of loop
  
     temp = float(port.readline())
     clock.tick(100)
     value = font.render(str(temp), 1, (100, 100, 100))
     screen.blit(value, (280,165))
     pygame.display.flip()   #Update screen
     port.write('3')
  </code></pre>