2019年9月3日 星期二

WebUSB/Arduino on Windows 8 - How to make it work

Recently I'm playing with arduino and hoped to utilize the WebUSB API to enable cross-platform control over my arduino board. Here's some directions on how to get it work:

Outlines

  • Get a board that is compatible: I used Arduino Leonardo
  • Download ArduinoDroid for Android
  • Download WebUSB library
  • Upload your sketch to the board
  • Install Zadig on your windows to replace the original Driver and let it work

  1. You need a board that is compatible! I tried Arduino UNO at first but in vain finally
    Here is a list as suggested by https://github.com/webusb/arduino

    Arduino Leonardo (this is what I'm using)
    Arduino/Genuino Micro
    Arduino/Genuino Zero
    Arduino/Genuino MKR1000
    Arduino MKRZero
    Arduino MKR FOX 1200
    Arduino MKR WAN 1300
    Arduino MKR GSM 1400
    Arduino MKR NB 1500
    Arduino MKR WiFi 1010
    Arduino MKR Vidor 4000
    Arduino NANO 33 IoT
    Adafruit Feather 32u4
    Adafruit ItsyBitsy 32u4
    Adafruit Feather M0 Express
  2. You need a program for uploading sketches, and I would suggest ArduinoDroid on Android
    https://play.google.com/store/apps/details?id=name.antonsmirnov.android.arduinodroid2

  3. You need to install the libraries included in my example:
    • IRremote made by shirriff
      ...Menu>Libraries>Manage>Remove Robot IR Remote in the "Installed" tab and install IRremote in the "Available" tab
    • WebUSB on https://github.com/webusb/arduino  , go to the main page and navigate to the Desktop Version, click Clone or Download > Download Zip
      Then, you'll have to copy the library/WebUSB folder to /sdcard/ArduinoDroid/libraries, and move the .cpp and .h files into a newly created folder "src" under /WebUSB
  4. You need to upload a sketch to enable your Arduino board to support WebUSB, and here is an example (revised from webusb/arduino's example):
    https://1drv.ms/t/s!AuF-m6d32eIfhf49JfWav4xKVVac0g?e=xuDb6M
    First select board type by clicking ...Menu>Settings>Board type>Arduino>Arduino Leonardo. Click the Floppy Disk (save) > Lightning (compile) > Download (Upload sketch) Icons in this order; The last upload step might fail for several times, just be patient to retry

  5. After uploading the sketch, navigate to my WebUSB testing page and click "Connect" and select your Leonardo on your phone. You would be prompt whether to let chrome access USB, and of course, "yes". Finally, you should now be able to switch LED on/off by "Send ledh" and "Send Custom" on Android.
    https://drjohnjstest.blogspot.com/2019/07/webusb-test.html
I finished all the above steps in a very quick time, but then when I wanted to plug my Leonardo board into my computer's USB which is running Windows 8, I failed to find any device on my test page. So now let's solve this problem permanently.

  1. Download a software called zadig on your PC here
    https://zadig.akeo.ie/
  2. Then open zadig and in the Options menu, select the "list all" option.
  3. Select your arduino device in the list and install WinUSB (v6.1.7600.16385) for it. Be careful, version 6.2.9200 doesn't work! So don't ever think that the newer version is better and omitted this step! This is right the point I was searching for which spent me lots of time.
  4. After installing, navigate back to my webusb-test.html page and you should be able to find your device when clicking on "Connect".
  5. Wish you all good luck and have a nice day playing with Arduino!!

沒有留言: