Arduino code – Panel command – Animation: bouncing ball
void setup() { Serial.begin(115200); delay(5000); Serial.println("\n$PING 200"); Serial.println("$P:Dg21;^{-%90,90gn2}{I7.55~1%10;}"); } void loop() { static float x = 0; static float y = 0; static float dx = 0.17/1.3/2; static float dy = 0.213/1.3/2; static float CBall = 0; Serial.print("#C0:s~1:@"); Serial.print(x+5,1); Serial.print(","); Serial.print(y,1); Serial.println(""); if ((x+dx > 80) || (x+dx < 0)) { dx=-dx;} if ((y+dy > 80) || (y+dy < 0)) { dy=-dy;} x += dx; y += dy; delay(2); }
NOTE: Remember to check (on your miuPanel App) that the baud-rate of your wifi module is the same set in this code.