Los Electrofaster
Published © GPL3+

Potentiometer scale using a 7 segment display

Think about how a numerical value of a potentiometer can be represented using just one character on the 7-segment display.

BeginnerFull instructions provided1 hour4,732
Potentiometer scale using a 7 segment display

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
7 Segment LED Display, Red
7 Segment LED Display, Red
×1
Through Hole Resistor, 240 ohm
Through Hole Resistor, 240 ohm
×2
Jumper wires (generic)
Jumper wires (generic)
×12

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Circuit 3

Code

Potentiometer scale on 7segment

Arduino
int Value = 0;
const byte PIN[7] = {2,3,4,5,6,7,8}; 

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);
  }
}

void loop(){
  Value = analogRead(A0);
  for (int i=0; i<7; i++) {
    digitalWrite(PIN[i] , LOW);
  }
  int scale = map(Value, 0, 1020, 0, 8); // map function to get brihtness
    
  for (int j = 0; j < 7; j++) {
    digitalWrite(j+2, bits[scale][j]);
  }
  
  delay(100); // Wait for 100 millisecond(s)
}

Credits

Los Electrofaster

Los Electrofaster

8 projects • 7 followers

Comments