[HELP!/UNSOLVED] Using a Color sensor and a Ultrasonic sensor simultaneously!

Howdy! I am relatively new to the world of Arduino, so don't be frustrated if I ask questions that could be silly. This project has a deadline, so any input is appreciated.

THE PROJECT:

I am planning to build a 2WD vehicle, with an arm using 2 servos, and a TCS3200 color sensor. The goal is to make the robot avoid obstacles while simultaneously searching for a GREEN colored object (using the color sensor). After finding the GREEN object, it would stop and use the robotic claw to grab the object. Finally, it would continue to avoid obstacles until you reach a RED colored area. It would drop the object and start again.

Something like this: Area cleaning color sensor robot - YouTube

QUESTIONS:

That said, I have some questions about the use of different sensors to control a robot (do not hesitate to put any input that may be useful):

  1. How would you connect it to the sensor shield considering the other components? Could you use analog pins or (converting digital to analog) or use fewer pins? (I just need Green and Red)

  2. How would make it so that the Arduino receives data from both sensors at the same time? How can I make both sensors control the same two motors?

WIRING: wiring exactly the same bigger image


NOTE: in the second image the ultrasonic sensor should be connected to the bottom right pins

You say you are subject to a deadline. If it was me doing this project (at any level of experience), the first thing I would do is use Google to find technical documentation to answer questions like, "Does a TCS3200 color sensor need PWM pins to work?".

It's actually faster than asking in a forum. I think you might be looking too much at people's projects and opinions, instead of base documentation for example TCS3200 data sheet, libraries and so on...

@aarg I did not find anything on PWM pins on the documentation, so I assume no PWM pins are needed. I have tried searching for Google already (before I posted) HOWEVER, I didn't find any answers to my questions such as: using two different sensors simultaneously to control the motors and connecting the color sensor to the shield :sob: . I STILL NEED HELP :slightly_frowning_face: , but thanks for the input! :slight_smile:

You have not given a link to your ultrasonic sensor. If you have a data sheet or look at example programs, you will see it is blocking your program until it either receives an echo or times-out waiting for one. So, can't even consider using it at the same(relative) time as another sensor.

Paul

Then how is this guy able to do it?

alex654:
Then how is this guy able to do it?

Maybe s/he's smart, and spent time learning about the problem

The first thing to do is get an Uno or similar, a color sensor and an ultrasonic ranger.

Then, separately, study one or more of the many example tutorials for each, and get each working individually.

Once that is done, you will be in fine shape to start thinking about using them together on a robot.

alex654:
https://www.youtube.com/watch?v=VPVOqlVQsD0

Then how is this guy able to do it?

By not using pulseIn().

aarg:
By not using pulseIn().

What could I use as an alternative then or how can I do it the proper way? Thanks for all the input so far!