Arduino 프로그램에서 나는 GPS를 통해 arduino에 USB를 통해 좌표를 보낸다. 이 때문에 들어오는 좌표는 문자열로 저장됩니다. GPS 좌표를 float 또는 int로 변환 할 수있는 방법이 있습니까?String을 float 또는 int로 어떻게 변환합니까?
나는 int gpslong = atoi(curLongitude)
및 float gpslong = atof(curLongitude)
을 시도했지만, 그들은 둘 다 원인 아두 이노 오류 줄 :
error: cannot convert 'String' to 'const char*' for argument '1' to 'int atoi(const char*)'
가
사람이 어떤 제안이 있습니까를?
toInt 제대로 감사를 작동합니다. 이 경우 toCharArray를 얼마나 정확하게 사용합니까? 나는 그것을 알아낼 수 없습니다. – Xjkh3vk
@ Xjkh3vk : 예를 추가했습니다. – nneonneo