Python Forum
Convert string to float problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert string to float problem
#1
Hi, I have a problem converting a string to a float. The program receives data from Arduino via the serial port and processes it. But I'm getting this error message. Is there a solution? Thank you!

from pynput.mouse import Button, Controller
import time
import serial

mouse = Controller()
ser = serial.Serial('COM3', baudrate=9600, timeout=1)


while True:
    arduinoData = ser.readline().decode('ascii')
    print(arduinoData)
    data = (float(arduinoData))
    mouse.position = (data, 100)

Attached Files

Thumbnail(s)
   
Reply


Messages In This Thread
Convert string to float problem - by vasik006 - May-27-2022, 07:15 PM
RE: Convert string to float problem - by ndc85430 - May-27-2022, 07:33 PM
RE: Convert string to float problem - by deanhystad - May-27-2022, 08:12 PM
RE: Convert string to float problem - by vasik006 - May-28-2022, 08:13 AM
RE: Convert string to float problem - by vasik006 - May-28-2022, 08:16 AM
RE: Convert string to float problem - by vasik006 - May-28-2022, 08:46 AM
RE: Convert string to float problem - by deanhystad - May-28-2022, 01:08 PM
RE: Convert string to float problem - by vasik006 - Jun-03-2022, 04:54 PM
RE: Convert string to float problem - by deanhystad - Jun-03-2022, 06:41 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  convert to bin problem kucingkembar 3 324 Apr-19-2024, 12:53 PM
Last Post: kucingkembar
  python calculate float plus float is incorrect? sirocawa 6 400 Apr-16-2024, 01:45 PM
Last Post: DeaD_EyE
  Convert From PDf into JPEG Problem koklimabc 4 1,113 Sep-05-2023, 06:44 AM
Last Post: Gribouillis
  convert string to float in list jacklee26 6 1,996 Feb-13-2023, 01:14 AM
Last Post: jacklee26
  openpyxl convert data to float jacklee26 13 6,215 Nov-19-2022, 11:59 AM
Last Post: deanhystad
  how to convert tuple value into string mg24 2 2,424 Oct-06-2022, 08:13 AM
Last Post: DeaD_EyE
  Convert SQLite Fetchone() Result to float for Math Extra 13 3,655 Aug-02-2022, 01:12 PM
Last Post: deanhystad
  TypeError: float() argument must be a string or a number, not 'list' Anldra12 2 4,951 Jul-01-2022, 01:23 PM
Last Post: deanhystad
  Detecting float or int in a string Clunk_Head 15 4,726 May-26-2022, 11:39 PM
Last Post: Pedroski55
  Convert a string to a function mikepy 8 2,613 May-13-2022, 07:28 PM
Last Post: mikepy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020