Professional Documents
Culture Documents
Lab1 JohnAzarcon 02-22-2021
Lab1 JohnAzarcon 02-22-2021
I. COMPUTATIONS
The first algorithm determines the size of array that
is to be declared.
void loop() {
Numcpy=number;
expn=1;
expset=1;
while(number>expset*2-1) {
expset*=2;
expn++;
}
The second algorithm, is where each digit of the converted Figure 1. Arduino Output when DEC=1
binary value is stored as an individual array element. (Binary=0001)
int bindigit[10]; //10 bits
void loop() {
Numcpy=number; REFERENCES
expn=1; [1] C.M . Oppus, J.Lim, Marinas J.A., Arduino
expset=1; Laboratory Manual, Quezon City: Ateneo de
Manila University, 2
while(number>expset*2-1) {
expset*=2;
expn++;
}
Serial.print(number);
Serial.print(" = ");
if(number==1024) {
number=0;