Hello,
I have begun working on my summer projects early. Most of them involve creating practice bot ideas for training new members. For the past few years, our team has collected hobby kits to help teach programming, but it has not always worked out too well.
Long story short, we have the PiCar-s and the VMX-Pi. I got the car working (even wrote a small class for the steering yoke; it works well). However, the ultrasonic sensor is a mystery to me. It seems like a digital TOF sensor (even though they repeatedly call it analog in the documentation). Yet there is only one cable. The sensor is a max220-49 ds-2. In the Arduino and Raspberry Pi code, they use the same pin as both an input and an output. Is this possible in the FRC world? Does a counter send a pulse, or a PWM receive one? Sorry if this thread is misplaced. I am ultimately programming in Java.
I saw someone posted a similar question a few years ago with no response. I am wondering if anyone has any thoughts.
If this is not possible, that is okay. I just wanted to know before a spent much more time on it (I thought it would be simple).
Here is the Arduino Snippet (I know, it is C++, not Java).
//set SIG as OUTPUT,start to output trigger signal to the module to start the ranging
pinMode(SIG, OUTPUT);
//Genarate a pulse 20uS pulse
digitalWrite(SIG, HIGH);
delayMicroseconds(20);
digitalWrite(SIG, LOW);
//set SIG as INPUT,start to read value from the module
pinMode(SIG, INPUT);
rxTime = pulseIn(SIG, HIGH);//waits for the pin SIG to go HIGH, starts timing, then waits for the pin to go LOW and stops timing
// Serial.print("rxTime:");
// Serial.println(rxTime);
distance = (float)rxTime * 34 / 2000.0; //convert the time to distance