yeah, I was just hoping, since it was a simple program, that I would be able to quickly get it going without having to get too heavily into learning C++, since right now I am also studying for my CCNA and trying to find a new job as a net admin. Learning a programming language at this point in time doesn't seem conducive. Just out of curiosity though, could you guys point me in the general direction of where I went wrong? I made one or two modifications that I think might help but I don't really know. This is just from looking at a couple on the in IDE and on the site examples.
/*
Mowbot software version 2f with random number turning
*/int bumpPin1 = A2;
int bumpPin2 = A3;
int val;
int randNumber;
void setup() {
// initialize the digital pins as an outputs.
// Pins to control motor shield
pinMode(12, OUTPUT);
pinMode(9, OUTPUT);
pinMode(13,OUTPUT);
pinMode(8,OUTPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
}
void loop() {
val = analogRead(bumpPin1);
randNumber = random(600, 1500);
if (val == HIGH) { // if no objects detected on bump sensor right
digitalWrite(12, HIGH); //Establishes forward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
digitalWrite(3, 255); //Spins the motor on Channel A at full speed
digitalWrite(13, HIGH); //Establishes forward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
digitalWrite(11, 255); //Spins the motor on Channel B at full speed
}
else { // if objects detected on right sensor
digitalWrite(12, LOW); //Establishes backward direction of Channel B
digitalWrite(9, LOW); //Disengage the Brake for Channel B
digitalWrite(3, 123); //Spins the motor on Channel B at half speed
digitalWrite(13, LOW); //Establishes backward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
digitalWrite(11, 123); //Spins the motor on Channel B at half speed
delay(1500);
digitalWrite(13, LOW);// keep motor b running to turn
digitalWrite(8, LOW);
delay(randNumber);
analogWrite(11, 123); //Spins the motor on Channel B at half speed
}
val = analogRead(bumpPin2);
randNumber = random(600, 1500);
if (val == HIGH) { // if no objects detected on bump sensor right
digitalWrite(12, HIGH); //Establishes forward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
digitalWrite(3, 255); //Spins the motor on Channel A at full speed
digitalWrite(13, HIGH); //Establishes forward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
digitalWrite(11, 255); //Spins the motor on Channel B at full speed
}
else { // if objects detected on right sensor
digitalWrite(12, LOW); //Establishes backward direction of Channel B
digitalWrite(9, LOW); //Disengage the Brake for Channel B
digitalWrite(3, 123); //Spins the motor on Channel B at half speed
digitalWrite(13, LOW); //Establishes backward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
digitalWrite(11, 123); //Spins the motor on Channel B at half speed
delay(1500);
digitalWrite(13, LOW);// keep motor b running to turn
digitalWrite(8, LOW);
digitalWrite(11, 123); //Spins the motor on Channel B at half speed
delay(randNumber);
}
}