Hello, me and my friends have been working on a car project(line follower). We are using Mega and UNO to make a complex car. We have a RGB sensor, which reads the different colors of lines beneath the car and take operations according to the color. Like stopping for 5 seconds when it sees red etc. It uses a lot of data, library. Putting the sensor in MEGA resulted overloading MEGA. So we thought of putting RGB sensor's codes, librarys in UNO and let it process the color. Then uno tells the color to MEGA and MEGA do operations like stopping on red.
Our main problem is that we can not transfer the color data from uno to mega properly. For each color we have assigned a different number. Like 5 for red and 2 for blue. So the problem is that we can not send this data to mega.
I have looked around the net to find an solution for transfering int via Serial port, but none of them seems to work. Do you guys have any solution for transfering data via serial? If yes can you please put an example code? Thanks!
Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.
The technique in the 3rd example will be the most reliable.
You can send data in a compatible format with code like this
Another simple way is to transmit data in parallel. You assign each pin a different color and turn a pin high for presence and low for absence. Match up the appropriate pins to the mega. Be sure to use pull up or pull down resistors.
This does have it's limits though since little information can be transfered in this way. I would recommend you to study serial communication, it will get you much further.