SlideShare a Scribd company logo
int latchPin = 13;//ST_CP 
int clockPin = 12;//SH_CP 
int dataPin = 11; //DS 
// define latch, clock and datapin 
void setup () 
{ 
pinMode(latchPin,OUTPUT); 
pinMode(clockPin,OUTPUT); 
pinMode(dataPin,OUTPUT); 
//set these three pins to output 
} 
//Display function (display word, display position, display if have 
//decimal point) 
void disNum(int Num_Qua, int Num_Pos, int Num_Dec) 
{ 
int Num_Qua_B = 0; 
int Num_Pos_B = 0; 
switch (Num_Qua) 
{ 
case 0:Num_Qua_B = 192;break; 
case 1:Num_Qua_B = 249;break; 
case 2:Num_Qua_B = 164;break; 
case 3:Num_Qua_B = 176;break; 
case 4:Num_Qua_B = 153;break; 
case 5:Num_Qua_B = 146;break; 
case 6:Num_Qua_B = 130;break; 
case 7:Num_Qua_B = 248;break;
case 8:Num_Qua_B = 128;break; 
case 9:Num_Qua_B = 144;break; 
default: Num_Qua_B = 255;break; 
}; 
//this value convert to binary, which is adcdefg need to light up 
switch (Num_Pos) 
{ 
case 1:Num_Pos_B = 1;break; 
case 2:Num_Pos_B = 2;break; 
case 3:Num_Pos_B = 4;break; 
case 4:Num_Pos_B = 8;break; 
case 5:Num_Pos_B = 16;break; 
case 6:Num_Pos_B = 32;break; 
case 7:Num_Pos_B = 64;break; 
case 8:Num_Pos_B = 128;break; 
default: Num_Pos_B = 0;break; 
}; 
//this value convert to binary, which is the one light up now. 
if (Num_Dec == 1) 
{ 
Num_Qua_B = Num_Qua_B + 128; 
}; 
//======================================== 
digitalWrite(latchPin,LOW); 
// set latch to low tolet the display ready to receive data 
int L = Num_Qua_B; int R = Num_Pos_B; 
shiftOut(dataPin,clockPin,MSBFIRST,R); 
shiftOut(dataPin,clockPin,MSBFIRST,L);
digitalWrite(latchPin,HIGH); //restore to high TTL back 
//======================================== 
delayMicroseconds(100); 
} 
//this is the display number function 
void showNum(double number) 
// use double instead of int, int is not longer enough 
{ 
long num = number; 
int ShowDec [8]; 
for (int x = 1; x < 9; x++) 
{ 
ShowDec [x] = 0; 
} 
//creat the array for decimal point, 0 is not to display, 1 is to display 
if (num < 10000000){ 
if (num < 1000000){num = number*100; ShowDec[6]=1;ShowDec[7]=0;} 
else{ 
num = number*10; ShowDec[7]=1; 
} 
} 
//simple decimal point for two number display 
int ShowNumber [8]; 
ShowNumber[1] = (num/10000000)%10; 
ShowNumber[2]= (num/1000000)%10;
ShowNumber[3] = (num/100000)%10; 
ShowNumber[4] = (num/10000)%10; 
ShowNumber[5] = (num/1000)%10; 
ShowNumber[6] = (num/100)%10; 
ShowNumber[7] = (num/10)%10; 
ShowNumber[8]= (num/1)%10; 
//get every number and store in the arrary 
int dectest = 0; 
for (int x = 1; x<8; x++) 
{ 
if ((dectest == 0)and(ShowNumber[x] == 0)) 
{ 
ShowNumber[x] = 11; 
} 
else 
{ 
dectest = 1; 
} 
} 
//check if there is a "0" on the left front, if yes we ignore it 
disNum(ShowNumber[1],1,ShowDec[1]); 
disNum(ShowNumber[2],2,ShowDec[2]); 
disNum(ShowNumber[3],3,ShowDec[3]); 
disNum(ShowNumber[4],4,ShowDec[4]);
disNum(ShowNumber[5],5,ShowDec[5]); 
disNum(ShowNumber[6],6,ShowDec[6]); 
disNum(ShowNumber[7],7,ShowDec[7]); 
disNum(ShowNumber[8],8,ShowDec[8]); 
//display number in sequency, flashing fast 
} 
void loop() 
{ 
showNum(80600000);//simple function to display to number 
}

