my first bit shift project

I'm using an adafruit 8x8 bicolor LED display && ADXL335

only using X and Y axis

00000000
00000000
00000000
00011000
00011000
00000000
00000000
00000000

I want the 1's to stay in a 2x2 square, when "bishifting"
also i'm trying to make the color of the display change depending on the value of the pot.
I have a "set color" function and some bitshift instructions.

the biColor display examples from adafruit are poorly commented in my opinion.

this code is a rough draft.... I would appreciate some guidence and/or insite/direction.
I'm also ok with Paying a tip via paypal for a working example code of what i'm trying to achieve.
If more info is needed please comment.

/***************************************************
  This is a library for our I2C LED Backpacks

  Designed specifically to work with the Adafruit LED Matrix backpacks
  ----> http://www.adafruit.com/products/872
  ----> http://www.adafruit.com/products/871
  ----> http://www.adafruit.com/products/870

  These displays use I2C to communicate, 2 pins are required to
  interface. There are multiple selectable I2C addresses. For backpacks
  with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
  with 3 Address Select pins: 0x70 thru 0x77

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
 ****************************************************/

#include <Wire.h>
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"

//Pins
int X_Axis = A0;
int Y_Axis = A2;
int button = 2;

//Constants

//Variables
long X_COLOR;
long Y_COLOR; 
int X_Now;
int X_Then;
int X_Val;
int Y_Now;
int Y_Then;
int Y_Val;

Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();

void setup() {

Serial.begin(9600);
  static const uint8_t PROGMEM
  seven_bmp[] =  // 7
  { B11111110,
    B11111110,
    B00001110,
    B00011100,
    B00111000,
    B01110000,
    B11100000,
    B11000000
  },
  six_bmp[] =  // 6
  { B00111110,
    B01100011,
    B11000000,
    B11111110,
    B11000011,
    B11000011,
    B11111111,
    B01111110
  };

  matrix.begin(0x70);  // pass in the address
  matrix.clear();
  matrix.drawBitmap(0, 0, seven_bmp, 8, 8, LED_YELLOW);
  matrix.writeDisplay();
  delay(750);

  matrix.clear();
  matrix.drawBitmap(0, 0, six_bmp, 8, 8, LED_YELLOW);
  matrix.writeDisplay();
  delay(750);

  CheckSensor();
}
uint8_t 
bmp[] =
{ B00000000,
  B00000000,
  B00000000,
  B00011000,
  B00011000,
  B00000000,
  B00000000,
  B00000000
};

void loop() {

  X_Now = analogRead(X_Axis);
  Y_Now = analogRead(Y_Axis);

  ColorSet();

  if (X_Now - X_Then > 57) {
    //bitshift Left
    X_Then = X_Now;
  }
  if (X_Now - X_Then < 57) {
    //bitshift Right
    X_Then = X_Now;
  }
  if (Y_Now - Y_Then > 57) {
    //bitshift Left "up"
    Y_Then = Y_Now;
  }
  if (X_Now - X_Then < 57) {
    //bitshift Right "down"
    Y_Then = Y_Now;
  }

  Display();
  
}

void Display() {
  matrix.clear();
  matrix.drawBitmap(0, 0, bmp, 8, 8, LED_GREEN); // LED_GREEN
  matrix.writeDisplay();
  delay(50);
}

void CheckSensor() {

  X_Now = analogRead(X_Axis);
  Y_Now = analogRead(Y_Axis);
  Serial.print(X_Now);
  Serial.println(Y_Now);
  Serial.println(" ");

  if (((X_Now > 500) && ( X_Now < 520)) && (( Y_Now > 500) && (Y_Now < 520))) {
     X_Val = X_Now;
     Y_Val = Y_Now;
     X_Then = X_Val;
     Y_Then = Y_Val;
    loop();
  }
  else {
    matrix.clear();
    matrix.drawRect(0, 0, 8, 8, LED_RED);
    matrix.fillRect(2, 2, 4, 4, LED_GREEN);
    matrix.writeDisplay();  // write the changes we just made to the display
    delay(1000);
    setup();
  }
}

void ColorSet() {
  X_Now = analogRead(X_Axis);
  Y_Now = analogRead(Y_Axis);

  // Set Green
  if ((X_Now < 510) && ( X_Now > 514)) {
    X_COLOR = LED_GREEN;
  }
  if (( Y_Now < 510) && (Y_Now > 514)) {
    Y_COLOR = LED_GREEN;
  }
  // Set Yellow
  if (((X_Now < 338 ) && ( X_Now > 342)) || (( X_Now < 680) && (X_Now > 684))) {
    X_COLOR = LED_YELLOW;
  }
  if (((Y_Now < 338 ) && ( Y_Now > 342)) || (( Y_Now < 680) && (Y_Now > 684))) {
    Y_COLOR = LED_YELLOW;
  }
  // Set Red
  if (((X_Now < 168 ) && ( X_Now > 172)) || (( X_Now < 850) && (X_Now > 854))) {
    X_COLOR = LED_RED;
  }
  if (((Y_Now < 168 ) && ( Y_Now > 172)) || (( Y_Now < 850) && (Y_Now > 854))) {
    Y_COLOR = LED_RED;
  }

  X_Then = X_Now;
  Y_Then = Y_Now;
}

updated code with < and > placed correctly. along with some small other changes

/***************************************************
  This is a library for our I2C LED Backpacks

  Designed specifically to work with the Adafruit LED Matrix backpacks
  ----> http://www.adafruit.com/products/872
  ----> http://www.adafruit.com/products/871
  ----> http://www.adafruit.com/products/870

  These displays use I2C to communicate, 2 pins are required to
  interface. There are multiple selectable I2C addresses. For backpacks
  with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
  with 3 Address Select pins: 0x70 thru 0x77

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
 ****************************************************/

#include <Wire.h>
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"

//Pins
int X_Axis = A0;
int Y_Axis = A2;
int button = 2;

//Constants

//Variables
long X_COLOR;
long Y_COLOR; 
int X_Now;
int X_Then;
int X_Val;
int Y_Now;
int Y_Then;
int Y_Val;

Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();

void setup() {

Serial.begin(9600);
  static const uint8_t PROGMEM
  seven_bmp[] =  // 7
  { B11111110,
    B11111110,
    B00001110,
    B00011100,
    B00111000,
    B01110000,
    B11100000,
    B11000000
  },
  six_bmp[] =  // 6
  { B00111110,
    B01100011,
    B11000000,
    B11111110,
    B11000011,
    B11000011,
    B11111111,
    B01111110
  };

  matrix.begin(0x70);  // pass in the address
  matrix.clear();
  matrix.drawBitmap(0, 0, seven_bmp, 8, 8, LED_YELLOW);
  matrix.writeDisplay();
  delay(750);

  matrix.clear();
  matrix.drawBitmap(0, 0, six_bmp, 8, 8, LED_YELLOW);
  matrix.writeDisplay();
  delay(750);

  CheckSensor();
}
uint8_t 
bmp[] =
{ B00000000,
  B00000000,
  B00000000,
  B00011000,
  B00011000,
  B00000000,
  B00000000,
  B00000000
};

void loop() {

  X_Now = analogRead(X_Axis);
  Y_Now = analogRead(Y_Axis);

  ColorSet();

  if (X_Now - X_Then > 57) {
    //bitshift Left
    X_Then = X_Now;
  }
  if (X_Then - X_Now < 57) {
    //bitshift Right
    X_Then = X_Now;
  }
  if (Y_Now - Y_Then > 57) {
    //bitshift Left "up"
    Y_Then = Y_Now;
  }
  if (Y_Then - X_Now < 57) {
    //bitshift Right "down"
    Y_Then = Y_Now;
  }

  Display();
  
}

void Display() {
  matrix.clear();
  matrix.drawBitmap(0, 0, bmp, 8, 8, LED_GREEN); // LED_GREEN
  matrix.writeDisplay();
  delay(50);
}

void CheckSensor() {

  X_Now = analogRead(X_Axis);
  Y_Now = analogRead(Y_Axis);
  Serial.print(X_Now);
  Serial.println(Y_Now);
  Serial.println(" ");

  if (((X_Now > 500) && ( X_Now < 520)) && (( Y_Now > 500) && (Y_Now < 520))) {
     X_Val = X_Now;
     Y_Val = Y_Now;
     X_Then = X_Val;
     Y_Then = Y_Val;
    loop();
  }
  else {
    matrix.clear();
    matrix.drawRect(0, 0, 8, 8, LED_RED);
    matrix.fillRect(2, 2, 4, 4, LED_GREEN);
    matrix.writeDisplay();  // write the changes we just made to the display
    delay(1000);
    setup();
  }
}

void ColorSet() {
  X_Now = analogRead(X_Axis);
  Y_Now = analogRead(Y_Axis);

  // Set Green
  if ((X_Now > 510) && ( X_Now < 514)) {
    X_COLOR = LED_GREEN;
  }
  if (( Y_Now > 510) && (Y_Now < 514)) {
    Y_COLOR = LED_GREEN;
  }
  // Set Yellow
  if (((X_Now > 338 ) && ( X_Now < 342)) || (( X_Now > 680) && (X_Now < 684))) {
    X_COLOR = LED_YELLOW;
  }
  if (((Y_Now > 338 ) && ( Y_Now < 342)) || (( Y_Now > 680) && (Y_Now < 684))) {
    Y_COLOR = LED_YELLOW;
  }
  // Set Red
  if (((X_Now > 168 ) && ( X_Now < 172)) || (( X_Now > 850) && (X_Now < 854))) {
    X_COLOR = LED_RED;
  }
  if (((Y_Now > 168 ) && ( Y_Now < 172)) || (( Y_Now > 850) && (Y_Now < 854))) {
    Y_COLOR = LED_RED;
  }

  X_Then = X_Now;
  Y_Then = Y_Now;
}

[code]

Here's a try. Compiles, not tested...

#include <Wire.h>
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"

//Pins
const byte X_Axis = A0;
const byte Y_Axis = A2;
const byte button = 2;

//where the drawing is going to take place
byte
    bmp[8];

//location of the '11' pair is described by (pairX, pairY)
//X can range from 0 (left-most; first '1' sits at bit position 7) to 6 (right-most; 2nd '1' sits at bit position 0)
//Y can range from 0 (top row) to 6 (bottom row less one)
//
//byte in array to operate on is given by pairY
//bits in byte are pointed to by pairX (and pairX+1)
//  e.g. if (pairX, pairY) are (5, 4)
//  byte = [4]
//  ORmask = (0xC >> pairX)
//  ANDmask = ~(0xC >> pairX)

byte
    pairX,
    pairY;

//  0123456
//0 11000000    shows (0,0)
//1 11000000
//2 00000000
//3 00000000
//4 00000000
//5 00000000
//6 00000011    shows (6,6)
//7 00000011

//color mapping (example)
//  0123456
//0 GGGGGGGG
//1 GYYYYYYG
//2 GYRRRRYG
//3 GYRYYRYG
//4 GYRYYRYG
//5 GYRRRRYG
//6 GYYYYYYG
//7 GGGGGGGG

byte color_map[] = 
{
    LED_GREEN,  LED_GREEN,  LED_GREEN,  LED_GREEN,  LED_GREEN,  LED_GREEN,  LED_GREEN,  LED_GREEN, 
    LED_GREEN,  LED_YELLOW, LED_YELLOW, LED_YELLOW, LED_YELLOW, LED_YELLOW, LED_YELLOW, LED_GREEN,
    LED_GREEN,  LED_YELLOW, LED_RED,    LED_RED,    LED_RED,    LED_RED,    LED_YELLOW, LED_GREEN,
    LED_GREEN,  LED_YELLOW, LED_RED,    LED_YELLOW, LED_YELLOW, LED_RED,    LED_YELLOW, LED_GREEN,
    LED_GREEN,  LED_YELLOW, LED_RED,    LED_YELLOW, LED_YELLOW, LED_RED,    LED_YELLOW, LED_GREEN,
    LED_GREEN,  LED_YELLOW, LED_RED,    LED_RED,    LED_RED,    LED_RED,    LED_YELLOW, LED_GREEN,
    LED_GREEN,  LED_YELLOW, LED_YELLOW, LED_YELLOW, LED_YELLOW, LED_YELLOW, LED_YELLOW, LED_GREEN,
    LED_GREEN,  LED_GREEN,  LED_GREEN,  LED_GREEN,  LED_GREEN,  LED_GREEN,  LED_GREEN,  LED_GREEN 
    
};

Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();


