Skip to content

Instantly share code, notes, and snippets.

Created January 27, 2016 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4836950702ff3438df86 to your computer and use it in GitHub Desktop.
Save anonymous/4836950702ff3438df86 to your computer and use it in GitHub Desktop.
//declarar variables
int A = 0;
int B = 0;
//definimos una tercera variable auxiliar
//para asi poder intercambiar el valor de las variables
int C = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin (9600);
}
void loop() {
// put your main code here, to run repeatedly:
A = random (0,10);
B = random (11,20);
Serial.print("A = ");
Serial.println(A);
delay(500);
Serial.print ("B = ");
Serial.println(B);
Serial.println();
delay(500);
//asignamos el valor de A a C, en A guardamos el valor de B
//y luego le damos a B el valor de C
C = A;
A = B;
B = C;
Serial.print("A= ");
Serial.println(A);
delay(500);
Serial.print ("B = ");
Serial.println(B);
Serial.println();
delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment