Arduino: String to Int - Here's how
When programming the Arduino you sometimes have to convert strings to integers. You can find out how to do this in this practical tip
Arduino: String to Int
So that you can convert a string into an integer on the Arduino, you must first define a new string with a command such as »String a =" 23 "«.
- To convert this string into an integer, you need an integer variable. You can also automatically assign the correct value to it.
- You can do this with the command »int b = atoi (a);«. The variable "b" now has the value 23 as an integer.
- However, make sure that the string contains no spaces or letters.
In the next practical tip, we will show you how to build a voltmeter with the Arduino.