void setup( void )
{
    matrix.begin(0x70);  // pass in the address
    matrix.clear();
    matrix.writeDisplay();

    //not strictly required as pins are input coming out of reset
    //having these pinMode() calls here is just a formality to help us
    //remember the purpose of these signals
    pinMode( X_Axis, INPUT );
    pinMode( Y_Axis, INPUT );

}//setup

void loop( void )
{
    static unsigned long
        timeUpdate = 0;
    int
        readX,
        readY;

    if( millis() - timeUpdate < 50 )
        return;
    timeUpdate = millis();

    //read the X and Y axes
    //the values should range from 0 - 1023
    readX = analogRead( X_Axis );
    readY = analogRead( Y_Axis );
    
    //map the axes to a value from 0 to 6
    //6 is used because 2 pixels are lit so we can max out in both directions at 6
    pairX = map( readX, 0, 1023, 0, 6 );
    pairY = map( readY, 0, 1023, 0, 6 );
    
    //clear the local representation of the bitmap
    //memset is used to write zeros to all bytes in the bmp array
    //could also use a for loop
    memset( bmp, 0x00, sizeof( bmp ) );
    
    //and then write the pairs where needed
    bmp[pairY] |= (0xc0 >> pairX );         //first row
    bmp[pairY+1] |= (0xc0 >> pairX );       //second row
    
    //send this bitmap to the display
    updateBitmap();    
    
}//loop

void updateBitmap( void )
{
    byte
        mask,
        col_index = 0;

    //clear the existing map
    matrix.clear();

    //walk through our internal bitmap; where bits are set, draw a pixel
    //the colour to draw is based on the color_map array above
    for( byte y=0; y<8; y++ )
    {
        //check each bit by ANDing with a mask
        //the mask starts at 0x80, is shifted right each for loop
        //so 40, 20, 10 .. 02 01
        //mask is renewed each Y loop
        mask = 0x80;
        for( byte x=0; x<8; x++ )
        {
            //if bit is set
            if( bmp[y] & mask )
            {
                //draw a pixel there with the mapped color
                matrix.drawPixel( x, y, color_map[col_index] );
                
            }//if

            //shift mask right one bit per pixel
            mask >> 1;
            //and bump color index each pixel
            col_index++;
                
        }//for
        
    }//for

    //update the display
    matrix.writeDisplay();
    
}//updateBitmap

I'm going to play with this and see what happens. At a quick look, the color set up you have isn't quite what I'm looking to do. So the center 2x2 square starts off green and moves around depending on the X,Y values. If the green square were to move "off screen" then start back in the middle, only yellow. Then same thing, if yellow moves off screen. Start in the center with Red

LandonW:
updated code with < and > placed correctly. along with some small other changes

/***************************************************

This is a library for our I2C LED Backpacks

Designed specifically to work with the Adafruit LED Matrix backpacks
  ----> Adafruit Mini 0.8 8x8 LED Matrix w/I2C Backpack - Yellow-Green : ID 872 : $9.95 : Adafruit Industries, Unique & fun DIY electronics and kits
  ----> Adafruit Mini 8x8 LED Matrix w/I2C Backpack - Yellow : ID 871 : $9.95 : Adafruit Industries, Unique & fun DIY electronics and kits
  ----> Adafruit Mini 8x8 LED Matrix w/I2C Backpack - Red : ID 870 : $9.95 : Adafruit Industries, Unique & fun DIY electronics and kits

These displays use I2C to communicate, 2 pins are required to
  interface. There are multiple selectable I2C addresses. For backpacks
  with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
  with 3 Address Select pins: 0x70 thru 0x77

Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

Written by Limor Fried/Ladyada for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
****************************************************/

#include <Wire.h>
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"

//Pins
int X_Axis = A0;
int Y_Axis = A2;
int button = 2;

//Constants

//Variables
long X_COLOR;
long Y_COLOR;
int X_Now;
int X_Then;
int X_Val;
int Y_Now;
int Y_Then;
int Y_Val;

Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();

