I want to convert a string into a int value. in my real code, I receive a string "Slider 255" the number after slider changes from 0 to 255, so I want a int value to be equal to that number. This is a small example of the code:
#include <Servo.h>
Servo myServo;
int val = 0;
String s = "";
void setup() {
Serial.begin(9600);
myServo.attach(9);
}
void loop() {
while(BT.available() >0){
s = Serial.read(); // which wiil be a number between 0 and 255
// So I want val to be = to ehatever the string is. So far I have try this but it doesn´t work.
// first attempt # 1
val = s:
myServo.write(val);
// Second attempt # 2
Serial.println(s)
val = Serial.read();
myServo.write(val);
}
}