• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Arduino: Display Potentiometer Readings on 7 Segment LED Display

By Abhishek Ghosh July 4, 2023 9:44 am Updated on July 4, 2023

Arduino: Display Potentiometer Readings on 7 Segment LED Display

Advertisement

There are various practical needs to output the value of a potentiometer on a digit 7-segment display without making it super complicated. Things such as an audio player require a display of the audio control knob by using some sort of logic with this kind of project.

In our earlier articles, we have discussed about PWM and control of a line of LED with potentiometer. Both of those articles are important since this guide is dependent on them. It is also possible to combine both if we use TM1637 4 digit 7 segment display module.

 

By Using a Single 7-Segment LED Display

 

If you want a one-digit display which shows zero to nine upon rotating the potentiometer knob like this project:

Advertisement

---

Arduino Display Potentiometer Readings on 7 Segment LED Display

You can emulate this on TinkerCAD:

The sketch is super easy if you have understood the previous project with 12 LEDs and a potentiometer:

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
int Value = 0;
const byte PIN[7] = {2,3,4,5,6,7,8};
int salva[3] = {0,0,0};
int bits[10][7] = {{ 1, 1, 1, 1, 1, 1, 0 },  // 0
  { 0, 1, 1, 0, 0, 0, 0 },  // 1
  { 1, 1, 0, 1, 1, 0, 1 },  // 2
  { 1, 1, 1, 1, 0, 0, 1 },  // 3
  { 0, 1, 1, 0, 0, 1, 1 },  // 4
  { 1, 0, 1, 1, 0, 1, 1 },  // 5
  { 1, 0, 1, 1, 1, 1, 1 },  // 6
  { 1, 1, 1, 0, 0, 0, 0 },  // 7
  { 1, 1, 1, 1, 1, 1, 1 },  // 8
  { 1, 1, 1, 1, 0, 1, 1 }   // 9
};
void setup(){
  for (int i=0; i<7; i++) {
    pinMode (PIN[i], OUTPUT);
  }
  pinMode(12, OUTPUT);
}
 
void loop(){
  Value = analogRead(A0);
  for (int i=0; i<8; i++) {
    digitalWrite(PIN[i] , LOW);
  }
  int scale = map(Value, 0, 1020, 0, 9); // map function to get brihtness
    
  for (int j = 0; j < 8; j++) {
    digitalWrite(j+2, bits[scale][j]);
  
    
  }
  
  delay(100); // Wait for 100 millisecond(s)
}

 

By Using TM1637 4 digit 7 Segment Display Module

 

This is easier with the wiring part. Connect CLK of TM1637 to pin 2 of Arduino, connect DIO of TM1637
to pin 3 of Arduino, connect Vcc to 5v, GND to GND, connect DIO of TM1637
to pin 3 of Arduino, connect the middle pin of the potentiometer to A0 of Arduino UNO.

This sketch will display zero to 1023 upon rotating the potentiometer knob:

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <Arduino.h>
#include <TM1637Display.h>
#define CLK 2
#define DIO 3
TM1637Display display(CLK, DIO);
 
void setup() {
 
}
 
void loop() {
  display.setBrightness(0x0f);
  display.clear();
  uint8_t data[] = { 0x00, 0x00, 0x00, 0x00 };
  int value = analogRead(A0); // read of potentiometer value
  String texto = String(value);
  if (value > 999){
    data[0] = display.encodeDigit(texto[0]);
    data[1] = display.encodeDigit(texto[1]);
    data[2] = display.encodeDigit(texto[2]);
    data[3] = display.encodeDigit(texto[3]);
  } else if (value > 99){
    data[1] = display.encodeDigit(texto[0]);
    data[2] = display.encodeDigit(texto[1]);
    data[3] = display.encodeDigit(texto[2]);
  } else if (value > 9){
    data[2] = display.encodeDigit(texto[0]);
    data[3] = display.encodeDigit(texto[1]);
  } else {
    data[3] = display.encodeDigit(texto[0]);
  }
  display.setSegments(data);
 
  delay(100);
}

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Arduino: Display Potentiometer Readings on 7 Segment LED Display

  • 7 Segment LED Display Tutorial For Dummies

    Here is Step By Step 7 Segment LED Display Tutorial For Dummies On How To Light Up With Battery To Control With Arduino Without Library.

  • Arduino 14 Segment LED Display : Driver IC & Library

    Here is Information About Arduino 14 Segment LED Display Driver IC & Library. As it is less used component for higher price, possibly you have build module yourself.

  • Arduino 7 Segment LED Display Tutorial (TM1637 4 Digit)

    Here is Detailed Arduino 7 Segment LED Display Tutorial For the Beginners With Example Codes, Circuit Diagram Which Uses TM1637, Has 4 Digit.

  • Arduino 8 Digit 7 Segment LED Display Buying Guide

    Here Is Arduino 8 Digit 7 Segment LED Display Buying Guide. These Are Driven By MAX7219/MAX7221 Driver Which Supports LED Dot Matrix Too.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy