Arduino: String to Int - Evo kako
Kada programirate Arduino, ponekad morate pretvarati nizove u cijele brojeve. Možete saznati kako to učiniti u ovom praktičnom savjetu
Arduino: String to Int
Kako biste mogli pretvoriti niz u cijeli broj na Arduino-u, prvo morate definirati novi niz naredbom kao što je »String a =" 23 "«.
- Da biste pretvorili ovaj niz u cijeli broj, potrebna vam je cijela varijabla. Također možete automatski dodijeliti ispravnu vrijednost.
- To možete učiniti naredbom »int b = atoi (a);«. Varijabla "b" sada ima vrijednost 23 kao cijeli broj.
- Ipak, provjerite da niz ne sadrži razmake i slova.
U sljedećem praktičnom savjetu pokazat ćemo vam kako sagraditi voltmetar s Arduinom.