PySerial (Python) + Arduino sensors


hey guys,

i'm trying write simple program using pyserial.

i have 2 servos , 2 touch sensors.
i want write when touch each sensor, corresponding servo move.

i've managed set pyserial, , control servo it. main problem reading touch sensors when touched, , discerning touch sensor being touched.

here's python code if you're interested. (this takes in number input , sends arduino. arduino moves servo according number).

code: [select]


import serial 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 appreciate help. guys.

the python program can't read sensors. arduino can. making python script ask arduino read sensor 1 possible. making python script ask arduino read sensor 2 possible. making python script ask arduino move servo n position p possible.

those python issues, though, , not python forum.

making arduino read sensor n pretty easy. making arduino move servo n position p pretty easy. but, you've not posted code, or asked how that, there doesn't seem can you.


Arduino Forum > Using Arduino > Programming Questions > PySerial (Python) + Arduino sensors


arduino

Comments

Popular posts from this blog

Convierte tu Raspberry en un NAS. Firmware fvdw-sl 15.3 - Raspberry Pi Forums

How to format a Get Request

avrdude: verification error, first mismatch at byte 0x0000 0x0c != 0x62