Itan Fuentes Santamaria

Email: itan.fs@hotmail.com

Phone: 2227535416

NETWORKING AND COMMUNICATION

In this assignment we are going to use 2 micro-controler with the intention to send data from 1 micro to another to perform some action, to understand how this works, I'll do something easy (for the moment) because of my electronic skills, and that will be, turn on a led by sending data.

the schematic of the the connection between arduinos. I had an accident with my fab board and died, BE CAREFUL WHEN YOU CONNECT THE PINS!

Here is the code i used, i have to say you need to load in both micro-controler the code so the communication may be possible

Find the .ini HERE

 

int DATO=0;

int LED=52;

int BOTON=53;

int ESTADO_BOTON=0;

void setup(){

  Serial3.begin(9600);

  Serial.begin(9600);

  pinMode(LED,OUTPUT);

  pinMode(BOTON,INPUT);

}

void loop(){

   envio();

   lee();

   recibe();

}

void envio(){

   ESTADO_BOTON=digitalRead(BOTON);

  if(ESTADO_BOTON==HIGH){

     Serial3.write(1);

  }

   else{

     Serial3.write(0);

   }

}

void recibe(){

    if (Serial3.available()){

    DATO=Serial3.read();

    if(DATO==0)

    digitalWrite(LED,LOW);

    else

    digitalWrite(LED,HIGH);

  }

}

void lee(){

 Serial.print("DATO ENTRADA = " );

  Serial.print(DATO);

  Serial.print("\t DATO SALIDA = ");

  Serial.println(ESTADO_BOTON);

 delay(10);

}