robottino mozduino

ciao ragazzi ho trovato per la rete un video che parla di un semplice robot creato a barcellona al mozzilla festival ecco qui il codice
mozduino robot developed
/ in Barcellona during Brumbeat Festival
/ code made by a bunch of people
/ and Cristian Maglie :wink:

int RX = 11;
int LX = 10;
int LEDS = 3;
boolean DEBUG=false;

int RX_HALL = 4;
int DX_HALL = 5;

// written at: luckylarry.co.uk
// variables to take x number of readings and then average them
// to remove the jitter/noise from the SRF05 sonar readings
const int numOfReadings = 10; // number of readings to take/ items in the array
int readings[numOfReadings]; // stores the distance readings in an array
int arrayIndex = 0; // arrayIndex of the current item in the array
int total = 0; // stores the cumlative total
int averageDistance = 0; // stores the average value
// setup pins and variables for SRF05 sonar device
int echoPin = 2; // SRF05 echo pin (digital 2)
int initPin = 4; // SRF05 trigger pin (digital 3)
unsigned long pulseTime = 0; // stores the pulse in Micro Seconds
unsigned long distance = 0; // variable for storing the distance (cm)
// setup pins/values for LED
//int redLEDPin = 9; // Red LED, connected to digital PWM pin 9
int redLEDValue = 0; // stores the value of brightness for the LED (0 = fully off, 255 = fully on)

void setup() {
Serial.begin(9600);
pinMode(RX, OUTPUT);
pinMode(LX, OUTPUT);
pinMode(LEDS, OUTPUT);

//pinMode(redLEDPin, OUTPUT); // sets pin 9 as output
pinMode(initPin, OUTPUT); // set init pin 3 as output
pinMode(echoPin, INPUT); // set echo pin 2 as input
// create array loop to iterate over every item in the array
for (int thisReading = 0; thisReading < numOfReadings; thisReading++) {
readings[thisReading] = 0;
}

// turn on the light
digitalWrite(LEDS, HIGH);

// give some time for the port to get started
delay(3000);
}

void forward(int time) {
analogWrite(RX, 32); // Start Right Motor
analogWrite(LX, 32); // Start Left Motor

delay(time);

analogWrite(RX, 0); // Start Right Motor
analogWrite(LX, 0); // Start Left Motor
}

void left(int time) {
analogWrite(RX, 32); // Start Right Motor
analogWrite(LX, 0); // Start Left Motor

delay(time);

analogWrite(RX, 0); // Start Right Motor
analogWrite(LX, 0); // Start Left Motor
}

void right(int time) {
analogWrite(RX, 0); // Start Right Motor
analogWrite(LX, 32); // Start Left Motor

delay(time);

analogWrite(RX, 0); // Start Right Motor
analogWrite(LX, 0); // Start Left Motor
}

int deg90 = 640;

boolean detectObstacle() {
digitalWrite(initPin, HIGH); // send 10 microsecond pulse
delayMicroseconds(10); // wait 10 microseconds before turning off
digitalWrite(initPin, LOW); // stop sending the pulse
pulseTime = pulseIn(echoPin, HIGH); // Look for a return pulse, it should be high as the pulse goes low-high-low
distance = pulseTime/58; // Distance = pulse time / 58 to convert to cm.
total= total - readings[arrayIndex]; // subtract the last distance
readings[arrayIndex] = distance; // add distance reading to array
total= total + readings[arrayIndex]; // add the reading to the total
arrayIndex = arrayIndex + 1; // go to the next item in the array
// At the end of the array (10 items) then start again
if (arrayIndex >= numOfReadings) {
arrayIndex = 0;
}
averageDistance = total / numOfReadings; // calculate the average distance
// if the distance is less than 255cm then change the brightness of the LED
if (averageDistance < 255) {
redLEDValue = 255 - averageDistance; // this means the smaller the distance the brighterthe LED.
}
//analogWrite(redLEDPin, redLEDValue); // Write current value to LED pins
Serial.println(averageDistance, DEC); // print out the average distance to the debugger
if (averageDistance < 36)
return true;
return false;
}

boolean goLeft = true;

void loop()
{
forward(100);
if ( detectObstacle() ) {
digitalWrite(LEDS, LOW);
delay(500);
if (goLeft) {
left(deg90);
forward(1000);
right(deg90);
goLeft = false;
}
else {
right(deg90);
forward(1000);
left(deg90);
goLeft = true;
}
digitalWrite(LEDS, HIGH);
delay(500);
}
}
ma non riesco a trovare da nessuna parte la lista del materiale che mi serve per provare questo codice mi sapete aiutare??? ho visto anche un altro code ma mi sembra meno professionale
io come servi ho questi hitec hs311 standard servo vanno bene ???
come sensore volevo usare quello di dfrobot URM04 v2.0 Ultrasonic Sensor va bene si puo mettere anche in questo code??