More Related Content

What's hot (20)

PDF
C++ Programming - 3rd Study
Chris Ohk
 
PDF
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
Wataru Kani
 
PDF
C++ Programming - 1st Study
Chris Ohk
 
PDF
第一回 冬のスイッチ大勉強会 - XBee編 -
Wataru Kani
 
DOC
Infix to-postfix examples
mua99
 
DOC
C tech questions
vijay00791
 
PPT
Questions typedef and macros
Mohammed Sikander
 
PDF
C++ Question on References and Function Overloading
mohamed sikander
 
TXT
Langrange method for MATLAB Code
Taimoor Muzaffar Gondal
 
PPTX
The Moore-Spiegel Oscillator
Abhranil Das
 
PDF
C++ TUTORIAL 6
Farhan Ab Rahman
 
PPTX
Teeing Up Python - Code Golf
Yelp Engineering
 
PDF
Activity Recognition Through Complex Event Processing: First Findings
Sylvain Hallé
 
PPSX
C programming pointer
argusacademy
 
PPT
C++ programming
Abdallah Abuouf
 
PDF
CS50 Lecture3
昀 李
 
PDF
Nesting of for loops using C++
prashant_sainii
 
DOCX
C interview question answer 2
Amit Kapoor
 
C++ Programming - 3rd Study
Chris Ohk
 
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
Wataru Kani
 
C++ Programming - 1st Study
Chris Ohk
 
第一回 冬のスイッチ大勉強会 - XBee編 -
Wataru Kani
 
Infix to-postfix examples
mua99
 
C tech questions
vijay00791
 
Questions typedef and macros
Mohammed Sikander
 
C++ Question on References and Function Overloading
mohamed sikander
 
Langrange method for MATLAB Code
Taimoor Muzaffar Gondal
 
The Moore-Spiegel Oscillator
Abhranil Das
 
C++ TUTORIAL 6
Farhan Ab Rahman
 
Teeing Up Python - Code Golf
Yelp Engineering
 
Activity Recognition Through Complex Event Processing: First Findings
Sylvain Hallé
 
C programming pointer
argusacademy
 
C++ programming
Abdallah Abuouf
 
CS50 Lecture3
昀 李
 
Nesting of for loops using C++
prashant_sainii
 
C interview question answer 2
Amit Kapoor
 

Viewers also liked (14)

PDF
Carta Universal Derechos Humanos
Alex Vogager
 
PDF
Crisis in mexico Enrique Peña Nieto, and mexico's infrarrealistas
Alex Vogager
 
PDF
Desapariciones Forzadas Reporte HRW México
Alex Vogager
 
PPTX
Riset pandangan pengguna iOS terhadap cydia jailbreak
Research Assistant - Statistical Modeling on Apps
 
PDF
البحث النهائي لمبادئ التكوين
YEMENI JORDANIAN UNIVERSITY
 
PDF
Apresentaoodicialm 140918223638-phpapp02
Sergio Silva
 
PDF
計数感覚養成講座紹介パワポ
sasataku_0929
 
PPTX
Elisa tunnistus
Petteri Ihalainen
 
PPTX
計数感覚養成講座紹介パワポ
sasataku_0929
 
PDF
Lcr 800 user manual (1)
Slim Abid
 
PPTX
Research study on dyslexia provision in the European workplace
Jan Halfpenny MEd
 
PPTX
Dyslexia Plus - 3 common processing differences that commonly occur with dysl...
Jan Halfpenny MEd
 
PPT
United Aquafarm Ventures Empire Franchise Package
United Aquafarm Ventures Inc.
 
PPT
Mat.sunum 1
gencnurhayat
 
Carta Universal Derechos Humanos
Alex Vogager
 
Crisis in mexico Enrique Peña Nieto, and mexico's infrarrealistas
Alex Vogager
 
