• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
makerhacks-logo

Maker Hacks

Ideas, news & tutorials for makers and hackers – Arduino/Raspberry Pi, 3D printing, robotics, laser cutting, and more

  • Home
  • About
  • 3D Printing
  • Laser Cutting
  • YouTube
  • Free Arduino Course
  • Recommendations
  • Contact

Neo6502 GPIO Input and Output

You are here: Home / Electronics and Hardware / Neo6502 GPIO Input and Output
FacebookTweetPin
Author: Chris Garrett

Neo6502 GPIO Input and Output for electronics programming in BASIC. How to light up and fade an LED, plus read a button as input.

Neo6502 is a new credit card-sized single board computer featuring both a modern 6502 chip and a Raspberry Pi Pico. I reviewed the Neo6502 over on RetroGameCoders, and I love it.

Up until now the main focus of attention has been on programming and running BASIC games, or emulation, such as the Apple II on the device.

Fact is, it can also perform Arduino-like electronics tasks using the GPIO pins, so let’s take a look at how to do that now!

The Neo6502 GPIO Pins

The Neo6502 has two blocks of pins, and what we are talking about today are the “UEXT” pins that are especially for expansion and integrating things like add-ons and sensors, etc.

Neo6502 GPIO pin numbers (UEXT)
Neo6502 GPIO pin numbers (UEXT)

As you can see above, they are numbered from 1 to 10, but 1 and 2 are wired to 3.3v and Ground.

Each can be an input or an output, and can be controlled from the 6502 in BASIC, C, Pascal, or Assembly.

Blink an LED on the Neo6502

Blinking LEDs on the Neo6502 (police lights)
Blinking LEDs on the Neo6502 (police lights)

Of course, the Hello World of the electronics community is a simple blinking LED, so let’s start there!

Just to fancy it up a little, I have two LEDs, red and blue, alternating to make a police light effect:

10 pin 3,output
20 pin 4,output
30 while 1
40 pin 3,1
50 pin 4,0
60 call sleep(50)
70 pin 3,0
80 pin 4,1
90 call sleep(50)
100 wend
1000 proc sleep(delay)
1010 fin=time( ) +delay
1020 while time( ) <fin
1030 ' "wait"
1040 wend
1050 endproc

Here we set pins 3 and 4 as output, and in an infinite loop we repeatedly set each LED on and off, using our sleep() procedure that we set toward the end of the program.

This procedure accepts a number to use as the delay duration, which is added to the current time (in hundredths of a second), and then matched repeatedly.

Reading Input on the Neo6502 GPIO

Reading input on the Neo6502 is really easy. Whereas before we supplied a number to the Pin to tell it we want it on or off, instead we can read the value using pin(Pin_Number):

Read a button press on the Neo6502 gpio
Read a button press on the Neo6502
10 pin 3,output
20 pin 4,input
30 pin 3,pin(4)
40 goto 30

Here we set up a button and read the value. Whatever the value of the button returns, the Pin 3 is set to match.

Neo6502 BASIC to Fade an LED without PWM

The Neo6502 doesn’t have analog pins or PWM, how can we fade an LED?

All we need to do is turn the LED on and off really quickly, and if we do it right our eyes will mistake the flashing for a slightly darker LED brightness.

Fade an LED on the Neo6502, TARDIS style
Fade an LED on the Neo6502, TARDIS style
1000 pin 3,output
1020 call led(0.5)
1030 call led(0.3)
1035 pin 3,0:call sleep(25)
1040 call led(0.1)
1046 call led(0.3)
1048 call led(0.5)
1049 call led(0.8)
1050 pin 3,1:call sleep(25)
1090 goto 1020
1100 proc led(v)
1110 endtime=time( ) +15
1120 pin 3,1
1130 call sleep(v)
1140 pin 3,0
1150 call sleep(v)
1160 if time( ) <endtime then goto 1120
1170 endproc
1180 proc sleep(delay)
1190 fin=time( ) +delay
1200 while time( ) <fin
1210 ' "wait"
1220 wend
1230 endproc

There is a very high probability that I did something very wrong here but it seems to work ok for now, at least until we get a real PWM output on the board!

Next Steps

This is just the start, there are lots of advancements being made on the firmware, and as mentioned you can code the Neo6502 in C/C++ too!.

Category: Electronics and HardwareTag: Makes, neo6502
FacebookTweetPin

About Chris Garrett

Marketing nerd by day, maker, retro gaming, tabletop war/roleplaying nerd by night. Co-author of the Problogger Book with Darren Rowse. Husband, Dad, ?? Canadian.

Check out Retro Game Coders for retro gaming/computing.

☕️ Support Maker Hacks on Ko-Fi and get exclusive content and rewards!

Previous Post:Arduino SID player Arduino SID Player: Play C64 Music on Your Uno
Next Post:PiUSB – How to Make a Wifi Memory Stick Using Pi Zero W

Sidebar

  • Facebook
  • Twitter
  • Instagram
  • YouTube

Join the Newsletter

Sign up and get a free Arduino course + more!

Subscription Form

Recently Popular

  • xTool S1 Review
  • xTool P2 Review (first look)
  • IKIER K1 Pro Max Review
  • Gweike Cloud Review
  • How to choose the right 3D printer for you
  • Glowforge Review – Glowforge Laser Engraver Impressions, Plus Glowforge Versus Leading Laser Cutters
  • Flux Ador
  • Prusa i3 Mk3S Review
  • Best 3D Printing Facebook Groups
  • xTool D1 Pro Laser Cutter Review
  • Elegoo Mars Review – Review of the Elegoo Mars MSLA Resin 3D Printer
  • Glowforge ‘Pass-Through’ Hack: Tricking the Front Flap of the Glowforge with Magnets to Increase Capacity
  • How to Make a DIY “Internet of Things” Thermometer with ESP8266/Arduino
  • Wanhao Duplicator i3 Review
  • IKEA 3D Printer Enclosure Hack for Wanhao Di3
  • Creality CR-10 3d printer review – Large format, quality output, at a low price!
  • 3D Printed Tardis with Arduino Lights and Sounds
  • Anet A8 Review – Budget ($200 or less!) 3D Printer Kit Review
  • Make your own PEI 3D printer bed and get every print to stick!
  • Upgrading the Wanhao Di3 from Good to Amazing
  • How to Install and Set Up Octopi / Octoprint
  • Creality CR-10 S5 Review
  • Glowforge Air Filter Review
  • Thunder Laser Review

30 Days to Arduino

Arduino Tutorials
  • 3D Printing
  • CNC
  • Electronics and Hardware
  • Laser Cutting
  • News and Reviews
  • Software and Programming

arduino budget cad cnc diode laser glowforge Hacks Ideas laser cutter linux Makes making python raspberry pi resin Reviews technology tips xTool Lasers

.

Maker Hacks Blog Copyright © 2026 · All Rights Reserved · Privacy Policy