document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import time
  2.  
  3. from hw.commands import *
  4. from hw.usbdevice import *
  5.  
  6. #use all defaults since that\'s the device I have
  7. dev = UsbDevice.find()
  8.  
  9. #setup device
  10. def show_firmware():
  11.     #cmd is used for printing, otherwise you could\'ve done: print GetFirmwareUnpack(dev.get_result(GetFirmware().pack()))
  12.     cmd = GetFirmware()
  13.     print cmd
  14.     print FirmwareUnpack(dev.get_result(cmd.pack()))
  15.  
  16. def prepare_port():
  17.     cmd = SetBit("TRISC", 6, 0)
  18.     print cmd
  19.     print SetBitUnpack(dev.get_result(cmd.pack()))
  20.  
  21. def set_bit(value):
  22.     cmd = SetPortBit(Port.C, 6, value)
  23.     print cmd
  24.     print SetPortBitUnpack(dev.get_result(cmd.pack()))
  25.  
  26. show_firmware()
  27. prepare_port()
  28.  
  29. #blinking - send 0 to turn the led on, 1 for off
  30. for i in range(10):
  31.     set_bit(0)
  32.     time.sleep(1)
  33.     set_bit(1)
  34.     time.sleep(1)
');