LEFT RIGHT SELECT LCD 16×2 keypad Shield GND
Expert Answer
Connection:
Red: 5V
Black: GND
Blue: Analog in pin (A2 in our case)
const int analogInPin = A2; // Analog input pin that the sensor is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 14);
// change the analog out value:
analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
Serial.print(“sensor = ” );
Serial.print(sensorValue);
Serial.print(“t output = “);
Serial.println(analogRead(2)* 14.0 / 1024, 1);
// wait 10 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(500);
}
For LCD, all ypu ned is to place the module on the top of Uno board. The pins are all alligned and will be placed properly.As said use the “liquidcristal.h” library to make the LCD work.
Example code
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(“Chegg Rocks!”);
}
void loop() {
// Turn off the display:
lcd.noDisplay();
delay(1000);
// Turn on the display:
lcd.display();
delay(1000);
}