Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Arduino.h"
- #include "FOURDIGITS.h"
- FOURDIGITS::FOURDIGITS(){}
- void FOURDIGITS::digitInit(uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4);{
- Id1=d1;
- Id2=d2;
- Id3=d3;
- Id4=d4;
- pinMode(id1,OUTPUT);
- pinMode(id2,OUTPUT);
- pinMode(id3,OUTPUT);
- pinMode(id4,OUTPUT);
- }
- void FOURDIGITS::segmentInit(uint8_t lA, uint8_t lB, uint8_t lC, uint8_t lD, uint8_t lE, uint8_t lF, uint8_t lG, uint8_t lDP){
- ilA=lA;
- ilB=lB;
- ilC=lC;
- ilD=lD;
- ilE=lE;
- ilF=lF;
- ilG=lG;
- ilDP=lDP;
- pinMode(ilA,OUTPUT);
- pinMode(ilB,OUTPUT);
- pinMode(ilC,OUTPUT);
- pinMode(ilD,OUTPUT);
- pinMode(ilE,OUTPUT);
- pinMode(ilF,OUTPUT);
- pinMode(ilG,OUTPUT);
- pinMode(ilDP,OUTPUT);
- }
- void FORDIGITS::reset(){
- digitalWrite(Id1, HIGH);
- digitalWrite(Id2, HIGH);
- digitalWrite(Id3, HIGH);
- digitalWrite(Id4, HIGH);
- digitalWrite(ilA,LOW);
- digitalWrite(ilB,LOW);
- digitalWrite(ilC,LOW);
- digitalWrite(ilD,LOW);
- digitalWrite(ilE,LOW);
- digitalWrite(ilF,LOW);
- digitalWrite(ilG,LOW);
- digitalWrite(ilDP,LOW);
- }
- void FOURDIGITS::dPoint(uint8_t digit2){
- if(digit==1){digitalWrite(Id1, LOW);}
- if(digit==2){digitalWrite(Id2, LOW);}
- if(digit==3){digitalWrite(Id3, LOW);}
- if(digit==4){digitalWrite(Id4, LOW);}
- digitalWrite(ilDP, HIGH);
- }
- void FOURDIGITS::swrite(int digit, int num){
- reset();
- if(digit==1){digitalWrite(Id1, LOW);}
- if(digit==2){digitalWrite(Id2, LOW);}
- if(digit==3){digitalWrite(Id3, LOW);}
- if(digit==4){digitalWrite(Id4, LOW);}
- if(num==0){
- digitalWrite(ilA,HIGH);
- digitalWrite(ilB,HIGH);
- digitalWrite(ilC,HIGH);
- digitalWrite(ilD,HIGH);
- digitalWrite(ilE,HIGH);
- digitalWrite(ilF,HIGH);
- digitalWrite(ilG,LOW);
- }
- if(num==1){
- digitalWrite(ilA,LOW);
- digitalWrite(ilB,HIGH);
- digitalWrite(ilC,HIGH);
- digitalWrite(ilD,LOW);
- digitalWrite(ilE,LOW);
- digitalWrite(ilF,LOW);
- digitalWrite(ilG,LOW);
- }
- if(num==2){
- digitalWrite(ilA,HIGH);
- digitalWrite(ilB,HIGH);
- digitalWrite(ilC,LOW);
- digitalWrite(ilD,HIGH);
- digitalWrite(ilE,HIGH);
- digitalWrite(ilF,LOW);
- digitalWrite(ilG,HIGH);
- }
- if(num==3){
- digitalWrite(ilA,HIGH);
- digitalWrite(ilB,HIGH);
- digitalWrite(ilC,HIGH);
- digitalWrite(ilD,HIGH);
- digitalWrite(ilE,LOW);
- digitalWrite(ilF,LOW);
- digitalWrite(ilG,HIGH);
- }
- if(num==4){
- digitalWrite(ilA,LOW);
- digitalWrite(ilB,HIGH);
- digitalWrite(ilC,HIGH);
- digitalWrite(ilD,LOW);
- digitalWrite(ilE,LOW);
- digitalWrite(ilF,HIGH);
- digitalWrite(ilG,HIGH);
- }
- if(num==5){
- digitalWrite(ilA,HIGH);
- digitalWrite(ilB,LOW);
- digitalWrite(ilC,HIGH);
- digitalWrite(ilD,HIGH);
- digitalWrite(ilE,LOW);
- digitalWrite(ilF,HIGH);
- digitalWrite(ilG,HIGH);
- }
- if(num==6){
- digitalWrite(ilA,HIGH);
- digitalWrite(ilB,LOW);
- digitalWrite(ilC,HIGH);
- digitalWrite(ilD,HIGH);
- digitalWrite(ilE,HIGH);
- digitalWrite(ilF,HIGH);
- digitalWrite(ilG,HIGH);
- }
- if(num==7){
- digitalWrite(ilA,HIGH);
- digitalWrite(ilB,HIGH);
- digitalWrite(ilC,HIGH);
- digitalWrite(ilD,LOW);
- digitalWrite(ilE,LOW);
- digitalWrite(ilF,HIGH);
- digitalWrite(ilG,LOW);
- }
- if(num==8){
- digitalWrite(ilA,HIGH);
- digitalWrite(ilB,HIGH);
- digitalWrite(ilC,HIGH);
- digitalWrite(ilD,HIGH);
- digitalWrite(ilE,HIGH);
- digitalWrite(ilF,HIGH);
- digitalWrite(ilG,HIGH);
- }
- if(num==9){
- digitalWrite(ilA,HIGH);
- digitalWrite(ilB,HIGH);
- digitalWrite(ilC,HIGH);
- digitalWrite(ilD,HIGH);
- digitalWrite(ilE,LOW);
- digitalWrite(ilF,HIGH);
- digitalWrite(ilG,HIGH);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment