MODERN VINTAGE LAB / EXPERIMENT 003

Commodore 64 – Light Sensor

Turning a classic 8-bit computer into an experimental optical data acquisition system.

STATUS: WORKING PROTOTYPE


01 / Introduction

Can a Commodore 64 measure changes in ambient light and visualise the results in real time?

This experiment combines original Commodore hardware with a light-dependent resistor and a modern analogue-to-digital converter. The computer records changes in light intensity and presents the resulting data graphically.

The project represents a first step towards using vintage computers as experimental instruments for environmental monitoring and physical measurements.

02 / Hardware

  • Commodore 64
  • MOS Technology 6510 processor
  • MOS 6526 CIA interface
  • PCF8591 analogue-to-digital converter
  • HW-011 module with integrated light-dependent resistor
  • 24-contact user port edge connector (12 contacts on each side)
  • Connecting wires

03 / Physical Measurement Principle

A light-dependent resistor (LDR) is an electronic component whose electrical resistance changes depending on the amount of incident light.

Under brighter illumination, the resistance generally decreases. In darkness, the resistance increases. A voltage divider converts this resistance variation into a measurable analogue voltage.

Optical Signal Processing

Light intensity → Resistance variation → Analogue voltage → Digital value → Graphical display

The relationship between illumination and LDR resistance is generally nonlinear. Without calibration, the recorded values represent relative changes in light intensity rather than absolute illumination in lux.

04 / Analogue-to-Digital Conversion

The digital user port of the Commodore 64 cannot directly measure an analogue voltage. The PCF8591 provides the required conversion between the analogue sensor signal and digital computer data.

ParameterSpecification
ConverterPCF8591
ModuleHW-011
Resolution8 bit
Digital values0–255
Measurement levels256
Analogue input channels4
CommunicationI²C
Supply voltage5 V

For a nominal reference voltage of 5 V, an ideal 8-bit converter has a quantisation step of approximately 19.5 mV.

This theoretical voltage resolution must not be confused with the actual accuracy of the complete optical measurement system.

05 / User Port and Sensor Connections

The HW-011 module communicates with the Commodore 64 through two programmable digital signal lines. The prototype receives its power from the user port.

ConnectionFunction
VCC5 V supply
GNDCommon ground
SDASerial data
SCLSerial clock

The onboard light sensor is connected to an analogue input of the PCF8591 through the module configuration jumpers.

The exact user port pin assignment, analogue channel and jumper configuration will be documented after verification against the working hardware and original source code.

Always disconnect the computer from its power supply before modifying the circuit. Verify the connector orientation and electrical connections before switching on.

06 / I²C Communication

The Commodore 64 does not contain a dedicated hardware I²C controller. Communication with the PCF8591 is implemented in software using the programmable digital lines of the CIA interface.

This technique, known as bit-banging, allows the computer to generate the serial clock and data signals required to communicate with modern electronic components.

07 / Data Acquisition

  1. Ambient light reaches the light-dependent resistor.
  2. The sensor resistance changes.
  3. The resulting analogue voltage is converted into an 8-bit value.
  4. The Commodore 64 reads the digital value via I²C.
  5. The software processes and displays the measurement.
  6. The measurement cycle is repeated.

08 / Software and Programming

The experimental software combines Commodore BASIC with 6510 assembly language routines.

Assembly language provides direct access to the digital hardware and handles communication with the analogue-to-digital converter. BASIC can be used to process the acquired values, control the experiment and generate graphical output.

In one version of the experimental software, the machine language routine starts at memory address $C000. The acquired measurement value is stored at address $C800.

FunctionHexadecimalDecimal
Machine language routine$C00049152
Measurement value$C80051200
SYS 49152
PRINT PEEK(51200)

This example calls the previously loaded machine language routine and reads the resulting measurement value. It is not a standalone sensor program.

The exact sampling frequency and measurement timing depend on the software version and will be documented after verification.

09 / Graphical Visualisation

Several graphical interfaces were developed to visualise the acquired light sensor data on the Commodore 64.

  • Numerical display of raw sensor values
  • Horizontal bar graph
  • Relative light intensity scale
  • Time-dependent graphical representation

The graphical design was inspired by historical scientific instruments and early computer-based data acquisition systems.

10 / Practical Experiment

One practical application of the system is the investigation of light changes inside a refrigerator.

The sensor can be used to observe the transition between darkness and illumination when the refrigerator door is opened or closed.

Although a relatively simple experiment, it demonstrates the ability of a vintage computer to observe physical processes outside its own electronic environment.

11 / Results and Limitations

The working prototype demonstrates that the Commodore 64 can acquire, process and visualise analogue sensor information using modern electronic components.

The measurement characteristics are influenced by several factors:

  • Nonlinear response of the light-dependent resistor
  • Sensor orientation and illumination geometry
  • Spectral characteristics of the light source
  • Analogue-to-digital converter resolution
  • Reference voltage stability
  • Software sampling interval

Absolute illumination measurements would require calibration against a suitable reference instrument. The current prototype is intended for relative optical measurements and experimental demonstrations.

12 / Development and AI

This project combines practical electronics, original vintage computer hardware and AI-assisted software development.

The experimental concept, hardware assembly, graphical design decisions and practical testing were carried out by Retro Area 51. Artificial intelligence assisted in the development, modification and troubleshooting of the software.

The aim is to demonstrate how modern development tools can support new applications for historical computer systems.

13 / Downloads

  • Commodore BASIC source code
  • 6510 assembly source code
  • Executable Commodore program (.PRG)
  • Hand-drawn wiring diagram
  • Technical project documentation

DOWNLOADS: IN PREPARATION

14 / Future Development

  • Calibration against a reference light meter
  • Long-term environmental monitoring
  • Adjustable measurement intervals
  • Storage and export of recorded measurements
  • Simultaneous acquisition of multiple sensor channels
  • Adaptation to the Commodore PET series

RETRO AREA 51 · MODERN VINTAGE LAB

Preserving the past. Engineering the future.