hi
Ich wollte mehrere SRF04 Sensoren am Handyboard betreiben, frage ist ob das geht. Bei Interactive C ist leider nur eine Funktion sonar() dabei, die nur an je einem bestimten digital und analog Port funktioniert.
Kann ich sowas einfach umschreiben so dass ich den dann an einem anderen port benutzen kann?
Wennn nein wie kann ich das sonst machen?

Gruss veloxid

hier noch de rcode vom sonar():
Code:
// Returns approximate distance in mm
// (actually closer to units of 1.04 mm)

int sonar()
{
    int result;
    long begintime;
    
    hog_processor();
    result= _trigger_srf04(0);
    begintime= mseconds();
    defer();
    
    // wait for input capture, but no longer than 25 msec
    while (!(peek(TFLG1) & 0b00000001)) {
        if (mseconds() - begintime > 25L) break;
        defer();
    }
    if (!(peek(TFLG1) & 0b00000001)) {
        // No return from sonar
        // This may mean that no sonar is connected, or that 
        // there was simply no echo return.  Since we can not tell the
        // difference, just return a large number
        return 32767;
    }
    
    result= (peekword(TIC3)-result)/2;
    if (result < 0) result += 16384;
    // result now contains the round-trip time in microseconds
    // Speed of sound is around 347 meters/sec
    // 1 microsecond * 347meters/sec = .347 mm round-trip, or .1735 mm one-way
    // So result contains the one-way distance in units of approx .1735 mm
    result /= 6;
    result -= 37; // zero offset due to pulse widths and receiver response
    // result now contains the one-way distance in units of approximately 1.04 mm
    
    return result; // units are approximately 1.04 mm each
}