title: 'accelerometer' and 'lcd' not declared in this scope
body: <p>It's telling me that "accelerometer" and "lcd" were not declared in this scope when they're used in PIT0_IRQHandler. None of the solutions I've found online have worked as of yet so I figured I'd just post it up. I'm pretty new to this as well so feel free to point out any and every error included</p>
  
  <pre><code>    #include &lt;stdio.h&gt;
      #include "system.h"
      #include "derivative.h"
      #include "hardware.h"
      #include "delay.h"
      #include "lcd.h"
      #include "i2c.h"
      #include "level.h"
      #include "mma845x.h"
      #include "tone.h"
      #include "accel.h"
  
      /// LCD dimensions and centerpoint
      #define LCD_WIDTH  (LCD_X_MAX-LCD_X_MIN)
      #define LCD_HEIGHT (LCD_Y_MAX-LCD_Y_MIN)
      #define CENTRE_X   ((LCD_X_MAX-LCD_X_MIN)/2)
      #define CENTRE_Y   ((LCD_Y_MAX-LCD_Y_MIN)/2)
  
      #define BACKGROUND_COLOUR (RED)
      #define FOREGROUND_COLOUR (WHITE)
      #define CIRCLE_RADIUS (20)
  
      using namespace USBDM;
  
      void initialisePIT(int channel, uint32_t interval) {
          // Enable clock to PIT
          SIM-&gt;SCGC6  |= SIM_SCGC6_PIT_MASK;
          // Enable PIT module
          PIT-&gt;MCR     = PIT_MCR_FRZ_MASK;
          // Set reload value
          PIT-&gt;CHANNEL[channel].LDVAL  = interval-1;
          // Enable this channel with interrupts
          PIT-&gt;CHANNEL[channel].TCTRL = PIT_TCTRL_TEN_MASK|PIT_TCTRL_TIE_MASK;
          // Enable PITn interrupts in NVIC
          NVIC_EnableIRQ((IRQn_Type)(PIT0_IRQn+channel));
          // Set arbitrary priority level
          NVIC_SetPriority((IRQn_Type)(PIT0_IRQn+channel), 8);
      }
  
      void initialiseLCD(){
          // Instantiate SPI interface class
          Spi *spi = new Spi0();
          // Instantiate LCD interface class
          Lcd *lcd = new Lcd(spi);
          // Clear Background and set to a preset (Set above) colour
          lcd-&gt;clear(BACKGROUND_COLOUR);
          // Draw crosshairs and initial circle on the screen
          lcd-&gt;drawLine(LCD_WIDTH/2,LCD_WIDTH/2,0,LCD_HEIGHT,BLACK);
          lcd-&gt;drawLine(0,LCD_WIDTH,LCD_HEIGHT/2,LCD_HEIGHT/2,BLACK);
          lcd-&gt;drawCircle(CENTRE_X, CENTRE_Y, 20, WHITE);
      }
  
      void initialiseAccel()
      {
          I2c *i2c = new I2c0();
          MMA845x *accelerometer = new MMA845x(i2c, MMA845x::ACCEL_2Gmode);
      }
  
      void PIT0_IRQHandler(void) {
          int accelStatus;
          int16_t accelX,accelY,accelZ;
          accelerometer-&gt;readAccelerometerXYZ(&amp;accelStatus, &amp;accelX, &amp;accelY, &amp;accelZ);
  
          lcd-&gt;clear(BACKGROUND_COLOUR);
          lcd-&gt;drawCircle(accelX,accelY,20,WHITE);
  
          // Clear the interrupt request from PIT
          PIT-&gt;CHANNEL[0].TFLG = PIT_TFLG_TIF_MASK;
      }
  </code></pre>