Loading...
  Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Serial communication between two arduinos on: February 27, 2012, 04:01:15 pm
Thank you. It seems to work :-) and I think I understand your code ...
Does this only with one sensor or can I define multiple "outputs"?

/Örjan
2  Using Arduino / Programming Questions / Serial communication between two arduinos on: February 27, 2012, 03:25:21 pm
I need som help with my code (is not a programmer...
I want to communicate serial between two Arduino. A potentiometer on one board to control an output on the other. I'm building a ROV and want to control the steering in this way.
Can I have the serial communication through 60 feet of cable?)

------------Transmit code on board no 1---------------
//Send potentiometer value from one Arudino board to another
const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin with LED for control of pot function
int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the PWM

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  // read the analog in value:
  sensorValue = analogRead(analogInPin);           
  // map it to the range of the analog out:
  outputValue = map(sensorValue, 0, 1023, 0, 255); 
  // change the analog out value:
  analogWrite(analogOutPin, outputValue);           

  // print the results to the serial monitor:
   Serial.println(outputValue);   
  delay(10);                     
}

------------Receiving code on board no 2---------------
//Recive potentiometer value and dim a LED
int outputValue = 127;         // start value
const int analogOutPin = 6; // Analog output pin that the LED is attached to

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  // if we get a valid byte, read analog ins:
   if (Serial.available() > 0) {
    // get incoming byte:
    outputValue = Serial.read();
     delay(10);         
  }
analogWrite(analogOutPin, outputValue);
}


3  International / Scandinavia / Styra ett Arduino från ett annat? on: January 27, 2012, 04:24:16 pm
Jag håller på att bygga en undervattens-ROV som kommer att styras via en kabel. För att få ner antalet trådar funderar jag om man enkelt kan kommunicera med två kort via seriell anslutning. Som exempel, en lampa sitter på det ena kortets utgång, men jag vill tända den när jag ger en signal på det andra kortets ingång. Skulle också kunna tänka mig att det ena kortet har en tempgivare och jag visar temperaturen på en LCD på det andra kortet.

Är seriell komminukation mellan de två kortetn rätt väg att gå?

Hej - Örjan
Pages: [1]