Advertisement
RuiViana

Calcula_numero.ino

Sep 1st, 2020
1,654
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. char recebido[4] ;
  2. bool flag = false;
  3. ///////////////////////////////////////////////////////////////
  4. void setup() {
  5.   Serial.begin(115200);
  6. }
  7. ///////////////////////////////////////////////////////////////
  8. void loop() {
  9.   if (Serial.available() >= 2)
  10.   {
  11.     int i = 0;
  12.     while (Serial.available() > 0)
  13.     {
  14.       recebido[i] = Serial.read();
  15.       i++;
  16.       delay(1);
  17.       flag = true;
  18.     }
  19.   }
  20.   if (flag == true)
  21.   {
  22.     long total = 1;
  23.     flag = false;
  24.     for ( int i = 0; i < 4; i++)
  25.     {
  26.       total = (int)recebido[i] * total;
  27.     }
  28.     if(total > 0)
  29.     Serial.println(total);
  30.   }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement