Wednesday 17 April 2013

Digispark / Rpi.


Talking with a relative about the arduino / Pi integration, he gave me a 'digispark' which he'd backed on kickstarter.  This device should be able to plug into the USB, and tidy up the wiring a bit from the arduino idea to measure distance........   So, how to make it work.

I don't seem able to program this on Linux - it isn't recognised on my PC - USB problems, however I can program it on Windows, then plug into the Pi, and it is recognised.  (There need to be various bits for the Pi recompiled to make the IDE work on Pi, and this is outside my needs (capabilities probably....).

On the pi...  sudo pip install PyUSB

From the digispark wiki, install the examples, load up the DigiUSB example onto the digispark, and run the recieve.py on the Pi:-


pi@raspberrypi ~/digispark/DigisparkExamplePrograms-master/Python/DigiUSB/source $ cat receive.py
#/usr/bin/python

#
# Written for PyUSB 1.0 (w/libusb 1.0.3)
#


import usb # 1.0 not 0.4


import sys
sys.path.append("..")

from arduino.usbdevice import ArduinoUsbDevice


if __name__ == "__main__":
    try:
        theDevice = ArduinoUsbDevice(idVendor=0x16c0, idProduct=0x05df)
    except:
        sys.exit("No DigiUSB Device Found")




    import sys
    import time

    while 1 == 1:
        try:
            lastChar = chr(theDevice.read())
            if(lastChar == "\n"):
                break
            sys.stdout.write(lastChar)
            sys.stdout.flush()


        except:
            # TODO: Check for exception properly
            time.sleep(0.1)


Cool. - Something was received!!  The foundation to rework the distance measurement here.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.