You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

96 lines
2.1 KiB

#define HZin 4
uint32_t hzhigh[20];
uint32_t hzlow[20] ;
uint8_t x = 0;
void setup() {
// put your setup code here, to run once:
pinMode(HZin, INPUT);
Serial.begin(116200);
}
void loop() {
// put your main code here, to run repeatedly:
//if (val = pulsein < 2000) then do low, then high again
//else goto end
/*if((hzhigh[x] = pulseInLong(HZin, HIGH, 1000000UL)) < 2000){
x++
hzlow[x] = pulseInLong( HZin, HIGH, 1000000UL);
}*/
//if pulse high don't care
//if pulse low, do stuff{
// whilepulse low, time,
// while pulse high time,
// etc...
//if pulse high greater than 3ms, end
//the below is not usable
//apparently setup time is too long
if((hzlow[x] = pulseInLong(HZin,LOW, 2000000UL))){
//while(hzhigh[x] < 2000){
x++;
hzhigh[x] = pulseInLong(HZin,HIGH,2000000UL);
x++;
hzlow[x] = pulseInLong(HZin,LOW, 2000000UL);
x++;
hzhigh[x] = pulseInLong(HZin,HIGH,2000000UL);
x++;
hzlow[x] = pulseInLong(HZin,LOW, 2000000UL);
x++;
hzhigh[x] = pulseInLong(HZin,HIGH,2000000UL);
x++;
hzlow[x] = pulseInLong(HZin,LOW, 2000000UL);
x++;
hzhigh[x] = pulseInLong(HZin,HIGH,2000000UL);
x++;
hzlow[x] = pulseInLong(HZin,LOW, 2000000UL);
x++;
hzhigh[x] = pulseInLong(HZin,HIGH,2000000UL);
x++;
hzlow[x] = pulseInLong(HZin,LOW, 2000000UL);
x++;
hzhigh[x] = pulseInLong(HZin,HIGH,2000000UL);
x++;
hzlow[x] = pulseInLong(HZin,LOW, 2000000UL);
x++;
hzhigh[x] = pulseInLong(HZin,HIGH,2000000UL);
x++;
hzlow[x] = pulseInLong(HZin,LOW, 2000000UL);
}
/*
for(x=0;hzhigh[x]<2000;x++){
hzhigh[x] = pulseInLong( HZin, HIGH, 2000000UL);
hzlow[x] = pulseInLong( HZin, LOW, 2000000UL);
//hzhigh[x] = pulseInLong( HZin, HIGH, 2000000UL);
}
for(x=0;x<10;x++){
hzhigh[x] = hzhigh[x]>>5;
hzlow[x] = hzlow[x]>>5;
}*/
end:
Serial.print("\n\n\n\n");
for(x=0;x<14;x++){
Serial.print("hi:");
Serial.print(x);Serial.print(" is:");
Serial.println(hzhigh[x]);
Serial.print("low:");
Serial.print(x);Serial.print(" is:");
Serial.println(hzlow[x]);
}
for(x=0;x<14;x++){
hzhigh[x] = 0;
hzlow[x] = 0;
}
delay(100);
}