How do I add Xinput to a gamepad arduino project? - arduino

I have successfully running push buttons and analog sticks working on a board of mine through the serial connection via the Arduino IDE. How do I get that data to work with Xinput?
I have my own emulation software that works in Xinput beyond that. I just need to get the gamepad device xinput support. What are the neccessary steps to get this working with a driver and how I can get this up in running in the least amount of timing possible without having to edit someone else's driver too much?

You can turning an Arduino Leonardo into a joystick, use a teensy board and the teensy joystick library, use a HID-compatible bluetooth chip (such as RN-42 HID or something similar) with a joystick/gamepad profile or just remove a controller's existing joystick parts and replace with your components.

Related

Platformio which ESP32 board to pick

Hello and happy holiday to all
I am using platformio for an arduino project for the first time. I have purchased this ESP32 borad:
EC Buying ESP32-DevKitC Development Board ,ESP32 Development Board Equipped with WROOM-32D Module Integrated WiFi Bluetooth Module Microprocessor Interface SPI I2C I2S Suitable for Arduino
I am new to all this and need to know what board I should pick in PLATFORMIO for this board. I have loaded the core 32 from Espressif 32 and have the large list of ESP32 boards.
just want to make sure to pick the correct board to match the one purchased. Here is also the link to amazon on the board purchased.
https://www.amazon.com/dp/B0B64SD16T?psc=1&ref=ppx_yo2ov_dt_b_product_details
Thanks to all you wonderful people who can help.
I have not tried any boards listed as I did not what to damage this new board.
You won't damage an ESP32 by choosing the wrong PlatformIO board. The worst that will happen is that you won't be able to flash your program to the board, or it won't run correctly when it's flashed. While it's not impossible to brick an ESP32 by configuring security options, that's not something PlatformIO is going accidentally do to your board.
You can search the list of available boards on the web and look for a close match.
The most important thing is to get the correct processor type - figure out whether you have ESP32, ESP32-S2, ESP32-S3, ESP32-C3 (or eventually some other kind of ESP32). Only consider PlatformIO boards for that specific CPU. Then look for the size of the flash storage. Usually any board that matches that spec will work.
esptool.py, the program PlatformIO uses to flash the firmware to the board, will detect the CPU type, so if you have an ESP32-S2 and try to flash code for an ESP32 to it, it will detect this and report an error.
In your case you might try the generic Espressif ESP32 Dev Module:
[env:esp32dev]
platform = espressif32
board = esp32dev
If your first try doesn't work, it's safe to try another.

Is it possible to factory reset an arduino from hardware to remove bad user code?

I was troubleshooting why Serial1 was always throwing undefined errors in sketches I was trying to run when I found a solution posted online for a slightly different board that suggested this line:
HardwareSerial Serial1(2);
I uploaded it and now the Arduino doesn't show up in the IDE, did I remap it's serial communications? Why is this possible!
Is there any hardware factory reset option available on these boards? Did I just brick my device?
edit: It seems the STM32Cube programmer app can be used to communicate with the device but I'm not sure where to get the original firmware to flash. https://imgur.com/a/LbiHenf
Assuming from the tag in your question, I guess you have an STM32 – (BluePill) Development Board (STM32F103C8).
If you think that your board is not handling serial communication properly then you might consider burning bootloader to your board. This will reset the complete configuration of your board.
There are many ways in which you can burn bootloader to your board.
Using another Arduino board like Uno / Nano / Mega
Using an FTDI USB to TTL Serial Adapter.
You might want to go through tutorials list below:
Getting Started with STM32 using Arduino IDE: Blinking LED
Programming STM32F103C8 Board using USB Port

Getting two arduinos to interact without wiring them together

Okay, I've been working on this project for months with this being what has stopped me, heres the situation.
I am making a glove that can move a robot arm. The glove has an Arduino Nano iot 33 attached. The board measures the orientation with the built in imu, and sends it to my laptop (will be a raspberry pi in the future) through a usb cable. Also connected to the laptop is an Arduino Uno r3. This board is what makes the robot move (the servos are wired to it and I attached a display that shows the orientation of the glove here). I pondered how to make the Arduino Nano communicate to the Arduino Uno for a while, and I settled on keyboard presses. The Arduino Nano would press certain buttons based on its orientation and the Uno would wait for them to be pressed to move the robot. Turns out that after over 1000 lines of code, the Arduino uno can't use the keyboard library, and I'm stuck again. Is there a better way to go about this?? or is there a way to get the Arduino uno to get keyboard commands (I'm sixteen, tryin to save for college, I know theres a way to buy something to bypass the boards chip, I've already spent quite a bit on arduinos and PLA and such, and if im gonna buy something I want to use it again, please keep that in mind)
How would you have gone about this? How can I recover this project? Please help me...
this is an amazing project.
Great idea the link over SerialUSB, but it is very very slow...
You should use a radio transmitter like this.
Else, there is a great tutorial for communication using Bluetooth master & slave (warning: the post is in Italian).
If you still want to use SerialUSB, you should use a program that reads input from Nano and send a hex. code into Arduino Uno.
Library for serial communication with java or ruby.
Library for serial communication with Arduino.
I hope this can help you. Good luck!

Arduino - Sparkfun USB host

