Convert string into integers

Hello,
I want to convert text to integers, or even better, to binary.

I've already written something to convert integers to binary, but eventually I want to convert text to binary.

I know you can print the ASCII value of every char of a string, but I don't want to print te value, I want the ASCII value as a variable, so I can use it

Is there anyone who has an idea?

Text is binary. Integers are binary. Everything in the computer is binary. What do you mean?

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:

  char a_string[10];          // make a char array to hold string

  strcpy(a_string, "25");      // Place string in array

  unsigned long value = atoi(a_string);  // atoi converts the array of ascii to an int

  for (byte i = 1; i < 10; i++) {        // print the new "value" variable to the monitor...times it by 1 to 9 for example.
    Serial.println(value * i);
    delay(100);
  }
  delay(500);


}

want to convert text to integers,

A very simple example of capturing a string of numeric characters into a String, then converting the String into an integer.

//zoomkat 7-30-10 serial servo test
//type servo position 0 to 180 in serial monitor
// Powering a servo from the arduino usually *DOES NOT WORK*.

String readString;
#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 

void setup() {
  Serial.begin(9600);
  myservo.attach(9);
  Serial.println("servo-test"); // so I can keep track of what is loaded
}

void loop() {

  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the String readString
    delay(2);  //slow looping to allow buffer to fill with next character
  }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured String 
    int n = readString.toInt();  //convert readString into a number
    Serial.println(n); //so you can see the integer
    myservo.write(n);
    readString="";
  } 
}

Individual ASCII characters are bytes. If the parity bit is masked,
numbers 0 through 9 are 0x30 to 0x39.
If the numbers are entered as HEX, you need A through F being 0x41 to 0x46.
If lower case, a to f it is 0X61 to 0x66.
Converting is then just math.
123
is
0x31,0x32,0x33.
Typical conversion programs read left to right and first check
each digit to be in range. If so it subtracts 0x30.
If there is another digit, it multiplies the sum by 10 ( 16 if hex )
and adds the next converted value.
Programming should be simple enough.
Dwight

You can also write zoomcat's code without using the String class, which usually results in smaller code. His code compiles to 6026 bytes. The following code does not use the String class, but instead uses a char array to form a C string:

#include <Servo.h>
Servo myservo;  // create servo object to control a servo


char readString[10];

void setup() {
  Serial.begin(9600);
  myservo.attach(9);
  Serial.println("servo-test"); // so I can keep track of what is loaded
}

void loop() {
  byte charsRead;

  if (Serial.available() > 0) {
    charsRead = Serial.readBytesUntil('\n', readString, 9);  // Read until newline
    readString[charsRead] = '\0';                            // Now it's a string

    if (charsRead > 0) {
      Serial.println(readString);  // so you can see the captured String
      int n = atoi(readString);    // convert readString into a number
      Serial.println(n);           // so you can see the integer
      myservo.write(n);
    }
  }
}

It compiles to 4314 bytes.