Arduino: String to Int - Ecco come
Quando si programma Arduino a volte è necessario convertire le stringhe in numeri interi. Puoi scoprire come farlo in questo suggerimento pratico
Arduino: String a Int
Affinché sia possibile convertire una stringa in un numero intero su Arduino, è necessario innanzitutto definire una nuova stringa con un comando come »String a =" 23 "«.
- Per convertire questa stringa in un numero intero, è necessaria una variabile intera. Puoi anche assegnare automaticamente il valore corretto ad esso.
- Puoi farlo con il comando »int b = atoi (a);«. La variabile "b" ora ha il valore 23 come numero intero.
- Tuttavia, assicurarsi che la stringa non contenga spazi o lettere.
Nel prossimo suggerimento pratico, ti mostreremo come costruire un voltmetro con Arduino.