UnoJoy project

Hi,

I am trying to make a simple UnoJoy project with two potentiometers and one button. I am trying to make a simple code for it, but I don't know what has to be in the code. I have been looking at the examples for several hours, but can't find how to write the most basic code. Could any of you help me?

Jasper

STart with working through the examples in the tutorial section. You will learn a lot about the basics of the Arduino language and how to do things. You will find many snippets of code that can be useful for your project.

Your journey starts here - http://arduino.cc/en/Tutorial/HomePage -

Hi,

Thanks for the reply. I have already worked through all the tutorials for the arduino, my problem is that I don't know how to code a basic UnoJoy program.

Jasper

what is an UnoJoy?
what are the requirements?
What hardware needs to be connected?

you should tell far more to get meaningful answers

Hello,

Have a look at unojoy.com , it's really cool. No hardware is required.

Jasper

with two axis and one button

Sounds like hardware to me.

I get it, UnoJoy is firmware what lets your computer recognize your arduino as a joystick. You can hook buttons and other inputs like potentiometers to control the joystick outputs. I want to make my project with 2 potentiometers and 1 button.

Jasper

jasperachtbaan:
Hello,

Have a look at unojoy.com , it's really cool. No hardware is required.

Jasper

Links on that site seems to be dead?

That's right, just copy and paste...

http://code.google.com/p/unojoy/downloads/list

so you have the code ...?

Yes, but I can't make up what's necessary and what's not. I am not that experienced.

Jasper

THe only way to learn is

  1. dissect the code you have to understand how it works
  2. try to make one step at the time to add the things you need.

If you are really new to Arduino, this project can be a too big step forward. For me it is at least too big to dive in tonight. Maybe tomorrow .

Hi,

Thanks for your tip, tomorrow I will try to inspect the whole code again, see if I succeed this time. I will post my progress. By the way, I think the coding of UnoJoy is not so hard at all, but it's just hard to see in the whole code.

Jasper

This is my 2 cents based on a quick look at UNOJoy...

One of the cornerstones of the original Arduino, that made it attractive to beginning developers, is the serial bootloader. Most new computers no longer have RS232 type serial ports anymore, so to keep up, Arduino moved to USB. Since the Atmega328 chip doesn't have any built in hardware for USB, the Arduino used FTDI chips that were a hardcoded USB to serial interface. The UNO model of Arduino replaced the FTDIs with Atmega8u2 and Atmega16u2 chips. These are general purpose microcontrollers with built in USB hardware. Your UNO was delivered with the 16u2 setup as a USB to serial interface, like the FTDIs, but unlike the FTDIs, they can be reprogrammed to look like a keyboard, or a mouse or yes even a joystick.
UNOJoy is a two part project. The 328 is programmed with a normal sketch that reads buttons and pots and sends the results through the serial port. There are a number of these example sketches, and you should be able to load one like any other Arduino sketch. The other part loads the 16u2 with firmware that looks to the PC host like a joystick. It receives the data from the serial port and instead of sending it as serial USB data, it packages it up as a Joystick. The key is that while the Joystick code is loaded in the 16u2, you can't load another sketch, or get serial debug text. If you do want to make a change to the 328 software, you'd need reload the 16u2 as USB_to_Serial, load a sketch, then load the 16u2 again back to Joystick mode.
If you want to play with UNOJoy, read the Getting Started file a few more times, load a sketch from the Example directories (if you have potentiometers, you'll want analogRead calls), and try to load the 8u2 (in this case the same as 16u2) code. The text file describes how to get into DFU mode (the USB bootloader for the 8u2). Maybe even Google "UNO atmega8u2 reprogam".
Bottom line : if you just want to see if you can make a simple Joystick that will talk with your PC, this is rough, but OK. If you want to make a real Joystick interface, there may be easier ways that don't tie up a pricey UNO when your done. Check out the 8u2's bigger, more powerful cousin, the 32u4. It's the main chip in the Leonardo and (my favorite) the Teensy 2.0. This allows you to put all of the code in 1 chip, which makes it easier to code. There are a number of people that have created joystick projects with Teensy 2.0.

Hi,

Thanks for your reply. I got the examples running on it, and the new firmware loaded up to it. It works fine. My problem is not that part of it, but I really don't know how to get the code into my own codes. That's why I'd like to have the absolute minimal code, so I can put it into my own codes without unnecessary parts.

Jasper

Hi,

I stripped the code, and this is what was left, it works fine:

#include <UnoJoy.h>
int button = 5;
void setup(){
  pinMode(button, INPUT);
  digitalWrite(button, HIGH);
  setupUnoJoy();
}
void loop(){
   
    dataForController_t controllerData = getBlankDataForController(); //Don't get what this means
    controllerData.squareOn = digitalRead(button);
    setControllerData(controllerData);
}

Thanks for your help everyone