Welcome, guest | Sign In | My Account | Store | Cart

This is one of a few Arduino Python snippets to come your way. This one is DEDICATED entirely to the classic stock AMIGA A1200HD emulation inside WinUAE. With a small hardware modification it WILL work on a genuine stock AMIGA A1200HD also see inside the code for more information.

It only requires an ancient version of SATNDARD Python 1.4.x as an absolute minimum, and yes I know it is ancient, but hey, the classic AMIGA is still capable of running Python to version 2.0.x; other AMIGA variants can run much newer versions.

Original copyright, (C)2008, B.Walker, G0LCU. NOW issued as entirely Public Domain...

Certain assumptions have been made and are inside the code.

Also in the code box is the very basic Test.pde file to program the Arduino Diecimila Board with so that this works.

There will be Linux and Windows versions coming that require only STANDARD Python also - NO pySerial is required AT ALL.

Sorry but you will need to split the two pieces of code below manually...

Enjoy finding simple solutions to often very difficult problems...

Python, 102 lines
  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
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
Python Code:-
=============


# Arduino-WinUAE.py
#
# Arduino test for Python 1.4.x under WinUAE only, NOT classic AMIGAs.
# This is an experimental idea only to test the Arduino Diecimila
# development board under Python 1.4.x and WinUAE.
# (It is assumed that the Python 1.4.x install is in the default drawers.)
# NOTE:- This code also works to Python 2.0.x inside WinUAE.
# This working idea is copyright, (C)2008, B.Walker, G0LCU.
# Copy this 'Arduino-WinUAE.py' file into the 'PYTHON:Lib/' drawer
# and you will be ready to roll... ;-)
# Press ~Ctrl C~ to QUIT, OR, set the input to maximum of 5V, i.e. 255.
#
# It is assumed that you have WinUAE 1.5.3 or greater installed and running a
# minimum of EMULATED classic AMIGA OS 3.0x, 68EC020, 2MB RAM, HDD; that is emulating
# a stock A1200HD and Workbench 3.0x. 
# It is assumed that the SER: device is set up in the AMIGA mode.
# See here for the correct parameters:-
# http://aminet.net/package/dev/src/Arduino_Python
# It is assumed that you know how to allocate the Windows COMx: device to WinUAE.
# It is assumed that you know how to connect and set up the USB Arduino Diecimila
# board inside Windows, (32 bit installs)...
# There may be other forgotten assumptions too, not listed here!
#
# To run type:-
# >>> execfile("PYTHON:Lib/Arduino-WinUAE.py")<RETURN/ENTER>
# NOW issued as Public Domain, you may do with it as you please.
#
# IMPORTANT NOTE:- With a piece of simple home built hardware add-on this WILL work
# on a classic AMIGA A1200 with a standard Serial Port also. For this modification see:-
# http://prdownload.berlios.de/mikeos/ARDUINO.zip

# The program proper.
def main():
	print
	print '      Arduino Diecimila Dev Board access demonsration Python 1.4.x code.'
	print '             Original idea copyright, (C)2008, B.Walker, G0LCU.'
	print '                           Press ~Ctrl C~ to QUIT.'
	print

	while 1:
		# Open up a channel for USB/Serial reading on the Arduino board.
		# Place a wire link between ANALOG IN 0 and Gnd.
		# Replace the wire link between ANALOG IN 0 and 3V3.
		# Replace the wire link between ANALOG IN 0 and 5V.
		# Watch the values change.
		pointer = open('SER:', 'rb', 2)

		# Transfer an 8 bit number into `mybyte`.
		mybyte = str(pointer.read(1))

		# Immediately close the channel.
		pointer.close()

		# Print the decimal value on screen.
		print 'Decimal value at Arduino ADC Port0 is:-',ord(mybyte),'.    '

		# Ensure one safe getout when running!
		if mybyte == chr(255): break

main()

# End of program...
# Enjoy finding simple solutions to often very difficult problems.




Arduino Test.pde code:-
=======================

/* Using the Arduino as a DEMO single channel ADC for Windows XP and Linux. */
/* This idea is copyright, (C)2008, B.Walker, G0LCU. */
/* This is just demonstration code only for use with Python 2.6.x or less. */

/* Set up a variable for basic analogue input. */
int analogue0 = 0;

void setup() {
  /* open the serial port at 1200 bps. This rate is used for purely */
  /* for simplicity only. */
  Serial.begin(1200);

  /* Set the analogue voltage reference, DEFAULT is 5V in this case. */
  analogReference(DEFAULT);
}

void loop() {
  /* Read the 10 bit analogue voltage on analogue input 0. */
  analogue0 = analogRead(0);
  /* Convert to a byte value by dividing by 4. */
  analogue0 = analogue0/4;

  /* Send to the Serial Port the byte value. */
  Serial.print(analogue0, BYTE);
 
  /* Delay 500 milliseconds before taking the next reading. */
  delay(500);
}

As WinUAE has no independent analogue I/O I decided to utilise the Arduino Diecimila Board.

This is the Python variant of DEMO code that I have done. There are very simple Arexx, C, and BASIC variants also by me on the AMIGAs AMINET site.

This recipe is Public Domain and you may do with it as you please...

(Sorry to those who have already tried this, the "if" statement had a typo.)

Created by Barry Walker on Sat, 26 Mar 2011 (MIT)
Python recipes (4591)
Barry Walker's recipes (73)

Required Modules

  • (none specified)

Other Information and Tasks