Arduino: String to Int - Iată cum
Când programați Arduino, uneori trebuie să convertiți șiruri în numere întregi. Puteți afla cum să faceți acest lucru în acest sfat practic
Arduino: String to Int
Pentru a putea converti un șir într-un număr întreg pe Arduino, trebuie mai întâi să definiți o nouă șir cu o comandă precum »String a =" 23 "«.
- Pentru a converti acest șir într-un număr întreg, aveți nevoie de o variabilă întreagă. Puteți, de asemenea, să îi atribuiți valoarea corectă.
- Puteți face acest lucru cu comanda »int b = atoi (a);«. Variabila "b" are acum valoarea 23 ca număr întreg.
- Cu toate acestea, asigurați-vă că șirul nu conține spații sau litere.
În următorul sfat practic, vă vom arăta cum să construiți un voltmetru cu Arduino.