Last active
August 16, 2017 19:34
-
-
Save urmil0071/80bde147505088d20a10cff4971fc1ad to your computer and use it in GitHub Desktop.
Hex Number Multiplication
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
byte x=0; | |
char lupTable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; | |
char display[]={B111110,B111101,B111011,B110111}; | |
int x1,x2,z1,z2,z3,z4,y,y1,y2,y3,y4; | |
int shift[]={12,8,4,0}; | |
int digit[4]; | |
int ccCode[4]; | |
void setup() | |
{ | |
DDRB=B111111; | |
DDRD=0xff; | |
x1=0x24; | |
x2=0x56; | |
y=x1*x2; | |
for (int i=0;i<=3;i++) | |
{ | |
digit[i]=y>>shift[i]; | |
digit[i]=digit[i]&0x000f; | |
ccCode[i]=lupTable[digit[i]]; | |
} | |
} | |
void loop() | |
{ | |
PORTB= display[x]; | |
PORTD= ccCode[x]; | |
delay(2); | |
x++; | |
if (x>3) {x=0;} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment