You need to simply open the serial port in python and start sending data. Or recieving data.
Study the pose rial documentation.
The baud rate must be set the same as the arduino.
On the arduino end you use serial read and write just as you would with any serial input / output.
You can try this out. I am sure it will
not going to work unless it has USB to ttl converter in case of arduino,
Yes it is true, you followed right process but i doubt it will work.
You need to simply open the serial port in python and start sending data. Or recieving data.
Study the pose rial documentation.
The baud rate must be set the same as the arduino.
On the arduino end you use serial read and write just as you would with any serial input / output.
You can try this out. I am sure it will
not going to work unless it has USB to ttl converter in case of arduino,
Yes it is true, you followed right process but i doubt it will work.
Why do you comment about things you know nothing about?
This is rubbish. I have done this many times.
What you think yourself. We also not done these kind of stuff. I have also programmed. i also tried these kind of stuff in python.I have written the statement on basis of trial runs done on arduino and python communication
AMPS-N:
What you think yourself. We also not done these kind of stuff. I have also programmed. i also tried these kind of stuff in python.I have written the statement on basis of trial runs done on arduino and python communication
Then you have no idea about what you have done. And very poor language skills in trying to express what you have done.
import serial
arduino= serial.Serial('COM3', 9600)
data = arduino.read(20)
hi = int(data[0])
depending on what i set "hi" to it gives me a different number. It will change even though all numbers printed on serial should be alike. If you need a example ask But while you respond i will be working on getting them.
I dont know if you know python or not, but when i do it tells me the output. Heres what i did to test it.
So this is in the direct mode from the console?
When you send
Serial.print(300);
You will send the ASCII codes 0x33, 0x30, 0x30. In decimal these will be 51, 48, 48
You are sending them very fast so you are filling up the buffer.
depending on what i set "hi" to it gives me a different number.
You need to say what the numbers are to make any sense of this.
Edit. Just seen your results, does this make sense to you now?
Comma is 44 in decimal as well. so it is working you are just not converting them correctly.
So. not to rush it or anything, but how would i fix it and send numbers like this across? Would you recommend breaking the numbers down before sending them? But after I break them down then what? Sorry BTW for being a total Noob at this.
At the moment the only thing that separates your numbers is comma, yuo extract a number like this you read the serial port one bit at a time until you find a comma, that marks the end of your last number. Then you gather bytes into a list until you get another comma, don't add that to the list. Then you convert each byte from the character into a number with an (ord(data[0]).
For each successive number you then multiply the previous number by ten and add the next byte to it.
Bottom line is you have to think about what data format you are sending and how you communicate with the arduino.
This bit of code I used to get two 16 bit ints from the arduino. Each byte was tagged with a unique top two bits so I could identify them.
def openPort():
global running
ser.flushInput()
# tell the arduino to start sending
running = True
ser.write('3')
ser.write('G')
def checkInput(b): # see if the bytes have been received in the correct order
correct = True
for i in range(0,4):
#print i," - " # ,hex(ord(b[i]))
if (ord(b[i]) >> 6) != i :
correct = False
return correct
def getData():
global reading, running
if running :
a = ser.read(4)
if checkInput(a) :
reading[0] = ((ord(a[0]) & 0x1f)<< 5) | (ord(a[1]) &0x1f)
reading[1] = ((ord(a[2]) & 0x1f)<<5) | (ord(a[3]) &0x1f)
#print reading[0]," - ",reading[1]
else:
correct = False
while correct == False : # resyncronise
print "lost sync ",ser.inWaiting()
b = ser.read(1)
t = a[1] + a[2] + a[3] + b[0]
a = t
correct = checkInput(a)
I would be testing out my code but i keep getting this error when attempting to import pyserial:
Traceback (most recent call last):
File "<blender_console>", line 1, in
File "C:\Python33\serial_init_.py", line 19, in
from serial.serialwin32 import *
File "C:\Python33\serial\serialwin32.py", line 12, in
from serial import win32
File "C:\Python33\serial\win32.py", line 196
MAXDWORD = 4294967295L # Variable c_uint
^
SyntaxError: invalid syntax