user29266: Hi I want to control a DC motor using Arduino mega2560 and Arduino Uno as a slave. Mega have to process data from an ultrasonic sensor(measuring distance) and control the motor based on the input. I tried to google but couldn't find a better tutorial or code. I'm using Adafruit motor shield l293d. I have the idea about the wiring part just need a simple code.
Eg:   

 if( distance < 20) {
   //send signal to slave to run the motor forward
 }else {
   //send signal to slave to stop the motor 
 }


user1576: Serial is quite easy to implement and use the SoftSerial.
Example code for serial can be found in the Arduino IDE under the menu:
File | Examples | 04. Communication


29266: <p>Hi I want to control a DC motor using Arduino mega2560 and Arduino Uno as a slave. Mega have to process data from an ultrasonic sensor(measuring distance) and control the motor based on the input. I tried to google but couldn't find a better tutorial or code. I'm using Adafruit motor shield l293d. I have the idea about the wiring part just need a simple code.</p>

<pre><code>Eg:   

 if( distance &lt; 20) {
   //send signal to slave to run the motor forward
 }else {
   //send signal to slave to stop the motor 
 }
</code></pre>
 1576: <p>Serial is quite easy to implement and use the <code>SoftSerial</code>.</p>

<p>Example code for serial can be found in the Arduino IDE under the menu:</p>

<pre><code>File | Examples | 04. Communication
</code></pre>
