Arduino Shield Bot with IR and Ultrasound

I have this shield bot set up with IR detection and it works pretty good. I am trying to add ultrasound, hooked up to pins 5(echo) and 6(trigger) to reduce some corner jittering where it can get get stuck at times. I will probably try to get it to trigger a 90 degree turn and 20cm distance. Then I can turn the IR out to cover the side blind spots. I'm not sure how to combine the ultrasound sketch (which works fine on the serial monitor) with my present sketch. Any help would be appreciated, Thanks.

Update: Got a lot of help with the sketch.....I was in a little over my head for first arduino project but ended up with it working pretty good. Uses both IR and ultrasound and has serial communication with the MP3 Trigger. I posted latest version in the video.

 


This is a companion discussion topic for the original entry at https://community.robotshop.com/robots/show/arduino-shield-bot-with-ir-and-ultrasound

You just poll each of your sensors

Check the responses against thresholds and respond. It would be no different if you were to add bumpers. The only real difference would be with switches the threshold is either on or off. 

if (leftSwitch && rightSwitch) { reverse }
else if (leftSwitch) { right }
else if (rightSwitch) { left }