Overall the aim is to achieve a snake of a certain length that moves with the analogue stick and almost wiggles and curves with the movement of the stick if you can imagine that. Sorry probably should've mentioned that in the first place.
So when I run my code at the moment it seems to just draw circles randomly in relation to the analog stick movement. Again Im not sure why its doing this but maybe something to do with the frame rate? it seems to me I want it to be drawing the circles (or snake) constantly so it has a smooth movement.
Also in regards to the mapping limits, yes I need to do this as the circles are only appearing on the edges and certain places on the LCd screen most likely because the values from the analogue stick are not mapped to that of the screens dimensions. The screen is 84x84 pixels and the analogue stick produces a value from 0 - 660 roughly in both the X and the Y directions.
Here is my code again, slightly modafied:
#include <SPI.h>
#include <EEPROM.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
Adafruit_PCD8544 display = Adafruit_PCD8544(3,4,5,6,7); //Initialise display object
// analog
int pin_x = 0;
int pin_y = 1;
int initialLength = 5;
void setup(){
Serial.begin(9600); //Begin Serial Communication
display.begin();
display.setContrast(25);
display.clearDisplay();
display.setTextSize(1); //Initial Display
display.setTextColor(BLACK);
//start up screen
/*
Serial.begin(9600); //Begin Serial Communication
display.begin();
display.setContrast(25);
display.clearDisplay();
display.setTextSize(1); //Initial Display
display.setTextColor(BLACK);
display.setCursor(10,15);
display.print("snake movement");
display.display();
delay(4000);
display.begin();
display.clearDisplay();
*/
}
void loop(){
int Ax = analogRead(pin_x);
int Ay = analogRead(pin_y); // read in analogue stick values
//Draw the snake
for(int i=0;i<initialLength;i++)
{
display.drawCircle(Ax,Ay,1,BLACK);
}
display.display();
}