This is part 4 of the ESR Shield build for the Arduino.
In this video I discuss the Arduino code used to make this meter work. Atmel Studio and Visual Micro are shown as the IDE used.
Part 1 can be seen here. Part 2 can be seen here. Part 3 can be seen here.
Download ArduinoESRshieldV1.ino:
https://www.discoveringelectronics.com/Downloads/ArduinoESRshieldV1.zip
Watch in HD!
Hi nice work! I am building this and I am done but I have a different lcd the generic 16×2 LMB162ABC. I was wondering where i would change the code at for this one to work or how the serial code would go. I am new to coding so this is all new. Thank you for your help.
Thanks Kathy!
It is an easy conversion, but you will need to install a button on your board for the calibration function.
Below is the LCD declaration listed in the code.
// -= Using SainSmart LCD Shield =-
// LCD Pins RS, En, D4, D5, D6, D7
// Create an instance of the LiquidCrystal class and name it lcd.
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
Below I explain the format of the declaration.
The RS (Register Select) pin on your lcd is pin 4; which you will need to connect to pin 8 of the Arduino Uno.
The En (Data Enable) pin on your lcd is pin 6; which you will need to connect to pin 9 of the Arduino Uno.
The lcd will be used in the 4 bit mode which means we will use lcd pins 11 through 14 for the actual data transfer.
LCD Data Pin ———> Arduino Uno Pin
11 —————————–> 4
12 —————————–> 5
13 —————————–> 6
14 —————————–> 7
This will get your LCD working without changing the code.
Now to get the calibration button to work is no major problem. I wrote it this way anticipating people might not want to use a lcd/button shield like I did.
Below is the interrupt function that turns on a flag (bit) that the main loop checks each time around.
If you look close you will see the following line:
//calFlag = true;
All you need to do is remove the two forward slashes that uncomment this line of code and then the calibration function will be called when the button is pressed.
If you wish to disable the calibration factors display, insert two forward slashes (//) to the beginning of this line:
showCalFlag = true;
Or leave it alone and the cal factor display will toggle on and off with each press of the calibrate button.
/*
-============================ interruptESRshieldButton ============================-
This is the external interrupt handler for external interrupt 0 on digital pin 2.
This procedure was assigned to interrupt 0 in the setup routine by the
“attachInterrupt(0, interruptESRshieldButton, FALLING)” method.
This is the interrupt routine is called when the button on the ESR shield is pressed.
*/
void interruptESRshieldButton(void)
{
showCalFlag = true; // Set the show calibration values request flag.
//calFlag = true; // This can also be used to request calibration for LCD shields without buttons.
}
/* -============================ interruptESRshieldButton
============================- */