I've written a simple brushless motor testing program, but i'm getting a weird error I've never seen before !
What does this error mean and how do I fix it? Thanks in advance!
BTW the error happens somewhere in the for loop where 'i' is between 1500 and 1000 I think. The code works fine up till that point.
#include <LiquidCrystal.h>
#include <Servo.h> //Notice how you can use the standard servo library!
Servo bldc_motor; //creates a "servo" object (the ESC and motor)
LiquidCrystal LCD (2, 3, 4, 5, 6, 7); ///create an LCD
void setup()
{
 bldc_motor.attach (9); //attach the motor to pin 9
 LCD.begin (16, 2); //initialise the LCD
 LCD.clear();
}
void loop()
{
 bldc_motor.writeMicroseconds(1500); //provides a "neutral" pulse. The ESC won't start without this.
 LCD.print ("BLDC Motor Test");
 LCD.setCursor (0, 1);
 LCD.print ("Starting in ");
Â
 for (int i = 4; i >= 0; i --) //countdown timer
 {
  LCD.setCursor (12, 1);
  LCD.print (i+1);
  LCD.print ("s");
  delay (1000);
 }
Â
 LCD.setCursor (0, 1);
 LCD.print ("        "); //clears the bottom line of the LCD
Â
 LCD.setCursor (5, 1);
 LCD.print ("forward"); //writing it here so it doesn't keep rewriting this in the for loop
Â
 while(1)
 {
  for (int i = 1500; i <= 2000; i++)
  {
   int speed_value = map (i, 1500, 2000, 0, 100); //maps the signal pulse to a percentage
   LCD.setCursor (0, 1);
   LCD.print (" "); //clears any previous number;
   LCD.setCursor (0, 1);
   LCD.print (speed_value); //prints the percentage to the LCD
   LCD.print ('%'); //notice the single quotation marks. I've just sent a char value, not a string because it's only 1 character
  Â
   bldc_motor.writeMicroseconds (i); //actually write the value to the motor
   delay(10);// small delay so you can see what's happening
  }
 Â
  LCD.setCursor (0, 1);
  LCD.print ("        "); // clears the bottom of the LCD screen;
  LCD.setCursor (0, 1);
  LCD.print ("braking in");
 Â
  for (int i = 4; i >= 0; i --) //countdown timer
  {
   LCD.setCursor (12, 1);
   LCD.print (i+1);
   LCD.print ("s");
   delay (1000);
  }
 Â
  bldc_motor.writeMicroseconds (1000); //full reverse. The ESC will automatically brake the motor.
  delay (500); //small delay to let things happen
  bldc_motor.writeMicroseconds (1500); //give a neutral signal
  LCD.setCursor (0, 1);
  LCD.print ("motor stopped");
  delay (3000); //keep it that way for a while
 Â
  LCD.setCursor (0, 1);
  LCD.print ("        "); //clear the bottom line of the LCD
  LCD.setCursor (5, 1);
  LCD.print ("backward");
 Â
  for (int i = 1500; i >= 1000; i --);
  {
   int speed_value = map (i, 1500, 1000, 0, 100); //maps the signal pulse to a percentage
   LCD.setCursor (0, 1);
   LCD.print (" "); //clears any previous number;
   LCD.setCursor (0, 1);
   LCD.print (speed_value); //prints the percentage to the LCD
   LCD.print ('%'); //notice the single quotation marks. I've just sent a char value, not a string because it's only 1 character
  Â
   bldc_motor.writeMicroseconds (i); //actually write the value to the motor
   delay(10);// small delay so you can see what's happening
  }
 Â
  LCD.setCursor (0, 1);
  LCD.print ("        "); //clear bottom line of LCD
 Â
  bldc_motor.writeMicroseconds (1500);
  LCD.setCursor (0, 1);
  LCD.print ("motor stopped");
  delay (3000); Â
 }
  Â
 Â
Â
}
Error messages:
name lookup of 'i' changed for new ISO 'for' scoping
sketch_nov03a.cpp: error: In funcion 'void loop()':
sketch_nov03a:77: error: name lookup of 'i' changed for new ISO 'for' scoping
sketch_nov03a:37: error: using obsolete binding at 'i' (what on earth does this mean too?)