PySerial (Python) + Arduino sensors

Hey guys,

I'm trying to write a simple program using PySerial.

I have two servos and two touch sensors.
I want to write something so that when I touch each sensor, the corresponding servo would move.

I've managed to set up PySerial, and even control a Servo with it. My main problem is reading the touch sensors when they are touched, AND discerning which touch sensor is being touched.

Here's my Python code if you're interested. (This basically takes in a number as input and sends it to the Arduino. The Arduino moves the Servo according to this number).

import serial as Serial

def main():
	serial = Serial.Serial('/dev/tty.usbmodem621', 9600)
                		
	char = 't'
	while char != 'e':
		char = raw_input( '> ' )
		numb = int( char )
		numb_ascii = chr( numb )
		char = numb_ascii
		if char == 'e':
			break;
		serial.write( char )
		print "->", serial.readline().rstrip( '\r' ).rstrip( '\n' )
                        
	serial.close()

if __name__ == '__main__':
	main()

Would greatly appreciate your help. Thanks guys.

The Python program can't read the sensors. Only the Arduino can. Making the Python script ask the Arduino to read sensor one is possible. Making the Python script ask the Arduino to read sensor two is possible. Making the Python script ask the Arduino to move servo n to position p is possible.

Those are all Python issues, though, and this is not the Python forum.

Making the Arduino read sensor n is pretty easy. Making the Arduino move servo n to position p is pretty easy. But, as you've not posted any code, or asked how to do that, there doesn't seem to be much we can do for you.