I'm trying to read the data from Arduino to python. The data is read by two sensors so i wanted the be contusloyesly reading at the same time i want to take 1000 samples every time and put them into the function (preposs).
> arduino_port = port='COM4'
> baud = 115200 #arduino uno runs at 9600 baud
> ser = serial.Serial(arduino_port, baud)
> #display the data to the terminal
> sensor_data = [] #store data
>
> sensor_data.append(readings)
> samples = 4999 #how many samples to collect
> line = 0 #start at 0 because our header is 0 (not real data)
>
>
> while line <= samples:
> getData=ser.readline()
> dataString = getData.decode('utf-8')
> data=dataString[0:][:-2]
>
> readings = data.split(",")
>
> sensor_data.append(readings)
>
> line = line+1
> df = pd.DataFrame(sensor_data, columns=["y-axis", "z-axis"])
> data12 = df.astype("float32")
>
> X=preposs(data12, 250, 50)
> print(data12)
This picture shows 5000 samples i manged to print but, it printed after it collected the sample. whereas,i wanted it to be continually printing and i take 1000 sample and put it in the function with the same data frame
Python code structure (loops, conditional statements ...) is defined by indentation instead of brackets. So, your python code example right now has no structure and we do not know what you intend it to do.
arduino_port = port='COM4'
baud = 115200 #arduino uno runs at 9600 baud
ser = serial.Serial(arduino_port, baud)
#display the data to the terminal
sensor_data = [] #store data
sensor_data.append(readings)
samples = 4999 #how many samples to collect
line = 0 #start at 0 because our header is 0 (not real data)
while line <= samples:
getData=ser.readline()
dataString = getData.decode('utf-8')
data=dataString[0:][:-2]
readings = data.split(",")
sensor_data.append(readings)
line = line+1
df = pd.DataFrame(sensor_data, columns=["y-axis", "z-axis"])
data12 = df.astype("float32")
#X=preposs(data12, 250, 50)
#predictions = EMG_CNcN.predict(X,batch_size=32)
#predicted_value = np.argmax(predictions[0])
#print(predictions)
#print(predicted_value)
print(data12.dtypes)
Ya i know that i need to change the sample to 1000 the code i gave i gust put 5000 for testing. but the thing is the code is take 5000 and print it and the code stop running
I read this genuine thing about this topic .The hardware consists of an open-source hardware board designed around an ATmega328 microcontroller, with a wide range of input and output pins. The software consists of a development environment that runs on your computer, used to write and upload code to the microcontroller board.