How do you know that the code is not working? How do you expect us to know? You don't say what is in valu, nor do you show how the function is called. Nor have you presented any proof, like serial output.