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

3 years ago
  1. #define HZin 4
  2. uint32_t hzhigh[20];
  3. uint32_t hzlow[20] ;
  4. uint8_t x = 0;
  5. void setup() {
  6. // put your setup code here, to run once:
  7. pinMode(HZin, INPUT);
  8. Serial.begin(116200);
  9. }
  10. void loop() {
  11. // put your main code here, to run repeatedly:
  12. //if (val = pulsein < 2000) then do low, then high again
  13. //else goto end
  14. /*if((hzhigh[x] = pulseInLong(HZin, HIGH, 1000000UL)) < 2000){
  15. x++
  16. hzlow[x] = pulseInLong( HZin, HIGH, 1000000UL);
  17. }*/
  18. //if pulse high don't care
  19. //if pulse low, do stuff{
  20. // whilepulse low, time,
  21. // while pulse high time,
  22. // etc...
  23. //if pulse high greater than 3ms, end
  24. //the below is not usable
  25. //apparently setup time is too long
  26. if((hzlow[x] = pulseInLong(HZin,LOW, 2000000UL))){
  27. //while(hzhigh[x] < 2000){
  28. x++;
  29. hzhigh[x] = pulseInLong(HZin,HIGH,2000000UL);
  30. x++;
  31. hzlow[x] = pulseInLong(HZin,LOW, 2000000UL);
  32. x++;
  33. hzhigh[x] = pulseInLong(HZin,HIGH,2000000UL);
  34. x++;
  35. hzlow[x] = pulseInLong(HZin,LOW, 2000000UL);
  36. x++;
  37. hzhigh[x] = pulseInLong(HZin,HIGH,2000000UL);
  38. x++;
  39. hzlow[x] = pulseInLong(HZin,LOW, 2000000UL);
  40. x++;
  41. hzhigh[x] = pulseInLong(HZin,HIGH,2000000UL);
  42. x++;
  43. hzlow[x] = pulseInLong(HZin,LOW, 2000000UL);
  44. x++;
  45. hzhigh[x] = pulseInLong(HZin,HIGH,2000000UL);
  46. x++;
  47. hzlow[x] = pulseInLong(HZin,LOW, 2000000UL);
  48. x++;
  49. hzhigh[x] = pulseInLong(HZin,HIGH,2000000UL);
  50. x++;
  51. hzlow[x] = pulseInLong(HZin,LOW, 2000000UL);
  52. x++;
  53. hzhigh[x] = pulseInLong(HZin,HIGH,2000000UL);
  54. x++;
  55. hzlow[x] = pulseInLong(HZin,LOW, 2000000UL);
  56. }
  57. /*
  58. for(x=0;hzhigh[x]<2000;x++){
  59. hzhigh[x] = pulseInLong( HZin, HIGH, 2000000UL);
  60. hzlow[x] = pulseInLong( HZin, LOW, 2000000UL);
  61. //hzhigh[x] = pulseInLong( HZin, HIGH, 2000000UL);
  62. }
  63. for(x=0;x<10;x++){
  64. hzhigh[x] = hzhigh[x]>>5;
  65. hzlow[x] = hzlow[x]>>5;
  66. }*/
  67. end:
  68. Serial.print("\n\n\n\n");
  69. for(x=0;x<14;x++){
  70. Serial.print("hi:");
  71. Serial.print(x);Serial.print(" is:");
  72. Serial.println(hzhigh[x]);
  73. Serial.print("low:");
  74. Serial.print(x);Serial.print(" is:");
  75. Serial.println(hzlow[x]);
  76. }
  77. for(x=0;x<14;x++){
  78. hzhigh[x] = 0;
  79. hzlow[x] = 0;
  80. }
  81. delay(100);
  82. }