Joystick USB definition for use with Arduino - arduino

I'm trying to write the control code for a custom joystick, and I cannot find any reference to what needs to be implemented to be recognized by a computer as a joystick.
I can see what things I need to have by referencing various game library APIs for using a joystick.
For example, pygame has the following methods,
init
quit
get_init
get_name
get_id
get_numaxes
get_numbuttons
etc.
My next stop is to read through the kernel for Linux's HID and joystick controlers... But this seems like a really round about way of finding this information.

I haven't worked with it, but it looks like there is some interesting information in Arduino Uno Joystick HID firmware and Arduino Uno Big Joystick HID firmware. There is also UnoJoy - I'd try that first (assuming you have an Arduino Uno or Leonardo).

Related

Why do we need to select a board to work with arduino IDE

I always wondered how this works . In arduino IDE we have option to select different boards because the code upload i guess is different ? Also there is possibility to even add board manager url to add other boards.
Why uploading the code is so different from board to board , and what exactly differs there ? The code is sent to via serial connection and i understand that a board might have different chip for handling USB to serial but ..
Can someone explain as clear as possible , how the code is uploaded to a board and why there is no generic way , why so many configurations.
Thanks and sorry if is a dumb question.
One of the important things that selecting a board does is, as you say, inform the IDE of how to load code onto the board. Perhaps more importantly, the board definitions give you the logical mapping of the board's hardware to the code constructs you are using to program against. For example, have you ever wondered what happens when you use a constant like PIN_13, or how that constant maps to a physical pin on your board, which has a trace to some contact on the microcontroller chip itself?
There is a lot of other code you don't see, much of it in the board definitions (and some in the Arduino core) which lets you work with relatively direct concepts (like pin numbers and modes) in the code that you write or edit.

Is it possible to program Arduino boards using a few lines of assembly in the Arduino IDE?

I want to measure the time between two signals that are not in phase and i am using arduino Uno. I have converted the 2 sinusoidal signals into square waves and i am feeding them on INT0 and INT1 respectively. To measure the lag between the two signals i want to measure the time between the rising edges or falling edges of the signals using interrupts. On receiving the first rising edge i want to start a timer, say timer 3, upon receiving the second rising edge i want to stop the timer. my problem is i cant find a library that will allow me to start and stop timer the 3 and use the value it so i have chosen to include a few lines of Assembly language in my program for that purpose. Is it possible on the Arduino boards using the arduino IDE?
Yes it's possible. See for example this tutorial. However, I'd strongly recommend if you're doing anything more than a few instructions, you download and install Atmel studio -- which is free -- and use its excellent user interface to do your coding and debugging. I do all my programming for bare microcontrollers, in-system programming, and Arduinos using Atmel Studio.

Draw image from live arduino sensor data

I want to draw real time graph using data coming from a rotating ultrasonic sensor through arduino. What are the tools or library required for this. I am using official arduino IDE using C language.
The Arduino itself can't really draw a plot, so you'll have to send the data to your computer using Serial communcation. Your computer can then draw a graph. There are two options:
Use an existing program
The easy way.
This official Arduino page has some example code for the program Processing, but I'm sure you can find a bunch of other examples and tutorials online.
Write it yourself
This is the difficult and fun way.
If you already know a programming language, great! Search some tutorials about how to connect your Arduino & how to plot data.
Otherwise, I recommend starting with Python, this is a good place to start.
Java
I have some old code written in Java that connects to the Arduino using the very easy JSSC library:
SerialPort port = new SerialPort("COM9");
port.openPort();
port.setParams(9600, 8, 1, 0);
byte b = port.readBytes(1)[0]; //read a single byte
port.writeByte(b); //write a single byte
Where you'd replace "COM9" with whatever port your Arduino is connected to, as displayed in the bottom right of the Arduino IDE.
Actually plotting the data would require another library, I see JFreeChart being recommend a lot online.

Running encoder on Arduino Mega using Simulink

I am using Simulink togheter with an Arduino Mega 2560 to control a motor with encoder. The encoder has 200 steps per revolution. My aim is to use external mode in order to get out data into the Simulink scope.
Earlier, when not using the Simulink blocks, this worked fine using attachInterupt. Now it does not work since Simulink does not have that option. I have tried two methods:
use the digital input blocks and trigger > too slow
use the serial block togheter with an extra arduino (uno) that Only handles the encoder signal (this extra arduino is not programmed in Simulink) and sends the pulses to the main arduino (the baudrate does not seem to the limiting factor, instead it is the fact that the block only handles uint8) > also too slow
I cannot see the generated code in my Simulink license, and I would prefer a solution where blocks are used. Is there a work-around??
Any tip is appreciated!
you may use S-function to develop encoder algorithm using the attachinterrupt of arduino. this link may help http://www.mathworks.com/matlabcentral/fileexchange/39354-device-drivers
Update: You can use the External Interrupt block to implement this in the latest version of the support package.

Arduino ethernet board compatible with LCD-Display?

I am doing a little project with an arduino ethernet board. I am new to arduino and wanted to know, whether following lcd display is compatible to my arduino or not. If it is compatible, do I need more hardware, for example cables and so on...
My Arduino Ethernet board, bought on fritzing.org:
http://shop.fritzing.org/products/fritzing-starter-kit-with-arduino-ethernet
LCD-Display which I found on dx.com:
http://dx.com/p/lcd-keypad-shield-for-arduino-duemilanove-lcd-1602-118059
Thanks in advance for any help!
In the ethernet board, pins 10-13 are reserved. The lcd-shield is using pins 4-10 (although #10 is the backlit control, so it may be possible to go without it, just having a constant backlit) - I have the lcd - keypad shield, but at home, so I cannot check that now. - look into the lcd-library to see if you can somehow define it.
That is, it is not possible to use the backlight and the ethernet at the same time. For your other question, you just stack the LCD -keypad shield on top of your arduino board, no other connections or cables are needed.
Although it may look a bit more scary, a display without a shield, eg http://dx.com/p/16-x-2-character-lcd-display-module-with-blue-backlight-121356 is not much harder to set up and it gives you more flexibility. (although, for the display I linked to, you must be able to solder in a set of pins to connect it) Another alternative is http://dx.com/p/16-x-2-character-lcd-display-module-with-blue-backlight-121356 - the latter gives you more flexibility, but poorer readability and it is a bit more work to set up the library.

Resources