How To POT With LCD

Required Hardware
For users who do not have Hackerspace Karachi Arduino Kit v1.0
- Arduino Board
- Breadboard
- L293D
- POT
- Hook-up Wires
Circuit
For users who do not have Hackerspace Karachi Arduino Kit v1.0
Schematic
Code
1. /*
2. POT with LCD
3.
4. This example shows how to use POT with LCD.
5.
6. The circuit:
7. – LCD
8. SDA connected to analog pin A4.
9. SCL connected to analog pin A5.
10. – POT
11. Anode connected to 5v.
12. Signal/Viper connected to analog pin A2.
13. Cathode connected to Ground.
14.
15. http://hackerspacekarachi.org/
16. */
17. //Library version:1.1
18. #include <Wire.h>
19. #include <LiquidCrystal_I2C.h>
20.
21. LiquidCrystal_I2C lcd(0x27, 20, 4); // set the LCD address to 0x27 for a 16 chars and 2
line display
22. #define potPin A2 // POT connected to analog pin A2
23.
24. void setup()
25. {
26. lcd.init(); // initialize the lcd
27. lcd.init();
28. lcd.backlight();
29.
30. }
31.
32.
33. void loop()
34. {
35. int potValue = analogRead(potPin); // read analogue value from
potentiometer (0 ~ 1023)
36.
37. lcd.setCursor(0, 1);
38. lcd.print(“POT Value”);
39. lcd.setCursor(10, 1);
40. lcd.print(potValue);
41. delay (1000);
42. lcd.clear();
43.
44. }