Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Is anyone interested...

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
Bazza
LXF regular


Joined: Sat Mar 21, 2009 11:16 am
Posts: 1381
Location: Loughborough

PostPosted: Tue Nov 17, 2009 6:02 pm    Post subject: Is anyone interested... Reply with quote

Hi all...

Well Arduino is now talking to STANDARD Python how I like it...

It requires NO drivers, NO dependencies, NO added stuff at
all and works from a live version of PCLinuxOS 2009 too.

It is also talking to the default terminal window.

Is anyone interested in the code on how it is done?

If there is a "YES" then I will post it on here FOC...

Also `stty` is a tricky little sod to understand.
_________________
73...

Bazza, G0LCU...

Team AMIGA...
Back to top
View user's profile Send private message
1slipperyfish
Forum Jester


Joined: Mon May 09, 2005 3:52 pm
Posts: 2366
Location: wigan

PostPosted: Wed Nov 25, 2009 8:58 pm    Post subject: Reply with quote

yes i am interested, can you give the code so it works with vista?? also can you give the code so you can program using java in vista??
thanks bazza Very Happy
paul
_________________
i am a follower of the culture

Back to top
View user's profile Send private message
Bazza
LXF regular


Joined: Sat Mar 21, 2009 11:16 am
Posts: 1381
Location: Loughborough

PostPosted: Wed Nov 25, 2009 10:01 pm    Post subject: Reply with quote

Hi 1sf (troll)...

> yes i am interested, can you give the code so it works with vista??

http://main.aminet.net/dev/src/Arduino_Python.lha

And my question was for Linux NOT Windows...

Did you want the Linux method too?
_________________
73...

Bazza, G0LCU...

Team AMIGA...
Back to top
View user's profile Send private message
1slipperyfish
Forum Jester


Joined: Mon May 09, 2005 3:52 pm
Posts: 2366
Location: wigan

PostPosted: Thu Nov 26, 2009 7:05 pm    Post subject: Reply with quote

yo bazza
if you wouldn't mind, i'm a 'driva user if that makes any difference Confused i'm also running fedora beta, but i'd rather use the 'driva Very Happy
paul
_________________
i am a follower of the culture

Back to top
View user's profile Send private message
Bazza
LXF regular


Joined: Sat Mar 21, 2009 11:16 am
Posts: 1381
Location: Loughborough

PostPosted: Thu Nov 26, 2009 10:32 pm    Post subject: Reply with quote

Hi 1sf (troll)...

Here goes...

> if you wouldn't mind, i'm a 'driva user if that makes any
> difference :S

Not really, it has been tested on Knoppix 5.1.1 too...

This is gonna be long so be prepared...

A simple manual test into the Console...

<Shell Code>
1) Boot up to your Linux flavour as root.
2) Temporarily disable any net access or use a stand-alone
machine.
3) Plug in your Arduino.
4) Open up a Console.
5) cd / <RETURN/ENTER>
6) cd /dev <RETURN/ENTER>
7) ls <RETURN/ENTER>
8) Check the you have a device as ttyUSB?
Note ? will probably be 0.
9) If ttyUSB0 exists then carry on; otherwise ignore this post.
10) Place a wire link between ANALOG 0 and the 3.3 V terminals.
11) chmod 666 /dev/ttyUSB0 <RETURN/ENTER>
Note, that chmod is not really needed but added for fullness!
12) stty -F /dev/ttyUSB0 1200 <RETURN/ENTER>
13) stty -F /dev/ttyUSB0 raw <RETURN/ENTER>
14) cat < /dev/ttyUSB0 <RETURN/ENTER>
Note, the characters will be from about 170 to 172 decimal
allowing for bit error of the Arduino ADC.
15) Remove and replace the wire link from ANALOG 0 and GND
or ANALOG 0 and 5 V too.
16) Ctrl-C to stop the characters being printed to the Console.
</Shell Code>

Code:
# Arduino test for Python 2.5.x under PCLinuxOS.
# This is an experimental idea only to test the Arduino Diecimila
# development board under Python 2.5.x and Linux.

# This idea is copyright, (C)2009, B.Walker, G0LCU.

# Copy this `Arduino.py` file into the `Lib` drawer
# and you will be ready to roll... ;-)
# This code offered as Public Domain for all...

# Press ~Ctrl C~ to STOP the program.
# Set ANALOG 0 to 5V to fully QUIT the program.
# To run type:-
# >>> import Arduino<RETURN/ENTER>

# Do any imports as required.
# import sys
import os

# Assume root access!
os.system("chmod 666 /dev/ttyUSB0")

# Clear the screen...
os.system("clear")

# Fix the speed of the USB-Serial port to 1200 bps...
os.system("stty -F /dev/ttyUSB0 1200")

# Set it to `raw` transfer mode.
os.system("stty -F /dev/ttyUSB0 raw")

# The program proper.
def main():
   print
   print '      Arduino Diecimila Dev Board access demonsration Python 2.5.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('/dev/ttyUSB0', '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 == 255: break

main()
# End of program...

_________________
73...

Bazza, G0LCU...

Team AMIGA...
Back to top
View user's profile Send private message
Bazza
LXF regular


Joined: Sat Mar 21, 2009 11:16 am
Posts: 1381
Location: Loughborough

PostPosted: Thu Nov 26, 2009 10:41 pm    Post subject: Reply with quote

Hi `sf...

You will need the programming SW from:-

http://arduino.cc/

I don`t use Linux to program, I use Windows instead, as I use
Arduino with WinUAE...

I forgot the .pde code for Arduino...

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);
}


There that should be enough for you to start doing some I/O
projects with Arduino...

For example, Vlotmeters, Ammeters. Powermeters both AF
and RF, Data Loggers/Transient recorders and... and...

Enjoy...
_________________
73...

Bazza, G0LCU...

Team AMIGA...
Back to top
View user's profile Send private message
1slipperyfish
Forum Jester


Joined: Mon May 09, 2005 3:52 pm
Posts: 2366
Location: wigan

PostPosted: Fri Nov 27, 2009 10:35 am    Post subject: Reply with quote

you're the best bazza Very Happy
paul
_________________
i am a follower of the culture

Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast