1. Engineering
  2. Computer Science
  3. arduino code the code i have below is a wireless...

Question: arduino code the code i have below is a wireless...

Question details

Arduino Code:

The code I have below is a wireless signal code from HC-12. I am sending String of numbers and this code is readying it. However I just want to know how to convert the String that are getting sent over into int, so i can work with those numbers. I need to convert the data sent to the String "input" into an int type.

SoftwareSerial mySerial(2, 3); //RX, TX
int ledPin = 13;
void setup() {
pinMode(ledPin, OUTPUT);

void loop() {
if(mySerial.available() > 1){
String input = mySerial.readString();//read string
mySerial.flush();//clear the serial buffer for unwanted inputs   
delay(10);//delay little for better serial communication

********** This is where i am having problem with the code. It wont accpeted it because it is a string and not an int. How do i convert string "input" into an int type?*******

if( input > 10) {
digitalWrite(ledPin, HIGH)

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution