Skip to content

Instantly share code, notes, and snippets.

@moonjuice
Created May 15, 2015 13:27
Show Gist options
  • Save moonjuice/e12bdbba0e13158355b4 to your computer and use it in GitHub Desktop.
Save moonjuice/e12bdbba0e13158355b4 to your computer and use it in GitHub Desktop.
if (BT.available()>0){
val = BT.read();
Serial.print(red);
if (val>=30 && val<=39) {
//如果是數字(0~9),也就是ASCII介於30~39,把值存起來
red = red * 10 + (val - 30);
/* example:
1 => 0 * 10 + 1 = 1
8 => 1 * 10 + 8 = 18
0 => 18 * 10 + 0 = 180
*/
} else if (val==','){
//TODO: 如果是逗號,那麼做你想要做的事情。
red = 0;
} else {
//其他的符號或是字母,不做處理,也可以把這個else區塊砍掉。
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment