Project 10 - A Digital Voltmeter

<< Click to Display Table of Contents >>

Navigation:  Projects >

Project 10 - A Digital Voltmeter

This project displays a Rotary Pot IO reading using the seven segment font.

 

 

Component(s)

 

This project uses the following component(s) -

 

Rotary Pot IO

 

 

Wiring Diagram

 

 

Project 10-Digital Voltmeter

 

 

Code

 

In the Setup() routine, it loads the seven segment font and stores its handle into the font variable. Here is the sample code snippet -

 

int16_t font;

void setup()

{

CleO.begin();

font = CleO.LoadFont("@Fonts/DSEG7ClassicMini-BoldItalic.ftfont");

}

 

The loop() routine reads the value from the analog pin A0 and rescales it between 0 to 5000. It then prepares the string buffer using this value and draws on screen using the StringExt() command. Here is the code snippet -
 

void loop() {

 int analog = analogRead(0);     // sample analog pin A0

                          // CleO IO - Rotary Pot connects to CN11

 int mv = 5000L * analog / 1023; // rescale to milli-volts, 0-5000

 char buf[9];

 

 sprintf(buf, "%d. %03d", mv / 1000, mv % 1000);

 CleO.Start();

 CleO.StringExt(font, 160, 240, LED_RED, MM, 0, 0, buf);

 CleO.Show();

}

 

 

Output

 

 

Project 10 - A Digital Voltmeter