Surilli
Published © LGPL

Interfacing 7-Segment LED Display with Surilli Basic M0

Display changing voltage of an LDR on to the 7-segment display, which is a low-cost alternative to an LCD for such applications.

BeginnerFull instructions provided45 minutes250
Interfacing 7-Segment LED Display with Surilli Basic M0

Things used in this project

Hardware components

Surilli Basic
Surilli Basic
×1
Surilli 7 segment
×1
Photo resistor
Photo resistor
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Interfacing 7-segment LED display with Surilli Basic M0

Code

7_Segment_Display

C/C++
#include <AnalogInput.h>
int num_array[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, 0, 0, 1, 1 }
};   // 9
void setup()
{
// define pin modes
pinMode(A5, INPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
pinMode(A4, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
}
AnalogInput analoginput (A5, 13);//AnalogInput analoginput (InputPin, OutputPin):
char pin [] = {A1, A2, A3, A4, 10, 11, 12};
void loop()
{
//counter loop
int s = analoginput.exec();
int v = (s*5)/1023;
Num_Write(v);
SerialUSB.println(s);
SerialUSB.println(v);
delay(1000);
}
// this functions writes values to the sev seg pins
void Num_Write(int number)
{
for (int j = 0; j < 7; j++) {
  digitalWrite(pin[j], num_array[number][j]);
}
}

Credits

Surilli

Surilli

196 projects • 45 followers
Surilli is a premiere Internet of Things centric Technology Company aimed at providing cutting edge innovative solutions.

Comments