void setup() {

Serial.begin(9600);
  static const uint8_t PROGMEM
  seven_bmp[] =  // 7
  { B11111110,
    B11111110,
    B00001110,
    B00011100,
    B00111000,
    B01110000,
    B11100000,
    B11000000
  },
  six_bmp[] =  // 6
  { B00111110,
    B01100011,
    B11000000,
    B11111110,
    B11000011,
    B11000011,
    B11111111,
    B01111110
  };

matrix.begin(0x70);  // pass in the address
  matrix.clear();
  matrix.drawBitmap(0, 0, seven_bmp, 8, 8, LED_YELLOW);
  matrix.writeDisplay();
  delay(750);

matrix.clear();
  matrix.drawBitmap(0, 0, six_bmp, 8, 8, LED_YELLOW);
  matrix.writeDisplay();
  delay(750);

CheckSensor();
}
uint8_t
bmp[] =
{ B00000000,
  B00000000,
  B00000000,
  B00011000,
  B00011000,
  B00000000,
  B00000000,
  B00000000
};

void loop() {

X_Now = analogRead(X_Axis);
  Y_Now = analogRead(Y_Axis);

ColorSet();

if (X_Now - X_Then > 57) {
    //bitshift Left
    X_Then = X_Now;
  }
  if (X_Then - X_Now < 57) {
    //bitshift Right
    X_Then = X_Now;
  }
  if (Y_Now - Y_Then > 57) {
    //bitshift Left "up"
    Y_Then = Y_Now;
  }
  if (Y_Then - X_Now < 57) {
    //bitshift Right "down"
    Y_Then = Y_Now;
  }

Display();
 
}

void Display() {
  matrix.clear();
  matrix.drawBitmap(0, 0, bmp, 8, 8, LED_GREEN); // LED_GREEN
  matrix.writeDisplay();
  delay(50);
}

void CheckSensor() {

X_Now = analogRead(X_Axis);
  Y_Now = analogRead(Y_Axis);
  Serial.print(X_Now);
  Serial.println(Y_Now);
  Serial.println(" ");

if (((X_Now > 500) && ( X_Now < 520)) && (( Y_Now > 500) && (Y_Now < 520))) {
    X_Val = X_Now;
    Y_Val = Y_Now;
    X_Then = X_Val;
    Y_Then = Y_Val;
    loop();
  }
  else {
    matrix.clear();
    matrix.drawRect(0, 0, 8, 8, LED_RED);
    matrix.fillRect(2, 2, 4, 4, LED_GREEN);
    matrix.writeDisplay();  // write the changes we just made to the display
    delay(1000);
    setup();
  }
}

void ColorSet() {
  X_Now = analogRead(X_Axis);
  Y_Now = analogRead(Y_Axis);

// Set Green
  if ((X_Now > 510) && ( X_Now < 514)) {
    X_COLOR = LED_GREEN;
  }
  if (( Y_Now > 510) && (Y_Now < 514)) {
    Y_COLOR = LED_GREEN;
  }
  // Set Yellow
  if (((X_Now > 338 ) && ( X_Now < 342)) || (( X_Now > 680) && (X_Now < 684))) {
    X_COLOR = LED_YELLOW;
  }
  if (((Y_Now > 338 ) && ( Y_Now < 342)) || (( Y_Now > 680) && (Y_Now < 684))) {
    Y_COLOR = LED_YELLOW;
  }
  // Set Red
  if (((X_Now > 168 ) && ( X_Now < 172)) || (( X_Now > 850) && (X_Now < 854))) {
    X_COLOR = LED_RED;
  }
  if (((Y_Now > 168 ) && ( Y_Now < 172)) || (( Y_Now > 850) && (Y_Now < 854))) {
    Y_COLOR = LED_RED;
  }

X_Then = X_Now;
  Y_Then = Y_Now;
}

[code]

for some reason I cant copy paste this

LandonW:
I'm going to play with this and see what happens. At a quick look, the color set up you have isn't quite what I'm looking to do. So the center 2x2 square starts off green and moves around depending on the X,Y values. If the green square were to move "off screen" then start back in the middle, only yellow. Then same thing, if yellow moves off screen. Start in the center with Red

I'm sure you can update the code to do what you want.

Thank you very much. For some reason I cant copy paste this code..... I haven't been able to do anything with it. also I've been super busy at the day job so I haven't had a chance to tinker