COS SIN - analog needle gauge line code display - using Adafruit_SSD1306 128x64

it was very hard to find a simple example of an analog gauge, using the COS\SIN function.
this is basic, simple and a good starting point to play with.

modify and reply your own version, lets see what you can do :slight_smile:

so if anyone wants the full working code:

<Adafruit_SSD1306.h> SPI 128x64 screen
must read:

void loop() {


float angle  = (PI/1023) * analogRead(0);     // map analog in 0,1023, to 0.00,3.14
int length = 50;                                          // line height Ratio of Screen 0-64
const byte x0 = 64;                                    // x0 Line Start 0-128
const byte y0 = 63;                                    // y0 Line Start 0-64

byte x1 = x0 - length * cos (angle);
byte y1 = y0 - length * sin (angle);

display.drawLine(x0, y0, x1, y1, WHITE); // write to screen

this code does not include the SETUP and global \ library code.
but you can get it from a TEST or EXAMPLE code of the Adafruit_SSD1306 below.

get that working with your display first, then replace the void loop.

thanks all who helped, the COS\SIN code can be hard to understand. (y)