Question: % Now we normalize the current flex reading to a range between 0 and % 2 5 5 . Let's compare ratios ( in this
Now we normalize the current flex reading to a range between and
Let's compare ratios in this case, read reflects our ADC, and
targ reflects the RGB range This is called linear interpolation:
readVal readMinreadMax readMintargVal targMintargMax targMin
Rearranging:
targVal readVal readMinreadMax readMintargMax targMin targMin
Now let's take a reading from the flex sensor We want to ensure our
value is within the range we declared in order for our linear
interpolation to work.
flexVal nbanalogReadA;
if flexVal flexMax if flex reading is greater than maximum reading
flexVal flexMax; set to what?
elseif flexVal flexMin if flex reading is less than minimum reading
flexVal flexMin; set to what?
end
Time to linearly interpolate the RGB value from our flex reading.
rawRGB ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
