Analog line meter

Hi, Im trying to implement and analog line meter that takes a value from an LDR. I have drew the arc but I dont understand how I can get the line to move depending on what value comes from the LDR. a pointer in the right direction to what i should be looking up is appreciated.

but I dont understand how I can get the line to move

What line, can you be more descriptive about what hardware you have got or what you want.

The arc at the bottom left is where i want my meter, it will take a value from the LDR between 0 - 1023 and the line will move from the left around the arc.

Do you want to convert the value (0..1023) to an angle?

assuming you do:

consider 0,0 as the midpoint of the arc, and R its radius,

float alpha = 180 - analogRead(A0) / 5.68333;
int x = R * cos(alpha):
int y = R * sin(alpha);
line 0,0, x, y;

you need to keep the XY value to clear the line before drawing the next;

Hi, thanks for the help, Im still having problems

When I use your code i get a cant convert float to int

so I tried after converting value from LDR, float angle = 180 - (LDR / 5.68333);

float x = 90 + 65 * cos(angle);
float y = 490 + 65 * sin(angle);
line (90,490,x,y);

Now I got a perfect line from midpoint of arc to edge of arc, but the angle in the debug output: example 156.732 doesnt match where the needle in the meter is, the needle is shifting all the time even though the LDR is giving a constant value?

What is the range of the LDR ? minimum and maximum?
ok from 0-1023

My mistake sin() and cos() needs radians. OK try this:

float angle = 3.14159265 - (LDR / 325,6310);
float x = 90 + 65 * cos(angle);
float y = 490 + 65 * sin(angle);
line (90,490,x,y);

Thats worked great, the needle was going around the bottom of the arc so I just done a -325.6310 and that put the needle in the proper position, Im getting data through every 3 seconds so the needle doesn't move in a smooth fashion but the data is being collected long term so that doesn't matter, My trig is so bad I think I'll need to spend some time brushing up on it, thanks for your help.

You can do some smoothing like this:

  float newAngle =  3.14159265 - (LDR / 325,6310);

  #define  ALPHA = 0.2;
  static float angle = ALPHA * newAngle + (1-ALPHA ) * angle;  // changes smoothly to new value, speed depends on ALPHA

  int x = 90 + 65 * cos(angle);
  int y = 490 + 65 * sin(angle);
  line (90,490, x, y);

OR average multiple readings (takes more time)

int LDR = 0;

#define NR_LDR_READS  4

for (uint8_t i =0; i< NR_LDR_READS; i++) LDR += analogRead(LDRPIN);
LDR /= NR_LDR_READS;
etc.

Played around with the formula a bit, I got some nice smooth motion with alpha set to 0.950, would probably be better to take an average though, Im going to get the arduino system to do a bit more processing, get a background template and just have processing do the data representation.