Arduino-Windows2x.py
Finally the Windows 32 bit version of the other recipes of similar design. (The AMIGA/WinUAE and Linux versions are already on this site.)
To get more recognisable characters displayed it is best to use a potentiometer wired as one end to +5V, the other end to Gnd and the wiper to ANALOG IN 0. This has been tested on various Linux Distros and kept as simple as possible so that anyone can understand it.
The required ?.pde file for the Arduino Board can be found here:-
Similar assumptions are made as in the URL above.
Enjoy finding simple solutions to often very difficult problems... ;o)
Bazza, G0LCU.
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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | # Arduino-Windows2x.py
#
# DEMO Arduino Diecimila Board and below, serial access, using standard
# Python and Windows 32 bit installs.
#
# This is an experimental idea only to test the Arduino Diecimila
# development board under Python 2.2.x to 2.6.x; (assume Python 2.6.x).
# (It is assumed that the Python install uses the default folders.)
# This working idea is copyright, (C)2008, B.Walker, G0LCU.
#
# Pyserial is NOT needed AT ALL for this to work.
#
# NOW issued entirely as Public Domain. You may do with it as you please...
#
# Copy this 'Arduino-Windows2x.py' file into the 'C:\Python26\Lib\' folder
# and you will be ready to roll... ;-)
#
# To run type:-
# >>> execfile("C:\\Python26\\Lib\\Arduino-Windows2x.py")<RETURN/ENTER>
# OR......
# >>> import Arduino-Windows2x<RETURN/ENTER>
#
# And away you go...
#
# Press ~Ctrl C~ to QUIT, OR, set input to maximum of 5V, i.e. 255.
# Do any imports as required.
import os
# Start off with a basic cleared screen...
os.system('CLS')
# The program proper.
def main():
print
print ' Arduino Diecimila Dev Board access demonsration Python 2.x.x code.'
print ' Original idea copyright, (C)2008, B.Walker, G0LCU.'
print ' Press ~Ctrl C~ to QUIT.'
print
# This is set up for my COM(n) port on this old P IV machine.
# You WILL have to change it to suit the COM port number generated
# by your particular machine. For example just change my COM5: to
# your COMx: number in the lines below using a simple text editor.
os.system("MODE COM5: BAUD=1200 PARITY=N DATA=8 STOP=1 to=on")
while 1:
# Open up a channel for USB/Serial reading on the Arduino board.
pointer = open('COM5:', 'rb', 2)
# Transfer an 8 bit number into `mybyte`.
mybyte = str(pointer.read(1))
# Immediately close the channel.
pointer.close()
# 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.
# 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 DEMO...
# Enjoy finding simple solutions to often very difficult problems... ;o)
|
Arduino Diecimila access using Python Version 3.x.x for various platforms will follow in the not too distant future.