I am sorry but I can't figure out how to do that.
Here's what I manage to cobble together.
#include "URMSerial.h"
#define DISTANCE 1
int ledPin = 13;
URMSerial urm;
int output = 0;
// Arduino pins connected to the 4511
const int LedA = 5;
const int LedB = 8;
const int LedC = 7;
const int LedD = 6;
// Arduino pins connected to the segment driver transistors
const int Led1 = 4;
const int Led2 = 3;
const int Led3 = 2;
void setup() {
Serial.begin(9600); // Sets the baud rate to 9600
urm.begin(9,10,9600); // RX Pin, TX Pin, Baud Rate pinMode(ledPin, OUTPUT);
// Let the Arduino know which pins go where
pinMode(LedA, OUTPUT);
pinMode(LedB, OUTPUT);
pinMode(LedC, OUTPUT);
pinMode(LedD, OUTPUT);
pinMode(Led1, OUTPUT);
pinMode(Led2, OUTPUT);
pinMode(Led3, OUTPUT);
digitalWrite(Led1, HIGH);
digitalWrite(Led2, HIGH);
digitalWrite(Led3, HIGH);
}
void loop()
{
// Request a distance reading from the URM37
urm.requestMeasurement(DISTANCE); // You may call this as many times as you like. It will only send once
// Avoid fetching the distance until we're sure the reading is ready
if(urm.hasReading())
{
int value; // This value will be populated
switch(urm.getMeasurement(value)) // Find out the type of request
{
case DISTANCE: // Double check the reading we recieve is of DISTANCE type
// Display the first digit
Display(value / 100); // Send first digit to the 4511
output = value % 100; // Calculate next digit
digitalWrite(Led1, LOW); // Illuminate first segment
delay(2); // Wait
digitalWrite(Led1, HIGH); // Extinguish first segment
// Display the second digit
Display(value /10);
output = value % 10;
digitalWrite(Led2, LOW);
delay(2);
digitalWrite(Led2, HIGH);
// Display the third digit
Display(value);
output = value;
digitalWrite(Led3, LOW);
delay(2);
digitalWrite(Led3, HIGH);
delay(200);
break;
}
}
}