Answered step by step
Verified Expert Solution
Question
1 Approved Answer
% 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started