Arduino: String to Int - Ето как
Когато програмирате Arduino, понякога се налага да конвертирате низове в цели числа. Можете да разберете как да направите това в този практичен съвет
Arduino: String to Int
За да можете да преобразувате низ в цяло число в Arduino, първо трябва да дефинирате нов низ с команда като "String a =" 23 "«.
- За да преобразувате този низ в цяло число, имате нужда от цяло число. Можете също така автоматично да му присвоите правилната стойност.
- Можете да направите това с командата »int b = atoi (a);«. Променливата "b" вече има стойността 23 като цяло число.
- Уверете се обаче, че низът не съдържа интервали или букви.
В следващия практичен съвет ще ви покажем как да изградите волтметър с Arduino.