Desapariciones Forzadas Reporte HRW México
Alex Vogager
 
Riset pandangan pengguna iOS terhadap cydia jailbreak
Research Assistant - Statistical Modeling on Apps
 
البحث النهائي لمبادئ التكوين
YEMENI JORDANIAN UNIVERSITY
 
Apresentaoodicialm 140918223638-phpapp02
Sergio Silva
 
計数感覚養成講座紹介パワポ
sasataku_0929
 
Elisa tunnistus
Petteri Ihalainen
 
計数感覚養成講座紹介パワポ
sasataku_0929
 
Lcr 800 user manual (1)
Slim Abid
 
Research study on dyslexia provision in the European workplace
Jan Halfpenny MEd
 
Dyslexia Plus - 3 common processing differences that commonly occur with dysl...
Jan Halfpenny MEd
 
United Aquafarm Ventures Empire Franchise Package
United Aquafarm Ventures Inc.
 
Mat.sunum 1
gencnurhayat
 
Ad

Similar to 7segment scetch (20)

PPTX
R tist
Atul Uttam
 
DOCX
Microcontroladores: programas de CCS Compiler.docx
SANTIAGO PABLO ALBERTO
 
PDF
Arduino uno basic Experiments for beginner
YogeshJatav7
 
DOCX
EJERCICIOS DE BORLAND C++ 2DA PARTE.docx
leovasquez17
 
DOCX
EJERCICIOS DE BORLAND C++ 2DA PARTE.docx
leovasquez17
 
PDF
sodapdf-converted into ppt presentation(1).pdf
MuhammadMaazShaik
 
DOCX
#include IRremote.hint RECV_PIN = 19;const int timer = 600.docx
katherncarlyle
 
PDF
The IoT Academy IoT Training Arduino Part 3 programming
The IOT Academy
 
DOC
Arduino based keyboard and display interfacing
Akash1900
 
PDF
Code
Bilal Atie
 
PPT
DataTypes.ppt
RithikRaj25
 
PDF
C++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdf
andreaplotner1
 
PPT
Lập trình C
Viet NguyenHoang
 
DOCX
Program flowchart
Sowri Rajan
 
PDF
C++ normal assignments by maharshi_jd.pdf
maharshi1731
 
PDF
Please use the code below and make it operate as one program- Notating.pdf
seoagam1
 
PDF
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
Demetrio Siragusa
 
PPT
Paradigmas de Linguagens de Programacao - Aula #4
Ismar Silveira
 
PDF
I am try to create a program that takes a user typed MIPS instructio.pdf
allystraders
 
PDF
Arduino Workshop 2011.05.31
Shigeru Kobayashi
 
R tist
Atul Uttam
 
Microcontroladores: programas de CCS Compiler.docx
SANTIAGO PABLO ALBERTO
 
Arduino uno basic Experiments for beginner
YogeshJatav7
 
EJERCICIOS DE BORLAND C++ 2DA PARTE.docx
leovasquez17
 
EJERCICIOS DE BORLAND C++ 2DA PARTE.docx
leovasquez17
 
sodapdf-converted into ppt presentation(1).pdf
MuhammadMaazShaik
 
#include IRremote.hint RECV_PIN = 19;const int timer = 600.docx
katherncarlyle
 
The IoT Academy IoT Training Arduino Part 3 programming
The IOT Academy
 
Arduino based keyboard and display interfacing
Akash1900
 
DataTypes.ppt
RithikRaj25
 
C++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdf
andreaplotner1
 
Lập trình C
Viet NguyenHoang
 
Program flowchart
Sowri Rajan
 
C++ normal assignments by maharshi_jd.pdf
maharshi1731
 
Please use the code below and make it operate as one program- Notating.pdf
seoagam1
 
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
Demetrio Siragusa
 
Paradigmas de Linguagens de Programacao - Aula #4
Ismar Silveira
 
I am try to create a program that takes a user typed MIPS instructio.pdf
allystraders
 
Arduino Workshop 2011.05.31
Shigeru Kobayashi
 
Ad

Recently uploaded (20)

