Tag Archives: hardware

Debugging a cool robot

A friend bought a mini robot for his son.
But it didn’t work as it should.

No way i let this opportunity pass to play with it!

This is the one:
https://elektronicavoorjou.nl/product/maqueen-plus-v2/
Maqueen Plus V2 – Geavanceerde STEM Educatie Robot voor micro:bit

https://wiki.dfrobot.com/SKU_MBT0021-EN_Maqueen_Plus_STEAM_Programming_Educational_Robot#target_0

So you can program this in a blockly like manner.

Problems we encountered:

  • Uploading didn’t work
    Solution: Using chrome it had access to the usb port to upload, firefox didn’t work
  • The program didn’t compile, faulty or zero size hex file.
    Solution: Wrong Maqueen library was in the examples
    (After changing, needed version update also, see below)
  • Not everything is in Dutch (I like English, but this is for the boy), maqueen V2 needed a lot of translation.
    (So we joined https://crowdin.com/project/makecode/nl to help translating the libraries)

Apparently my AI camera can be connected to this robot!

Checking faulty chips/hardware

When I fix old hardware I often use a flir camera.

My brother gave me his CAT S60 mobile phone. Which has a flir camera, he used it when he was a voluntary fireman.

Forward-looking infrared (FLIR) cameras, typically used on military and civilian aircraft, use a thermographic camera that senses infrared radiation

Soo .. when testing hardware. I do the following.

  • Clean the motherboard
  • Check chip pins
  • Press all chips/ic’s in their sockets
  • Test the power supply disconnected. ( Most will give a higher voltage when nothing is connected )
  • Measure the resistance of the board (sometimes)
  • Check if the machine can be started.

Now it gets interesting. Sometimes nothing happens. Sometimes the machine runs like it suppose to do.

But old hardware can be faulty or connections are bad. IC’s run hot and they stop working. ( Untill they are cooled enough or they stop forever 🙁 )

So I start monitoring the temperature when I boot the machine. Sometimes components heat up very fast. I use my finger and the flir camera.

These are pictures from my 8088. Nothing runs hot

Old mystery motherboard and Bios hacking – followup

The board seems to be a X Golden Board, except for the missing logo on the motherboard.

Downloaded pcxtbios and compiled the eproms native in linux. So i don´t have to use dosbox any more.
https://github.com/virtualxt/pcxtbios

cd pcxtbios
edit make_linux.sh if needed
./make_linux.sh

and you should end up with
eproms/27512/basicfc.rom
eproms/27512/basicf8.rom
eproms/27512/basicf6.rom
eproms/27512/pcxtbios.rom
eproms/27512/basicfa.rom
eproms/27128/basicfc.rom
eproms/27128/basicf8.rom
eproms/27128/basicf6.rom
eproms/27128/pcxtbios.rom
eproms/27128/basicfa.rom
eproms/27256/basicfc.rom
eproms/27256/basicf8.rom
eproms/27256/basicf6.rom
eproms/27256/pcxtbios.rom
eproms/27256/basicfa.rom
eproms/ibmxt/u18.rom
eproms/ibmxt/u19.rom
eproms/2764/basicfc.rom
eproms/2764/basicf8.rom
eproms/2764/basicf6.rom
eproms/2764/pcxtbios.rom
eproms/2764/basicfa.rom

I didn’t have enough 28C64, but the 28C256 has the same pinout. It just lacks A14 and A13

So I flashed the compiled ROMs for basic to different Eeproms

minipro -w ./2764/basicfc.rom -p AT28C64
minipro -w ./2764/basicf6.rom -p AT28C64
minipro -w ./27256/basicfa.rom -p AT28C256
minipro -w ./27256/basicf8.rom -p AT28C256

These roms need to be placed in sockets ROM6,5,4,3

ROM7 (BIOS)fe00:0-ffff:ffff
ROM6 Basicfc00:0000-fdff:ffff
ROM5 Basicfa00:0000-fbff:ffff
ROM4 Basicf800:0000-f9ff:ffff
ROM3 Basicf600:0000-f7ff:ffff

Machine Code monitor/editor

I tried to find a machine code monitor for 8088 rom, but did not have any luck there.

I tried mumon88, but that didn´t work.

Old mystery motherboard and Bios hacking

When selling a large part of my computer collection I kept a few odd pieces.

Amongst those was a 8088 DIY machine.

It is a 50PTX3 motherboard with a 8088 compatible CPU

  • Power light (Not LED) and connected to power adaptor, not motherboard
  • Reset button??? not connected
  • Power switch
  • Mid center, 5v gnd and 12v
  • 5.25″ drive not connected
Bottom

Tested the power adapter first, a nice 5V and 12V.
Then I plugged the power in the Motherboard add plugged a test ISA card in the slot.
After turning the machine on I saw the Address leds flashing

A NEC D70108C from 1984, which is 8088 pin compatible with Intel 8088 but faster, and has some extra functionality.
The empty socket is for the 8087 Co-processor.

Nec V20 versus 8088

Everything pretty dirty

Rom 2764 (8Kb) and a disconnected speaker wire.

Adding an 8bit Isa hercules/CGA card.

It starts! .. But there is no Floppy controller (yet)

I’ve dumped the Bios to a file and used a hexeditor to play around.
So that’s why there is a bad checksum.

Installing a ZIF socket (Zero Insertion Force) to make things easier to modify.

Burned GlaBios on the Eprom and now I can continue to play around.

So why? Why this all ..

I want to play around with old 8088 assembly code again, but not as I did before using a Dos machine, but hardcoded into Eproms.
I’ve got 8 banks for ROMs and the source code for GlaBios is available.

In the past Edk and me wrote a boot demo, so it was not utilizing Ms-Dos functions. Maybe i can get some graphical and sound stuff working straight from the Bios.

Some commands:

# Dump the bios to file
minipro -w original.rom -p AT2764A@DIP28

xxd and hexdump to view the dump

I've used ghex to alter the ROM

# Write a new bios to a 28C64 (same Eeprom i've used for the C64 Cartridges)
minipro -w /home/henri/Downloads/MYROM -p AT28C64
 

GlaBios source code:
https://github.com/640-KB/GLaBIOS/blob/main/src/GLABIOS.ASM

I was planning to disassemble the Phoenix Bios, but it’s quite hard to differentiate between code and data, there are no named pointers and you have to interpret every line of code.

So GlaBios it is ..

First code to look at:

This is after the whole post reset.
There is a reset pointer at ffff:fffe
Which points to the bootstrap routine, which ends in below machine code.
I'm going to plug my own code over here.

(See the funny remark about Monster as being displayed in one of above pictures)

;----------------------------------------------------------------------------;
; INT 18 - Unbootable IPL
;----------------------------------------------------------------------------;
; Display a disk boot failure message and wait for a key to cold reboot.
;
; This may be re-vectored to ROM BASIC, if present.
;
; Size: 18 bytes
;----------------------------------------------------------------------------;
INT_18 PROC
		ASSUME DS:_BDA_ABS
	PRINT_SZ  BOOT_FAIL			; print boot failure string
	XOR	AX, AX				; AH = 0 (wait for key)
	MOV	DS, AX				; DS = 0000
	MOV	WARM_FLAG_ABS, AX			; do a cold boot
	INT	16H					; wait for key press
	JMP	BOOT					; reboot
INT_18 ENDP

BOOT ENDP

;----------------------------------------------------------------------------;
;
; END OF BIOS POST/BOOTSTRAP
;
;----------------------------------------------------------------------------;

		ASSUME DS:_BDA
STRINGS PROC
;----------------------------------------------------------------------------;
; Banner Strings
;
BANNER_STRINGS PROC

					IF POST_GLADOS EQ 1
BOOT_BEGIN		DB	CR, LF
			DB	'Starting GLaDOS...'
NL2_Z			DB	LF				; two NL's, null term'd
					ENDIF
NL_Z			DB	CR, LF, 0			; one NL, null term'd
BOOT_FAIL		DB	'Disk Boot Fail.'
			DB	' You monster.'
NL2_ANY_KEY		DB	LF
NL_ANY_KEY		DB	CR, LF
ANY_KEY		DB	'Press the Any Key'
			DB	'...'

Assembly stuff

I’ve got Dosbox installed on my machine.

git clone https://github.com/640-KB/GLaBIOS.git
I copied MASM.EXE and LINK.EXE in the GLaBios src directory.

edit make.bat

change
MASM GLABIOS;
into
MASM /DVER_DATE=”05/24/23″ /DARCH_TYPE=”T” /DCPU_TYPE=”V” GLABIOS;

start dosbox

mount c: /home/henri/projects/

c:

cd glabios/src

make.bat

SDK-85 Cassettes

Started drawing a Cassette interface in Kicad.
This so i can read back my old cassettes with programs.
(And write some new stuff)

I’m planning to buy a small micro cassette player.
With schematic below, I’m going to use it as save/load device.
But also with the same player, I’m going to convert the tape to a wave file, and try to decode the program using python.

While I’m at it, reading the old manuals, a RS-232 interface would be nice also!

UPDATE 20231016

This is the final version

Information about the 7655A.
A eprom WITH IO ports! Amazing piece of history hardware.

Testing some sims on Linux and Android

JiffyDos notes (work in progress)

JiffyDOS is an enhanced DOS for the C64. The software is programmed onto ROM chips that replace the Kernal ROM chip on the motherboard and the DOS ROM chip in the disk drive. JiffyDOS is intended to provide greater speed, commands and convenience than on stock systems.

The 1541 drive is a computer on its own, using a 6502 and VIA chips.
(See other pages) (C64 uses a 6510, that is the same slightly modified version of the 6502)
A cool example of the drive being an OS/computer on its own:
https://www.youtube.com/watch?v=zprSxCMlECA

Some notes:

  • I want to use a larger rom and using the higher address lines as kernal selector. Address line A13 and A14 can be used as selector
  • There is a schematic out there using runstop at boottime to do de selection of the rom part

Did I misspell kernel? NO
(Below from Wikipedia)

The KERNAL was known as kernel inside of Commodore since the PET days, but in 1980 Robert Russell misspelled the word as kernal in his notebooks. When Commodore technical writers Neil Harris and Andy Finkel collected Russell’s notes and used them as the basis for the VIC-20 programmer’s manual, the misspelling followed them along and stuck.

Original Kernal: 901227-03
8-kilobyte 2364 ROM 4K * 8 bits PROM

28C265 = 32K * 8bits

Diffference in ROM size AND there are some other pin placements.
V0.1

Romselect should be /(a15 * a14 * a13) depending on ram/rom switch.


SEL0SEL1
00rom0
01rom1
10rom2
11rom3

$E000-$FFFF – ROM
57344-65535

KERNAL ROM or RAM area (8192 bytes); depends on the value of bits #0-#2 of the processor port at memory address $0001
$FFFA-$FFFF – hardware vectors

%x0x: RAM area.

%x1x: KERNAL ROM.

3D printing problem and Fluxengine

3D printed a case for my fluxengine.

Last week I got my 1.2MB 5.25″ drive.
And tested it with the fluxengine.
Now i can read old 5.25″ disks again. And convert these to disk images.
Amiga/Atari ST/C64 (single side) and my old MSDos disks.
(That’s what I’m using, the fluxengine can read many more)

Why single side C64? you ask?
Those are flippy disks, that means they are single sided and you flip the disk in the drive to read the other side.

Why can’t the fluxengine read those?

  • There is only one sensor in my drive.
  • Reading side 2 without turning the disk won’t work, the sectors are in reverse!
    (Maybe there is a trick to read in reverse? Fluxengine is reading and decoding raw disk sectors, but i have to read into this)

Note: The 1541 Drive for the commodore’s is a complete 6502 computer with 2x 6522 VIA and ram/rom chips! (2016-15 2K x 8 bit Static RAM / 27128 16kb x 8)

see: https://www.henriaanstoot.nl/tag/6502/

And this amazing trick:

https://www.youtube.com/watch?v=zprSxCMlECA

Maybe i’m going to modify my 5.25 drive with another index sensor.

So i downloaded a diskdrive case from thingiverse, which can hold 2 drives. 3.5″and 5.25″.
https://www.thingiverse.com/thing:3089895

I started printing the bottom, no problem there. But because of the large size of bottom and top. (Both about a day of printing) I had to change the filament.
But I didn’t have a good look at what I took!
Below is what you get when printing PLA and switch to PETG!

Temperatures for PLA:
Tool: 200 and bed 50
Temperatures for PETG:
Tool: 240 and bed 70


So 12 hours printing and I had to start again.

I could not remove the knob, else I would have removed the beige front and spray painted this black.

Backtracking maze generation with Arduino

As POC for the maze game.

Maze generation!

Make an initial cell the current cell
   mark it as visited
While there are unvisited cells
   If the current cell has any neighbours
   which have not been visited
         Choose randomly one of the unvisited neighbours
                Push the current cell to the stack
                Mark wall hole
                Make the chosen cell the current cell
                mark it as visited
        Else if stack is not empty
                Pop a cell from the stack
                Make it the current cell

This is my implementation of backtracking

The displaymatrix function is a implementation of different led mappings

Still have to decide where to place endpoint …
At 8,8 or at first stack pop?
Maybe both?

Code

#include <WEMOS_Matrix_LED.h>
#include <StackArray.h>

int directions[4]{};
int notalldone = 1;
int tmpx=0;
int tmpy=0;
int x = 1;
int y = 1;
MLED mled(5); //set intensity=5

int maze[8][8] = { 
  };

int displaymatrix[8][8] = { 
{ 0,1,2,3,4,5,6,7 },
{ 8,9,10,11,12,13,14,15 }, 
{16,17,18,19,20,21,22,23},
{24,25,26,27,28,29,30,31},
{32,33,34,35,36,37,38,39},
{40,41,42,43,44,45,46,47},
{48,49,50,51,52,53,54,55},
{56,57,58,59,60,61,62,63}
};

int visitmatrix[10][10] = { 
  1,1,1,1,1,1,1,1,1,1,
  1,0,0,0,0,0,0,0,0,1,
  1,0,0,0,0,0,0,0,0,1,
  1,0,0,0,0,0,0,0,0,1,
  1,0,0,0,0,0,0,0,0,1,
  1,0,0,0,0,0,0,0,0,1,
  1,0,0,0,0,0,0,0,0,1,
  1,0,0,0,0,0,0,0,0,1,
  1,0,0,0,0,0,0,0,0,1,
  1,1,1,1,1,1,1,1,1,1
  };

void setup() {
    Serial.begin(115200);
    randomSeed(analogRead(0));
    mazegen();
    drawmaze();
}

void mazegen(){
  visitmatrix[x][y]=1;       
  StackArray <int> rowStack; 
  StackArray <int> colStack;
        rowStack.push(x);
        colStack.push(y);
  while(notalldone == 1){    
     visitmatrix[x][y]=1;
        while(!rowStack.isEmpty()) {
        int count=0;
        //up
        if ( visitmatrix[x-1][y] == 0 ){
          directions[count]=1;
          count++;    
        }
        //right
        if ( visitmatrix[x][y+1] == 0 ){
          directions[count]=2;
          count++;    
        }
        //down
        if ( visitmatrix[x+1][y] == 0 ){
          directions[count]=4;
          count++;    
        }
        //left
        if ( visitmatrix[x][y-1] == 0 ){
          directions[count]=8;
          count++;    
        }  
        // no dir found
        if (count == 0 ) {

          mled.dot(x-1,y-1);
          mled.display();
          x = rowStack.pop();
          y = colStack.pop();

          Serial.println("popping ");
          } else {
          // count random direction
          int dir = directions[random(count)];
          Serial.println("push ");
          rowStack.push(x); 
          colStack.push(y);
          Serial.print("nr dir : "); 
          Serial.println(count);
          //delay(100);
          Serial.println(dir);
          // move 1,1 to 0,0
          mled.dot(x-1,y-1);
          mled.display();
          // set direction in maze, dit moet bit set worden
          int mybits = maze[x-1][y-1];
          int storedir = mybits | dir;
          maze[x-1][y-1] = storedir;
          if ( dir == 1){
          int getup = maze[x-2][y-1];
          int storedir = getup | 4;
          maze[x-2][y-1] = storedir;
          }
          if ( dir == 2){
          int getup = maze[x-1][y];
          int storedir = getup | 8;
          maze[x-1][y] = storedir;
          }
          if ( dir == 4){
          int getup = maze[x][y-1];
          int storedir = getup | 1;
          maze[x][y-1] = storedir;
          }
          if ( dir == 8){
          int getup = maze[x-1][y-2];
          int storedir = getup | 2;
          maze[x-1][y-2] = storedir;
          }


          
        //  maze[x-1][y-1] = dir;
          //set new square
          if (dir == 1){ x--; }
          if (dir == 2){ y++; }
          if (dir == 4){ x++; }
          if (dir == 8){ y--; }
          visitmatrix[x][y]=1;
          drawmaze();
          }
        }
        notalldone = 0;                                                  //#2
        // if found 0 in 10x10 matrix visited, do
        for(int checkx=0;checkx<10;checkx++){
          for(int checky=0;checky<10;checky++){
            if ( visitmatrix[checkx][checky] == 0 ){
              tmpx=x;
              tmpy=y;
              notalldone = 1;  
            }
          }
        }
   }
rowStack.push(tmpx); 
colStack.push(tmpy);
}



void drawmaze(){
  Serial.println("Generating done - Drawing");
  for(int ledx=0;ledx<8;ledx++)
  {
    for(int ledy=0;ledy<8;ledy++){
    Serial.print(maze[ledx][ledy]);  
    if ( maze[ledx][ledy] != 0 ) {
        mled.dot(ledx,ledy); // draw dot
        mled.display();
       // delay(50);
    }
      }  
    Serial.println("");
  }
  Serial.println("");
  delay(100);
}


void loop() {
}

Little Led Matrix Maze game

While doing stuff like, making our home a little greener. Smoking meat. Working on diorama’s and my Escape game. I found time to make this little maze game.

Using an ESP32, mini joystick and a 8×8 led matrix. The objective is to get to the other side of the invisible maze.

It is a blind maze, so you have to figure out the path by trail and error. I found it quite fun and entertaining. (Coline had a hard time finishing the mode 3 maze)

I’ve got 3 settings on the maze:
0 – There is a trail where you have been.
1 – No trail, but only red leds showing walls.
2 – No trail, red reds and a reset to square 0,0 .. so you have to remember the path you previously took.

I’ll add code and schematics tomorrow …

Light blue shows you where you have been

Mode 2 game, reset when hitting a wall

Hitting the end block!

Maze is static at the moment, i’m planning to implement a “Recursive division method” to generate the maze.

Code

#include <Arduino.h>
#include <Adafruit_NeoPixel.h>

// joystick pins
int up=33;
int down=25;
int left=32;
int right=26;
int cursor=32;

// 0 easy = trail // 1 only red walls // 2 = reset to 0.0
int mode=2;

//int trail=32;
int trail=0;

// Which pin on the Arduino is connected to the NeoPixels?
#define LED_PIN    2

// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 64

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

// bits set opening in square
//    2
//   -----
// 1 |   | 4
//   -----
//     0
// so 5 is a passage from left to right (1+4) 

int maze[8][8] = {
  4,5,3,6,5,5,5,3,
  6,5,11,12,5,3,6,9,
  14,1,12,5,3,10,12,1,
  12,5,5,3,10,12,5,3,
  2,6,5,9,14,5,1,10,
  10,10,6,5,9,6,5,9,
  12,11,10,6,1,10,6,1,
  4,9,12,13,5,13,13,1,
  };

int displaymatrix[8][8] = { 
{ 0,1,2,3,4,5,6,7 },
{ 15,14,13,12,11,10,9,8 }, 
{16,17,18,19,20,21,22,23},
{31,30,29,28,27,26,25,24},
{32,33,34,35,36,37,38,39},
{47,46,45,44,43,42,41,40},
{48,49,50,51,52,53,54,55},
{63,62,61,60,59,58,57,56}
};

int x = 0;
int y = 0;

void setup() {
// joy
  pinMode(32, INPUT_PULLUP);
  pinMode(33, INPUT_PULLUP);
  pinMode(25, INPUT_PULLUP);
  pinMode(26, INPUT_PULLUP);

// mode set with jumpers
  pinMode(34, INPUT_PULLUP);
  pinMode(35, INPUT_PULLUP);

  Serial.begin(115200);

  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  strip.setBrightness(10);
// set begin and end pixel
  strip.setPixelColor(displaymatrix[x][y], 0, 0, 255);
  strip.setPixelColor(displaymatrix[7][7], 0, 255, 0);

  strip.show();
//mode select  
 if (digitalRead(34) == 0) {
 mode=0;
 if (digitalRead(35) == 0) {
 mode=2;
 } else { 
 mode=1; 
 }
// finish effect
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

// reset to start (mode 2)
void reset2start() {
      strip.setPixelColor(displaymatrix[x][y], 0, 0, 0);
    strip.show();
  x = 0;
  y = 0;
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  strip.setBrightness(10);
  strip.setPixelColor(displaymatrix[x][y], 0, 0, 255);
  strip.setPixelColor(displaymatrix[7][7], 0, 255, 0);
  strip.show();

}
// finish effect
void rainbow(uint8_t wait) {
  uint16_t i, j;
  for(j=0; j<256; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

void loop() {
    int isUp = (bitRead(maze[x][y], 1));
    int isRight = (bitRead(maze[x][y], 2));
    int isDown = (bitRead(maze[x][y], 3));
    int isLeft = (bitRead(maze[x][y], 0));
if (digitalRead(up) == 0) {
  if (isUp == 1){
  strip.setPixelColor(displaymatrix[x][y], 0, 0, trail);
  x++;
  if ( x > 7) { x=7;}
  strip.setPixelColor(displaymatrix[x][y], 0, 0, 255);
  strip.show();
  } else {
    strip.setPixelColor(displaymatrix[x][y], 255, 0, 0);
    strip.show();

    if (mode == 2){ 
      delay(1000);
      reset2start();
    }
  }
}
if (digitalRead(down) == 0) {
  if (isDown == 1){
  strip.setPixelColor(displaymatrix[x][y], 0, 0, trail);
  x--;
  if ( x < 0) { x=0;}
  strip.setPixelColor(displaymatrix[x][y], 0, 0, 255);
  strip.show();
  } else {
    strip.setPixelColor(displaymatrix[x][y], 255, 0, 0);
    strip.show();

    if (mode == 2){ 
      delay(1000);
      reset2start();
    }
  }
}
if (digitalRead(left) == 0) {
  if (isLeft == 1){
  strip.setPixelColor(displaymatrix[x][y], 0, 0, trail);
  y--;
  if ( y < 0) { y=0;}
  strip.setPixelColor(displaymatrix[x][y], 0, 0, 255);
  strip.show();
  } else {
    strip.setPixelColor(displaymatrix[x][y], 255, 0, 0);
    strip.show();
    if (mode == 2){ 
      delay(1000);
      reset2start();
    }
  }
}
if (digitalRead(right) == 0) {
  if (isRight == 1){
  strip.setPixelColor(displaymatrix[x][y], 0, 0, trail);
  y++;
  if ( y > 7) { y=7;}
  strip.setPixelColor(displaymatrix[x][y], 0, 0, 255);
  strip.show();
  } else {
    strip.setPixelColor(displaymatrix[x][y], 255, 0, 0);
    strip.show();

    if (mode == 2){ 
      delay(1000);
      reset2start();
    }
  }
}
if (x ==7 && y == 7){
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  rainbow(20);
}
delay(200);

}

Converting a analog joystick to digital

When you need a large digital joystick, but only got an analog one. You can use below code to make the joystick act as a digital one.

I’ve played with analog joysticks on digital pins also, it can be done. But it can be buggy, and needs extra code.

Note: The joystick pins are marked with 5V, but when you use a Arduino which can only read till 3.3V using its ADC (Analog Digital Convertors), you can get some weird readings.
When moving down and left is reads okay, but up and right react as being connected together!
Just try it with 3.3V or use a resistor.

Above shows a ESP32, but below code has Arduino Nano pin names, change accordingly.

CODE

The code gives you a direction only once, you will need to move the stick to the middle position first and then move again.

Below gave me readings between 0 and 1024 (10 bits)
Hence the between 350 and 650 for the middle position.

Most will give you a reading between 0 and 4096.

Want to set the resolution yourself?

  analogReadResolution(10); // 10 bits
int val1 =0;
int val2 =0;

void setup()
{
    Serial.begin(9600);
}

void loop()
{
    int sensorValue1 = analogRead(A0);
    int sensorValue2 = analogRead(A1);

    if (sensorValue1 > 650){
      if (val1 == 0){ 
      Serial.print("DOWN");
      Serial.println(" ");
      val1=1;
      }
    }
    else if (sensorValue1 < 350){ 
      if (val1 == 0){
       Serial.print("UP");
      Serial.println(" ");
      val1=1;
      }
    }
    else if (sensorValue2 > 350 && sensorValue2 < 650){
      val1=0;
    }
    
    
    if (sensorValue2 > 650){
      if (val2 == 0){ 
      Serial.print("LEFT");
      Serial.println(" ");
      val2=1;
      }
    }
    else if (sensorValue2 < 350){ 
      if (val2 == 0){
       Serial.print("RIGHT");
      Serial.println(" ");
      val2=1;
      }
    }
    else if (sensorValue2 > 350 && sensorValue2 < 650){
      val2=0;
    }

    delay(100);
}