<variable> was not declared in this scope

I'm running Arduino 1.8.1 on Windows 10.

I needed to make some mods to a project that compiled fine the last time I compiled it back in November, but now throws a number of errors. They mostly have to do with various variables no longer being "declared in this scope." I'll post the error log below, along with the start of the code (it's 500+ lines, and the editor won't let me include anymore). Thanks for any thoughts on what's wrong.

Errors:

v2:54: error: 'A1' was not declared in this scope

 #define Battery     A1

                     ^

E:\Karl\Documents\Sculpture\MM Sorter\v7\Code\Arduino\v2\v2.ino:112:11: note: in expansion of macro 'Battery'

   pinMode(Battery, INPUT);

           ^

v2:47: error: 'A0' was not declared in this scope

 #define buttonPin A0

                   ^

E:\Karl\Documents\Sculpture\MM Sorter\v7\Code\Arduino\v2\v2.ino:115:11: note: in expansion of macro 'buttonPin'

   pinMode(buttonPin, INPUT_PULLUP);

           ^

v2:132: error: 'Serial' was not declared in this scope

   Serial.begin(9600);

   ^

v2:146: error: 'TWBR' was not declared in this scope

   TWBR = ((F_CPU /400000l) - 16) / 2; // Change the i2c clock to 400KHz   // Necessary for driving stepper; all other 

   ^

v2:149: error: 'digitalPinToInterrupt' was not declared in this scope

   attachInterrupt(digitalPinToInterrupt(PowerIn), ISR_off, HIGH );  // Use an interrupt to signal turn-off.  See ISR_off() for why.

                                                ^

E:\Karl\Documents\Sculpture\MM Sorter\v7\Code\Arduino\v2\v2.ino: In function 'void lcdmsg(char*, char)':

v2:343: error: 'class TinyM_USI_TWI' has no member named 'setClock'

   Wire.setClock(100000L); 

        ^

v2:366: error: 'class TinyM_USI_TWI' has no member named 'setClock'

     Wire.setClock(400000L); 

          ^

E:\Karl\Documents\Sculpture\MM Sorter\v7\Code\Arduino\v2\v2.ino: In function 'void debounce()':

v2:47: error: 'A0' was not declared in this scope

 #define buttonPin A0

                   ^

E:\Karl\Documents\Sculpture\MM Sorter\v7\Code\Arduino\v2\v2.ino:406:25: note: in expansion of macro 'buttonPin'

     while ((digitalRead(buttonPin) == LOW) && ((millis() - db) < 20))

                         ^

v2:47: error: 'A0' was not declared in this scope

 #define buttonPin A0

                   ^

E:\Karl\Documents\Sculpture\MM Sorter\v7\Code\Arduino\v2\v2.ino:412:23: note: in expansion of macro 'buttonPin'

   while ((digitalRead(buttonPin) == LOW))

                       ^

v2:47: error: 'A0' was not declared in this scope

 #define buttonPin A0

                   ^

E:\Karl\Documents\Sculpture\MM Sorter\v7\Code\Arduino\v2\v2.ino:416:25: note: in expansion of macro 'buttonPin'

     while ((digitalRead(buttonPin) == HIGH) && ((millis() - db) < 20))

                         ^

E:\Karl\Documents\Sculpture\MM Sorter\v7\Code\Arduino\v2\v2.ino: In function 'void showHSL()':

v2:447: error: 'Serial' was not declared in this scope

   Serial.print(hue);

   ^

E:\Karl\Documents\Sculpture\MM Sorter\v7\Code\Arduino\v2\v2.ino: In function 'void wheelAdvance()':

Multiple libraries were found for "Wire.h"
v2:457: error: 'TWBR' was not declared in this scope

 Used: C:\Users\Karl\AppData\Local\Arduino15\packages\adafruit\hardware\avr\1.4.11\libraries\Wire
 Not used: C:\Users\Karl\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.20\libraries\Wire
   TWBR = ((F_CPU /400000l) - 16) / 2;       // Change the i2c clock to 400KHz.  Necessary for driving stepper at adequate speed.

   ^

E:\Karl\Documents\Sculpture\MM Sorter\v7\Code\Arduino\v2\v2.ino: In function 'void BatteryTest()':

v2:54: error: 'A1' was not declared in this scope

 #define Battery     A1

                     ^

E:\Karl\Documents\Sculpture\MM Sorter\v7\Code\Arduino\v2\v2.ino:529:25: note: in expansion of macro 'Battery'

       b_in = analogRead(Battery);

                         ^

E:\Karl\Documents\Sculpture\MM Sorter\v7\Code\Arduino\v2\v2.ino: In function 'void ISR_off()':

v2:570: error: 'digitalPinToInterrupt' was not declared in this scope

   detachInterrupt(digitalPinToInterrupt(PowerIn));  // Disable this interrupt since we won't be

                                                ^
