Serial Monitor don't reponses when I have this code.


hi everyone.i new here , not @ english sorry english.
i use arduino uno r3.i have problem code attach below(this summarize 1 , doesn't work too). don't know why when upload , open serial monitor, type , enter number. doesn't response,but when delete red code(one of them or both), works well.

code: [select]
#include <lcd.h>
#include <liquidcrystal_i2c.h>
[color=red]#include <wire.h>[/color]

float deg_per_sec,rpm;

float gramma2_5[36]={22.19, 24.21, 26.32, 28.53, 30.80,
                 33.12, 35.48, 37.86, 40.24, 42.62,
                 44.99, 47.35, 49.69, 52.00, 54.28,
                 56.54, 58.77, 60.96, 63.12, 65.24,
                 67.33, 69.38, 71.39, 73.36, 75.30,
                 77.19, 79.04, 80.85, 82.62, 84.34,
                 86.01, 87.64, 89.22, 90.76, 92.24, 93.67};

float gramma2[45]={17.59,18.87,20.20,21.58,23.00,
                24.46,25.94,27.44,28.95,30.48,
                32.00,33.53,35.05,36.56,38.07,
                39.56,41.05,42.52,43.97,45.41,
                46.84,48.24,49.63,51.01,52.36,
                53.70,55.01,56.31,57.59,58.85,
                60.09,61.30,62.50,63.67,64.83,
                65.95,67.06,68.15,69.21,70.24,
                71.26,72.24,73.21,74.14,75.05};
float gramma1_5[60]={13.08,13.79,14.52,15.28,16.05,16.85,17.66,18.48,19.32,20.16,
                   21.00,21.86,22.71,23.57,24.43,25.29,26.14,27.00,27.85,28.69,
                   29.53,30.37,31.20,32.02,32.84,33.66,34.46,35.26,36.05,36.84,
                   37.61,38.38,39.15,39.90,40.64,41.38,42.11,42.83,43.55,44.25,
                   44.95,45.64,46.32,46.99,47.65,48.30,48.94,49.57,50.19,50.81,
                   51.41,52.00,52.59,53.16,53.72,54.27,54.82,55.35,55.86,56.37};
float gramma1[90]={8.64,8.95,9.27,9.60,9.93,10.27,10.62,10.97,11.32,11.68,
                  12.05,12.41,12.78,13.16,13.53,13.91,14.29,14.67,15.05,15.43,
                  15.81,16.19,16.57,16.95,17.33,17.71,18.09,18.47,18.85,19.22,
                  19.60,19.97,20.34,20.71,21.07,21.44,21.80,22.17,22.53,22.88,
                  23.24,23.59,23.95,24.30,24.64,24.99,25.33,25.67,26.01,26.35,
                  26.68,27.01,27.34,27.67,27.99,28.32,28.64,28.95,29.27,29.58,
                  29.89,30.20,30.50,30.80,31.10,31.40,31.69,31.98,32.27,32.56,
                  32.84,33.12,33.39,33.67,33.94,34.21,34.47,34.73,34.99,35.25,
                  35.50,35.75,36.00,36.24,36.48,36.72,36.96,37.19,37.41,37.64};
float gramma0_5[180]={4.28, 4.36,4.44,4.52,4.60,4.68,4.76,4.84,4.92,5.01,
                     5.09,5.18,5.26,5.35,5.44,5.53,5.62,5.71,5.79,5.89,
                     5.98,6.07,6.16,6.25,6.35,6.44,6.53,6.62,6.72,6.81,
                     6.91,7.00,7.10,7.19,7.29,7.38,7.48,7.57,7.67,7.76,
                     7.86,7.95,8.05,8.14,8.24,8.33,8.43,8.53,8.62,8.71,
                     8.81,8.90,9.00,9.09,9.19,9.28,9.38,9.47,9.57,9.66,
                     9.75,9.84,9.94,10.03,10.12,10.21,10.31,10.40,10.49,10.58,
                     10.68,10.77,10.86,10.95,11.04,11.13,11.22,11.31,11.40,11.49,
                     11.58,11.67,11.75,11.84,11.93,12.02,12.10,12.19,12.28,12.37,
                     12.45,12.54,12.62,12.71,12.79,12.88,12.96,13.05,13.13,13.22,
                     13.30,13.38,13.47,13.55,13.63,13.71,13.80,13.88,13.96,14.04,
                     14.12,14.20,14.28,14.36,14.44,14.52,14.60,14.67,14.75,14.83,
                     14.91,14.98,15.06,15.14,15.21,15.29,15.36,15.44,15.51,15.59,
                     15.66,15.74,15.81,15.88,15.96,16.03,16.10,16.17,16.24,16.31,
                     16.38,16.45,16.52,16.59,16.66,16.73,16.80,16.87,16.94,17.00,
                     17.07,17.14,17.20,17.27,17.33,17.40,17.46,17.53,17.59,17.66,
                     17.72,17.78,17.85,17.91,17.97,18.03,18.09,18.15,18.21,18.27,
                     18.33,18.39,18.45,18.51,18.56,18.62,18.68,18.73,18.79,18.85};

void setup()
{
  serial.begin(9600);
}
void loop()
{
    if(serial.available()>0)
    {
      deg_per_sec=serial.parsefloat();//you have type 0.5 or 1 or 1.5 or 2 or 2.5
      clockwise();
    }
    
 }
 void clockwise(){
for(int j=0;j<(90/deg_per_sec);j++)
{
    {
      if(deg_per_sec==2.5)
        {
          rpm=gramma2_5[j];
        }else if(deg_per_sec==2)
        {
          rpm=gramma2[j];
        }else if(deg_per_sec==1.5)
        {
          rpm=gramma1_5[j];
        }else if(deg_per_sec==1)
        {
          rpm=gramma1[j];
        }[color=red]else if(deg_per_sec==0.5){
           rpm=gramma0_5[j];
        }[/color]
        serial.println(rpm);
    }
}
 }



thank you help.

you've got 1600 bytes of ram wasted in tables.
you have 2048 bytes of ram in total.
if they're constant, they'd better kept in flash.


Arduino Forum > Using Arduino > Programming Questions > Serial Monitor don't reponses when I have this code.


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code