100% found this document useful (1 vote)
16 views11 pages

ARDU Watt Meter LCD 16X2

Uploaded by

smpn4 busungbiu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
16 views11 pages

ARDU Watt Meter LCD 16X2

Uploaded by

smpn4 busungbiu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

// include the library

#include <LiquidCrystal.h>

// initialize the interface pins

LiquidCrystal lcd(2,3,4,5,6,7);

int a,b,c;

long volt,current;

// the 8 arrays that form each segment of the custom numbers

byte bar1[8] =

B11100,

B11110,

B11110,

B11110,

B11110,

B11110,

B11110,

B11100

};

byte bar2[8] =

B00111,

B01111,

B01111,

B01111,

B01111,

B01111,

B01111,
B00111

};

byte bar3[8] =

B11111,

B11111,

B00000,

B00000,

B00000,

B00000,

B11111,

B11111

};

byte bar4[8] =

B11110,

B11100,

B00000,

B00000,

B00000,

B00000,

B11000,

B11100

};

byte bar5[8] =

B01111,

B00111,

B00000,
B00000,

B00000,

B00000,

B00011,

B00111

};

byte bar6[8] =

B00000,

B00000,

B00000,

B00000,

B00000,

B00000,

B11111,

B11111

};

byte bar7[8] =

B00000,

B00000,

B00000,

B00000,

B00000,

B00000,

B00111,

B01111

};

byte bar8[8] =
{

B11111,

B11111,

B00000,

B00000,

B00000,

B00000,

B00000,

B00000

};

void setup()

// assignes each segment a write number

lcd.createChar(1,bar1);

lcd.createChar(2,bar2);

lcd.createChar(3,bar3);

lcd.createChar(4,bar4);

lcd.createChar(5,bar5);

lcd.createChar(6,bar6);

lcd.createChar(7,bar7);

lcd.createChar(8,bar8);

// sets the LCD's rows and colums:

lcd.begin(16, 2);

Serial.begin(9600);

}
void custom0(int col)

{ // uses segments to build the number 0

lcd.setCursor(col, 0);

lcd.write(2);

lcd.write(8);

lcd.write(1);

lcd.setCursor(col, 1);

lcd.write(2);

lcd.write(6);

lcd.write(1);

void custom1(int col)

lcd.setCursor(col,0);

lcd.write(32);

lcd.write(32);

lcd.write(1);

lcd.setCursor(col,1);

lcd.write(32);

lcd.write(32);

lcd.write(1);

void custom2(int col)

lcd.setCursor(col,0);

lcd.write(5);
lcd.write(3);

lcd.write(1);

lcd.setCursor(col, 1);

lcd.write(2);

lcd.write(6);

lcd.write(6);

void custom3(int col)

lcd.setCursor(col,0);

lcd.write(5);

lcd.write(3);

lcd.write(1);

lcd.setCursor(col, 1);

lcd.write(7);

lcd.write(6);

lcd.write(1);

void custom4(int col)

lcd.setCursor(col,0);

lcd.write(2);

lcd.write(6);

lcd.write(1);

lcd.setCursor(col, 1);

lcd.write(32);

lcd.write(32);
lcd.write(1);

void custom5(int col)

lcd.setCursor(col,0);

lcd.write(2);

lcd.write(3);

lcd.write(4);

lcd.setCursor(col, 1);

lcd.write(7);

lcd.write(6);

lcd.write(1);

void custom6(int col)

lcd.setCursor(col,0);

lcd.write(2);

lcd.write(3);

lcd.write(4);

lcd.setCursor(col, 1);

lcd.write(2);

lcd.write(6);

lcd.write(1);

void custom7(int col)

{
lcd.setCursor(col,0);

lcd.write(2);

lcd.write(8);

lcd.write(1);

lcd.setCursor(col, 1);

lcd.write(32);

lcd.write(32);

lcd.write(1);

void custom8(int col)

lcd.setCursor(col, 0);

lcd.write(2);

lcd.write(3);

lcd.write(1);

lcd.setCursor(col, 1);

lcd.write(2);

lcd.write(6);

lcd.write(1);

void custom9(int col)

lcd.setCursor(col, 0);

lcd.write(2);

lcd.write(3);

lcd.write(1);

lcd.setCursor(col, 1);
lcd.write(7);

lcd.write(6);

lcd.write(1);

void printNumber(int value, int col) {

if (value == 0) {

custom0(col);

} if (value == 1) {

custom1(col);

} if (value == 2) {

custom2(col);

} if (value == 3) {

custom3(col);

} if (value == 4) {

custom4(col);

} if (value == 5) {

custom5(col);

} if (value == 6) {

custom6(col);

} if (value == 7) {

custom7(col);

} if (value == 8) {

custom8(col);

} if (value == 9) {

custom9(col);

}
void loop()

for(int i=0;i<200;i++){

c = analogRead(A1);

a = analogRead(A0);

volt=volt+a;

current=current+c;

delay(1);

current=(current/200-514);

if(current<1)current=0;

current=current*15;

volt=volt/30;

Serial.print(volt);

Serial.print(" ");

Serial.println(current);
b=(volt/10)%10;

lcd.setCursor(7,1);

lcd.print(b);

b=(volt/100)%10;

printNumber(b, 3);

b=(volt/1000)%10;

printNumber(b, 0);

lcd.setCursor(8,1);

lcd.print("V");

lcd.setCursor(6,1);

lcd.print(".");

b=current%10;

lcd.setCursor(14,1);

lcd.print(b);

b=(current/10)%10;

lcd.setCursor(13,1);

lcd.print(b);

b=(current/100)%10;

printNumber(b, 9);

lcd.setCursor(12,1);

lcd.print(".");

lcd.setCursor(15,1);

lcd.print("A");

delay(100);

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy