Converting from string to int

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 to int so i can work with those numbers. I need to convert the data sent to the String “input” into an int type.

#include <SoftwareSerial.h>

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

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

Please edit your post to sue code tags. See How to use the forum.

While you are at it, you can also explain what doesn't work and what happens. I see a serial print but you didn't bother us to tell what it actually prints...

Next, a String is not the same as a string :wink:

And a flush() doesn't clear the serial input. It waits until the send buffer is empty.

Search for robin2's 'serial input basics - updated' thread. It shows different ways to read (serial) input and how to convert text to integer.