hello, i am receiving data from this device(https://tr.aliexpress.com/item/32968161253.html?spm=a2g0o.cart.0.0.5cb138da0tbu2l&mp=1&gatewayAdapt=glo2tur) with rs232 pin, but when i am printing the data at the serial monitor its just bits like this 0111-0000-0000-0000, how can i convert this bits to decimal?
here is my code:
int dataIn = 11;
int clockIn = 12;
// Variables
int clock = 1;
int lastClock = 1;
unsigned long time = 0;
unsigned long timeStart = 0;
int out = 0;
void setup() {
// Pin Set Up
pinMode(dataIn, INPUT);
pinMode(clockIn, INPUT);
Serial.begin(115200);
Serial.println("Ready: ");
}
void loop(){
lastClock = clock;
clock = digitalRead(clockIn);
if (lastClock == 1 && clock == 0){
out = digitalRead(dataIn)+digitalRead(dataIn)+digitalRead(dataIn); // Tripple sampling to remove glitches
if((micros() - time) > 800){
Serial.println(" ");
}
else if((micros() - time) > 400){
Serial.print(" ");
}
if (out > 1){
Serial.print("0");
}
else{
Serial.print("1");
}
Serial.print(",");
time = micros();
}
}