Coding with analog and digital inputs
hi! have problem struggling put code potentiometer (analog) , ultrasonic sensor same line of code. using ultrasonic sensor obtain distance reading , have working code on own. potentiometer being used measure rotation , again have working code on own. how can combine two?
well rule of thumb this:
decide want resulting sketch do, , figure out how. if 1 uses blocking code full of delay()s, it's possible other skecth's code (like reading switch say) not happen @ right time. if that's likely, should start refactoring blocking delay()-based code doesn't block.
check , resolve pin , variable name clashes.
copy stuff above setup() both new sketch, or 1 other if use 1 "master", variable declarations, library includes etc.
do same stuff in setup().
and stuff in loop().
copy functions.
add code make 2 things happen in concert, ie maybe check sensor 1 program , use value invoke came other.
decide want resulting sketch do, , figure out how. if 1 uses blocking code full of delay()s, it's possible other skecth's code (like reading switch say) not happen @ right time. if that's likely, should start refactoring blocking delay()-based code doesn't block.
check , resolve pin , variable name clashes.
copy stuff above setup() both new sketch, or 1 other if use 1 "master", variable declarations, library includes etc.
do same stuff in setup().
and stuff in loop().
copy functions.
add code make 2 things happen in concert, ie maybe check sensor 1 program , use value invoke came other.
Arduino Forum > Using Arduino > Programming Questions > Coding with analog and digital inputs
arduino
Comments
Post a Comment