PDF
July Patch Tuesday
Ivanti
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
PPTX
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
PDF
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
PPTX
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
PPTX
Top Managed Service Providers in Los Angeles
Captain IT
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
July Patch Tuesday
Ivanti
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
Top Managed Service Providers in Los Angeles
Captain IT
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 

7segment scetch

  • 1. int latchPin = 13;//ST_CP int clockPin = 12;//SH_CP int dataPin = 11; //DS // define latch, clock and datapin void setup () { pinMode(latchPin,OUTPUT); pinMode(clockPin,OUTPUT); pinMode(dataPin,OUTPUT); //set these three pins to output } //Display function (display word, display position, display if have //decimal point) void disNum(int Num_Qua, int Num_Pos, int Num_Dec) { int Num_Qua_B = 0; int Num_Pos_B = 0; switch (Num_Qua) { case 0:Num_Qua_B = 192;break; case 1:Num_Qua_B = 249;break; case 2:Num_Qua_B = 164;break; case 3:Num_Qua_B = 176;break; case 4:Num_Qua_B = 153;break; case 5:Num_Qua_B = 146;break; case 6:Num_Qua_B = 130;break; case 7:Num_Qua_B = 248;break;
  • 2. case 8:Num_Qua_B = 128;break; case 9:Num_Qua_B = 144;break; default: Num_Qua_B = 255;break; }; //this value convert to binary, which is adcdefg need to light up switch (Num_Pos) { case 1:Num_Pos_B = 1;break; case 2:Num_Pos_B = 2;break; case 3:Num_Pos_B = 4;break; case 4:Num_Pos_B = 8;break; case 5:Num_Pos_B = 16;break; case 6:Num_Pos_B = 32;break; case 7:Num_Pos_B = 64;break; case 8:Num_Pos_B = 128;break; default: Num_Pos_B = 0;break; }; //this value convert to binary, which is the one light up now. if (Num_Dec == 1) { Num_Qua_B = Num_Qua_B + 128; }; //======================================== digitalWrite(latchPin,LOW); // set latch to low tolet the display ready to receive data int L = Num_Qua_B; int R = Num_Pos_B; shiftOut(dataPin,clockPin,MSBFIRST,R); shiftOut(dataPin,clockPin,MSBFIRST,L);
  • 3. digitalWrite(latchPin,HIGH); //restore to high TTL back //======================================== delayMicroseconds(100); } //this is the display number function void showNum(double number) // use double instead of int, int is not longer enough { long num = number; int ShowDec [8]; for (int x = 1; x < 9; x++) { ShowDec [x] = 0; } //creat the array for decimal point, 0 is not to display, 1 is to display if (num < 10000000){ if (num < 1000000){num = number*100; ShowDec[6]=1;ShowDec[7]=0;} else{ num = number*10; ShowDec[7]=1; } } //simple decimal point for two number display int ShowNumber [8]; ShowNumber[1] = (num/10000000)%10; ShowNumber[2]= (num/1000000)%10;
  • 4. ShowNumber[3] = (num/100000)%10; ShowNumber[4] = (num/10000)%10; ShowNumber[5] = (num/1000)%10; ShowNumber[6] = (num/100)%10; ShowNumber[7] = (num/10)%10; ShowNumber[8]= (num/1)%10; //get every number and store in the arrary int dectest = 0; for (int x = 1; x<8; x++) { if ((dectest == 0)and(ShowNumber[x] == 0)) { ShowNumber[x] = 11; } else { dectest = 1; } } //check if there is a "0" on the left front, if yes we ignore it disNum(ShowNumber[1],1,ShowDec[1]); disNum(ShowNumber[2],2,ShowDec[2]); disNum(ShowNumber[3],3,ShowDec[3]); disNum(ShowNumber[4],4,ShowDec[4]);
  • 5. disNum(ShowNumber[5],5,ShowDec[5]); disNum(ShowNumber[6],6,ShowDec[6]); disNum(ShowNumber[7],7,ShowDec[7]); disNum(ShowNumber[8],8,ShowDec[8]); //display number in sequency, flashing fast } void loop() { showNum(80600000);//simple function to display to number }