From String to int


i want grab number (int) of out string , use address in eeprom. code below not working.

code: [select]

instring = #num2;
char slotno = instring.charat(4);  //returns '2'
int s(slotno);
eeprom.write(s, '8');
char value = eeprom.read(2);
serial.println(value, byte);


i'm pretty sure s never converted 'int' becuase there no problems when write

eeprom.write(2, '8');

if serial.print(s), '2'. hope can tell me i'm doing wrong.

i think answered own question, there.

the slotno variable holds '2', not 2. '2' ascii code 50, so, s have value 50, not 2. not reading wrote.

to convert char int, subtract '0' char:

int s = slotno - '0';


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > From String to int


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums