Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How can i change this C++ code for the MBED from reading capacitance values to r

ID: 2267404 • Letter: H

Question

How can i change this C++ code for the MBED from reading capacitance values to reading resistor values. below is the code for the capacitors;

1 #include "mbed.h" 2 nclude "capSense.h" 3 #include "uLCD 4DGL.h" 6 #define RA 19770 // ohrs 7 #define RB 9053 //ohms 8 #define PERIOD 2000000 //us LO uLCD 4DGL uLCD (p9, p10, p11) lcd connection 1 CapSense cap (RA, RB, PERIOD, p21) 2 3 int main() { 4 ULCD.locate (3,5): //setting the cursor to the middle 15 L6 while (1) L7 uLCD. locate (0,6) 1setting cursor float capacitance = cap . measure(); uLCD . print f("Capacitance: sfuF ", uLCD.print f("Frequency:in%f Hz capacitance) ; 9 20 21 ", (float) cap._count/PERIOD 1000000)

Explanation / Answer

#include "mbed.h"

DigitalIn myInputPin(p5);

int main() {
myInputPin.mode(PullUp); //set the mbed to use a pullup resistor
while(1) {   
if(myInputPin.read()==1) { //a shorter way to write this is:

if(myInputPin){
//insert code to do something if the input value is 1.
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote