0
votes

I need idea to send a number ( 0 to 9 ) to a microcontroller, a Loop can then do a task ( sends 1 to outputs ) according to the number the microcontroller reads from USB ..

So how can I send a number from PC's software to be recognized by a loop on microcontroller ..

1
how about sending a character 0-9) over RS232 or a UART interface to your microcontroller. A USB 'dongle' that takes to RS232 or a UART is a standard driver free install for your PC. - kenny
Have you chosen a microcontroller? a development board? is USB capability built-in? Many dev kits have this functionality out of the box (including host side demo software). - jolati
Kenny.. Thanks for your advice but I want USB interface directly .. Jolati .. Yea, I have chosen Microchip 18F4550 which has a built-in USB, I understand that you have to load a firmware on the PIC so that the PC can recognize it as a HID .. and that firmware should include buffers to be controlled via a Visual basic program by sending numbers via USB to this specific device ( by its VID and PID ) ... So how can I achieve that !! - Mohamed Sayed
you dont just do "usb" you have to decided what device type, have software on both ends, etc...usually these chip manufactures have software libraries and examples, so it should be a relatively simple matter of downloading their sandbox and tools and building their usb hid example, add a few lines of code, done. - old_timer
maybe have to write host side software though, libusb is useful here. - old_timer

1 Answers

0
votes

To use your device as USB HID, you need a usb library with HID class implementation, you can enumerate this device on PC side using libusb and scan the device periodically.

But to communicate with your microcontroller you can use vendor class library running on microcontroller and libusb on PC. Here your device will act as usb device and pc as host depending upon interface in between usb connector and microcontroller usb pins. Now, upon connecting usb device with PC, enumeration process will start and pc will collect device information along with VID and PID. Now you can start sending 0 to 9 as bulk transfer of 10 bytes, you can create a buffer on microcontroller side to collect these bytes. You can send byte by byte but that would be taking longer period.