Testing the LCD screen

Before we build our EMF bug detector, we want to make sure that the LCD screen is working correctly. Therefore, we are going to test it by printing a very simple message on it.

The following is a complete sketch to do this:

// Required libraries
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Create LCD instance
LiquidCrystal_I2C lcd(0x27,20,4);

void setup()
{
  // Initialise LCD
  lcd.init();
 
  // Print a message to the LCD
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("Hello Secret Agent!");
}


void loop()
{
}

As you can see, the sketch is pretty straightforward. You can now plug the Arduino project into your computer using a USB cable and then copy and paste the sketch into your Arduino IDE.

Then, upload the sketch to your board. This is what you should see:

Testing the LCD screen

If you can see this message, congratulations, you are ready to move to the next step!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.208.97