I am building a device and need to use a USB Nordic ID rfid reader. I have a Spark-fun USB host card (V9947), and now need the firmware to allow be bi directional chat in a 'rs232' style serial... just as if it were a hardware or software serial port on the Arduino.
Nordic support have reassured me that their library and examples for the Arduino are normally used with readers with RS232 ports, however the same code will work with their smaller USB device if I can overcome the USB/serial barrier.
I have the library and examples for the USB host board, but cannot determine which example code resembles my requirement requirement, I have looked through the library and found no answer there either.
This could be down to personal stupidity/ignorance... however never been this stumped before. the internet does not seem to have an answer, documentation and support for this board are at best meager.
I hope someone here has managed to solve what should be a simple mission, and I can get on with this project.
Thanks Ian
As not knowing what you already have done, I'll make a walk through the complete setup. Please check(do) each point evenif you think its done already:
Soldering and hardware have no shorts
pin headers of the shield are soldered with no shorts
USB Jack of Arduino is isolated on the top to prevent shorts
With the SparkFun board, it seems like you MUST supply external power on Vin or the barrel jack. 5V from the USB cable will not work reliable.
You must also run a jumper from pin D7 to RESET.
For the board (SparkFun DEV-09947) set up – these are mandatory pre-requirements.Now the software
The code/drivers you need to use for this board are on this GitHub page.
There is a diagnostic test which is extremely useful for checking wether your board is working correctly. Do as follows:
Upload this sketch to your Arduino, then open the Serial Monitor to see the diagnostic info.
To see the output set your Serial Monitor terminal speed to 115200
Plug in your hardware into the USB of the shield
Reset the Arduino to start the diagnostic
Step 1 – you’ll see it recognize the board and start a transfer test
Step 2 – you’ll see it attempt to test the GPIO pins – you’ll get “GPIO test failed” message. Type something in the box at the top of the Serial Monitor, then hit “Send” button and the diagnostic test will continue.
Step 3 – you should see it cycle through a bunch of resets, then it will attempt to detect an USB device – as we have a device plugged into the USB port on the shield you should then see some summary info with a final message of “All tests passed”
So NOW we know the hardware is working and basic software is running.
Next step driver installation/test program for the Nordic
Get the library from here
Import NurMicroApi_arduino.zip to IDE. From menu: Sketch->Include library->Add .ZIP library...
Open example. From menu: File->Examples->NurMicroApi->NurExample
Change baudrates and sw serial pins to match your arduino HW In this example NUR module is connected to arduino via software serial pin 10 (RX) and pin 11 (TX) with baudrate 38400. HW serial is used as print output.
You may have to change this to the USB card connections (see diag-SW)
As an easier option you can use the HID parser to check if your NUR is recognized If that works take a working exmple like:
Working HID example and try to read a tag then start coding with the NUR example from above if values are not correct interpreted
If you want to use the "pure" at-Terminal (RS-232) style you have to get rid of the usb shields functions (lib) and write your own Arduino firmware based (=overcome the USB/serial barrier) on the nordic-api (well documented) Hope this gets you started

PWM/PPM Output misses some edges

I am using ESP8266 (NODEMCU 3.0 or something) to make a quadcopter. Ive connected ardu pro mini to RC receiver so I am reading PPM values from it. Pro mini sends data with tx to ESP8266. ESP reads it with software serial with 115200 baudrate. I am communicating with MPU9255 (Waveshire) via I2C either.
My problem is that I cant fully controll my brushless motors. When I was using arduino instead of ESP8266, servo library was the best and reliable. But ESP's servo library is different, since its not AVR, and problems occurs. First of the servo library didnt want to work on most frequencies. I mean default is 50Hz (20000uS) and in this state ESC of motors did armed but unfortunatelly when changes was fast and short (1250-> 1370 -> 1250) it did miss that change like nothing happnd... This makes my D value in PID controller useless...
Sometimes on 100Hz freq all was working fine, but sometimes not...
When Ive started to use analogWrite only 500Hz was working fine, rest of freq didnt want to arm ESCs.
PS. I am using 3.3V to 5V converter for PPM/PWM pins so I am sure that the signal is fine for ESCs.
PS2. I dont have any osciloscope unfortunately.
The ESP82266 present on your module is a RF transceiver integrated circuit that can handle WiFi communication, both configured as a slave to a microcontroller such as the ones present on various Arduino boards, or as a standalone chip by having it's on-board Tensilica L106 32-bit processor programmed via an external SPI flash memory. If used as a slave, the communication between, for example, an Arduino an the ESP82266 can be done using different protocols such as SPI / SDIO or I2C / UART interfaces. Googling a comprehensive Tensilica L106 user guide on the internet doesn't seem an easy task, and it looks as if some people have already failed to find it. If you're seeking to add Wi-Fi capabilities to your quadcopter the solution I suggest is having the Arduino take control over the servos, motors, etc. and hand off messages via SPI to your ESP82266 module. If this isn't the answer you are looking for, please try to be clearer about it, maybe find someone to do as an English translator for you.
However, if this is what you're concerned about, and you would like to use the ESP82266 module as as standalone solution, please link its built-in processor datasheet and the relevant parts of the quadcopters code that might need debugging.

Resources