You still need to tell us what you want it to do... =)
Comments:
1. You need a caster or 'third wheel' to contact the ground, otherwise your robot will be very unstable (three points of contact define a plane).
2. Wheels?
I assume, however, that your CAD is just a mockup, and that you've already got answers to the two comments above.
You should use a step-by-step approach for this project.
Step 1: Mount the hardware to make a stable robot platform.
Step 2: Program a working drive base (example code at end of post)
Step 3: Read data from sensors (example code at end of post)
Step 4: Implement algorithm to do whatever you want the robot to do (need your input!)
Example code for drive base (you may want to switch this to a state machine later):
#include <Servo.h> // include the servo library
// you will need to give these values
#define LEFT_SERVO_SIGNAL_PIN
#define RIGHT_SERVO_SIGNAL_PIN
Servo leftServo, rightServo;
// Takes a speed value between -100 (full reverse) and 100 (full forward) for each servo.
void setSpeeds(int8_t lspd, int8_t rspd) {
uint16_t lSet = map(lspd, -100, 100, 1000, 2000); // map this to the servo's input range
// because one of the servos is mounted backwards relative to the other, we will map it in reverse
uint16_t rSet = map(rspd, -100, 100, 2000, 1000); // map this to the servo's input range
leftServo.writeMicroseconds(lSet); // set left servo
rightServo.writeMicroseconds(rSet); // set right servo
}
void setup() {
leftServo.attach(LEFT_SERVO_SIGNAL_PIN);
rightServo.attach(RIGHT_SERVO_SIGNAL_PIN);
setSpeeds(0, 0);
}
void loop() {
// turn left
setSpeeds(-50, 50);
// turn right
setSpeeds(50, -50);
// go forward
setSpeeds(50, 50);
// go backward
setSpeeds(-50, -50);
}
Example code for Sharp GP2D12:
uint8_t readIR(uint8_t irpin) {
uint16_t adc = analogRead(irpin);
return (uint8_t) (5 * 2769 / 2 / value); // this equation was empirically derived for my sensor at some point, you can and should derive your own.
}
Example code for Parallax PIR: (assumes that it is set to single trigger output mode, see datasheet.)
#define PIR_SIGNAL_PIN
// in setup:
pinMode (PIR_SIGNAL_PIN, INPUT);
// when you want to check it
bool isMovement = digitalRead(PIR_SIGNAL_PIN);
Note: the code above is not guaranteed to work, it's instead intended to give you an idea of what you need to do