exit status 1
'A1' was not declared in this scope

Code:

// Pin D4:  power control output (high = on, low = off)
// Pin D5:  LED (high = on, low = off)
// Pin D6:  slot sensor for detecting extractor wheel orientation
// Pin D3:  power control input (normally low = power is on, high = turn off; pullup)
// Pin D9:  color sensor servo (servo 1)
// Pin D10:  diverter tube servo (servo 2)
// Pin D11:  MOSI (for ISP)
// Pin D12:  MISO (for ISP)
// Pin D13:  SCK (for ISP, also LED for testing)
// Pin A0:  pushbutton (input; for testing)
// Pin A1:  battery monitor (analog in)
// Pin A4:  SDA (I2C; stepper motor, color sensor)
// Pin A5:  SCL (I2C; stepper motor, color sensor)

#include <Wire.h>
#include "Adafruit_TCS34725.h"
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_MS_PWMServoDriver.h"
#include <Servo.h>

Servo Sensor;     // create servo object to control the color sensor servo
Servo Diverter;   // create servo object to control the diverter tube servo
// twelve servo objects can be created on most boards

// Create the motor shield object with the default I2C address
// The motorshield reports 0x60 and 0x70
Adafruit_MotorShield AFMS = Adafruit_MotorShield(); 
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61); 

// Connect a stepper motor with 200 steps per revolution (1.8 degree)
// to motor port #2 (M3 and M4)
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 2);

/* Initialise color sensor with default values (int time = 2.4ms, gain = 1x) */
// Adafruit_TCS34725 tcs = Adafruit_TCS34725();
/* Initialise with specific int time and gain values */
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_700MS, TCS34725_GAIN_1X);

#define buttonPin   A0
#define MMAX(a, b) (((a) > (b)) ? (a) : (b))
#define MMIN(a, b) (((a) < (b)) ? (a) : (b))
#define PowerIn     3
#define PowerOut    4
#define LED         5
#define slotSensor  6
#define Battery     A1

// Rotation limits for color sensor servo

#define TOP 58
#define BOTTOM  93

// Positions for the diverter tube servo

#define START 43
#define D_INDEX 19
#define D_RED START
#define D_GREEN START + D_INDEX
#define D_BLUE START + (2 * D_INDEX)
#define D_ORANGE START + (3 * D_INDEX)
#define D_YELLOW START + (4 * D_INDEX) + 1
#define D_BROWN START + (5 * D_INDEX)

// Function declarations

void ToHSL(float, float, float);
char mmColor(void);
void lcdmsg(char, char);
void wait(long);
void sensorDischarge(void);
void debounce(void);
void debounce2(void);
void showHSL(void);
void wheelAdvance(void);
void lcd_rgb(unsigned int, unsigned int, unsigned int, unsigned int);
void BatteryTest(void);
void powerOff(void);
void ISR_off(void);


unsigned int hue, saturation, luminance;
volatile unsigned char off = LOW;    // Flag set by ISR_off() to signal pushbutton has been pressed to turn off machine.
const char  LCD_I2C = 0x28;   // LCD I2C address

// Colors used by LCD
char red[] = "RED";
char green[] = "GREEN";
char blue[] = "BLUE";
char yellow[] = "YELLOW";
char orange[] = "ORANGE"; 
char brown[] = "BROWN";
char unknown[] = "UNKNOWN";
char empty[] = "EMPTY";
char found[] = "Found color sensor";
char notFound[] = "No TCS34725 found";
char msg[] = "Resetting sensor.";
char here[] = "Here.";

void setup(void) {
  Wire.begin();   // Initialize I2C
  pinMode(LED, OUTPUT);             // LED ring on power pushbutton
  pinMode(PowerIn, INPUT_PULLUP);   // State of power pushbutton; normally closed/normally low/active high
  pinMode(PowerOut, OUTPUT);
  pinMode(Battery, INPUT);
  digitalWrite(PowerOut, HIGH);   // Keep power on once pushbutton released
  digitalWrite(LED, HIGH);
  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(slotSensor, INPUT);   // There's already a pullup on the slotSensor board
  debounce2();
  BatteryTest();    // Test battery voltage and turn off if too low.
  Sensor.attach(9);     // Attaches the color sensor servo on pin 9 to the servo object
  Diverter.attach(10);  // Attaches the diverter tube servo on pin 10 to the servo object
  lcdmsg(msg, 0);
  Sensor.write(TOP);        // Initialize color sensor position.

You didn't post all your code.

Aarg is being a bit short, but he/she's right.

More to the point...not problem with your defines. They ok. My guess...

Somewhere in your main loop, you lost a }{ bracket. When you lose a bracket, the errors bubble up...in your case to near program start. Just go check all open/close state of

{
}

Disregard. Dumb environment setup mistake. Problem solved.