Arduino:StringからInt-方法は次のとおりです
Arduinoをプログラミングするとき、文字列を整数に変換する必要がある場合があります。 この実用的なヒントでこれを行う方法を見つけることができます
Arduino:StringからInt
Arduinoで文字列を整数に変換できるようにするには、まず»String a = "23"«などのコマンドで新しい文字列を定義する必要があります。
- この文字列を整数に変換するには、整数変数が必要です。 正しい値を自動的に割り当てることもできます。
- これを行うには、コマンド»int b = atoi(a);«を使用します。 変数「b」の整数値は23になりました。
- ただし、文字列にスペースや文字が含まれていないことを確認してください。
次の実用的なヒントでは、Arduinoで電圧計を作成する方法を示します。