23.- Arduino sends random numbers every second and every two seconds.
p9A0i_bluetooth_aleatorio2.aia (3.4 KB)
// Juan A. Villalpando
// http://kio4.com/appinventor/9A0_Resumen_Bluetooth.htm
int alea_1;
int alea_2;
unsigned long tiempo_actual_1 = 0;
unsigned long tiempo_actual_2 = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
if((millis()-tiempo_actual_1)>= 1000){
int alea_1 = random(0,100);
tiempo_actual_1 = millis();
Serial.println(String(alea_1));
}
if((millis()-tiempo_actual_2)>= 2000){
int alea_2 = random(200,300);
tiempo_actual_2 = millis();
Serial.println(String(alea_2));
}
}
