Show Posts
Pages: [1] 2 3 ... 8
1  Using Arduino / Installation & Troubleshooting / Re: Arduino Micro, USB Keyboard not 100% like a real keyboard on: March 07, 2013, 09:10:27 am
Thanks, interesting even though the problem is solved.

Carsten
2  Community / Exhibition / Gallery / Foot Switch Box for Rocksmith and other Applications on: March 07, 2013, 05:54:17 am
Hi,

I got addicted to a music game/learning tool called Rocksmith, here you can connect a real e-guitar and/or a e-bass to your computer and learn and play along rocksongs. I played more guitar in the last months like in the past 30 years.

In this game you can use different effects and amplifiers and also switch between them during a play, however it is not very comfortable and in some songs it is even not possible to let the guitar go to type on the computer keyboard. So I decided that a box with footswitches is needed. Some experimenting later I ordered a Arduino Micro because the Keyboard.h method on normal Arduinos was too wacky. The Micro has the ability like as the Leonardo to act as a USB Host, emulating a keyboard or a mouse.

The hardware consists out of a case, some stripe perfboard, a resistor array for the switches (somehow I don't like the internal ones), two LEDs wits Rs, a Arduino Micro, some buttons, one switch, cables, connectors and hot glue ;-)

Usually the buttons are like this:


ESC     ENTER     Bank Switch (LED dark, see below)
F1      F2           F3


The red Button in in fact a switch and changes the keys to:


ESC     ENTER     Bank Switch (orange LED lit)
LEFT   SPACE      RIGHT


That way you can control the whole game with the box, during play you switch between amps/effects with F1 - F3 (in fact F4 could also be used but no room left here), ESC and ENTER allows you to pause and to resume and also to control most of the gui.  For song select and advanced options you switch to the second bank and so you can controll the whole gui.

The sketch is nothing fancy:

Code:
/*
 Keybox.ino - Footswitch controller box for Arduino with USB Host, like Leonardo and Micro
 Copyright (c) 2013 Carsten Wartmann.  All right reserved.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    Dieses Programm ist Freie Software: Sie können es unter den Bedingungen
    der GNU General Public License, wie von der Free Software Foundation,
    Version 3 der Lizenz oder (nach Ihrer Option) jeder späteren
    veröffentlichten Version, weiterverbreiten und/oder modifizieren.

    Dieses Programm wird in der Hoffnung, dass es nützlich sein wird, aber
    OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite
    Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
    Siehe die GNU General Public License für weitere Details.

    Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
    Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
 */


// Two LEDs for showing "shift" status and power/ready/keypress
#define SHIFTLED 10  // orange
#define POWERLED 11  // green

#define DEBOUNCE 5  // button debounce interval

// here is where we define the input lines to use
byte buttons[] = {2, 3, 4, 5, 6, 7};
#define NUMBUTTONS sizeof(buttons)
byte pressed[NUMBUTTONS];

boolean hold=false;


void setup() {
  byte i;

  // LEDs
  pinMode(POWERLED,OUTPUT);
  pinMode(SHIFTLED,OUTPUT);

  // Make input & enable pull-up resistors on switch pins
  for (i=0; i< NUMBUTTONS; i++) {
    pinMode(buttons[i], INPUT);
    //    digitalWrite(buttons[i], HIGH); // uncomment to use internal pullups
  }

  delay(1000);
  Keyboard.begin();
}



// check the buttons (summs up to debounce)
void check_switches()
{
  byte index;

  for (index = 0; index < NUMBUTTONS; index++)
  {
    if (digitalRead(buttons[index]) and (pressed[index]<DEBOUNCE))
    {
      pressed[index]++;
    }
    else if (!digitalRead(buttons[index]))
    {
      pressed[index]=0;
    }
  }
}


// sending a key and repeats if needed
void keySend(char key)
{
  digitalWrite(POWERLED, LOW);
  Keyboard.press(key);
  delay(50);
  Keyboard.releaseAll();
  delay(50);
  if (!hold)
  {
    delay(200);
  }
  hold=true;
}



void loop()
{
  digitalWrite(POWERLED, HIGH);

  delay(10);
  check_switches();
  if (pressed[0] >= DEBOUNCE)
  {
    if (!digitalRead(SHIFTLED))
    {
      keySend(KEY_F1); // F1
    }
    else
    {
      keySend(KEY_LEFT_ARROW); // Links      
    }
  }
  else if (pressed[1] >= DEBOUNCE)
  {
    if (!digitalRead(SHIFTLED))
    {
      keySend(KEY_F2);
    }
    else
    {
      keySend(' '); // Space!
    }
  }
  else if (pressed[2] >= DEBOUNCE)
  {
    if (!digitalRead(SHIFTLED))
    {
      keySend(KEY_F3);
    }
    else
    {
      keySend(KEY_RIGHT_ARROW);  
    }  
  }
  else if (pressed[3] >= DEBOUNCE)
  {
    keySend(KEY_ESC);
  }
  else if (pressed[4] >= DEBOUNCE)
  {
    keySend(KEY_RETURN);
  }
  else
  {
    hold=false;
  }

  // "Shift" switch, we use the SHIFTLED to store the status
  // this switches to a second bank of meanings, it is not the keyboard Shift-key!
  if (digitalRead(buttons[NUMBUTTONS-1]))
  {
    digitalWrite(SHIFTLED, HIGH);
  }
  else
  {
    digitalWrite(SHIFTLED, LOW);    
  }
}

Attached some photos. I think all is pretty straight forward but don't hesitate to ask if something is unclear.

Of course this box could be used for other things, like controlling a computer which does not need a complete but sturdy keyboard etc. Also nice for projects with small computers (Raspberry Pi) where you don't want to use GPIO pins for Buttons.

Cheers,
Carsten
3  Using Arduino / Installation & Troubleshooting / Re: Arduino Micro, USB Keyboard not 100% like a real keyboard on: March 07, 2013, 04:34:31 am
BTW: where is the source for that functionality?
It's all included with the IDE and also can be found on the Arduino github.

Yea, sure, but I could not find it searching for "Leonardo", "Keyboard" or "USB". Was hoping for a lazyman pointer. Often the dvelopers comments are quite helpfull.

Carsten
4  Using Arduino / Installation & Troubleshooting / Re: Arduino Micro, USB Keyboard not 100% like a real keyboard on: March 06, 2013, 05:10:51 pm
@Erdin: You are my hero ;-)

Works now. I was unsure from beginning what function to use, and then decided that they are equal and that there must be some kind of buffer so that no keypress gets lost, but as it seems that function is much lower level, near hardware....

Thank you very much, you made my evening!
Carsten
5  Using Arduino / Installation & Troubleshooting / Re: Arduino Micro, USB Keyboard not 100% like a real keyboard on: March 06, 2013, 04:52:13 pm
I will try. Maybe the game itself uses a different keyboard polling because of the realtime needs of that specific game and so it misses that keypresses.

The delay(100) I use for the pause between keyboard key repeat.

will come back later with results.
Thanks,
Carsten
6  Using Arduino / Installation & Troubleshooting / Arduino Micro, USB Keyboard not 100% like a real keyboard on: March 06, 2013, 02:59:54 pm
Hi,

after trying a bit with a normal Arduino and usbkeyboard.h I found it too wacky and bought a Arduino Micro. It was quite straight forward to make my application, a footswitch controller for a music game (Rocksmith).

The Keyboard from the Arduino micro works well in Windows and even the menu control in the game works with it. HOWEVER and thats my problem, as soon as the real game (outside menus, playing a "level") starts no keypresses are send (or received?). A second (real) USB Keyboard connected works as expected, so I think the Arduino Micro does not act *exact* like a USB Keyboard...

Any suggestions how to solve this? Who is the developer for this part of the Arduino project? BTW: where is the source for that functionality?

Any suggestions welcome to save my project from going to the "not working projects" box...

Cheers,
Carsten

EDIT: The sketch

Code:
// Keybox


#define SHIFTLED 10
#define POWERLED 11

#define DEBOUNCE 10  // button debouncer
// here is where we define the buttons that we'll use. button "1" is the first, button "6" is the 6th, etc
byte buttons[] = {
  2, 3, 4, 5,6,7}; // the analog 0-5 pins are also known as 14-19
// This handy macro lets us determine how big the array up above is, by checking the size
#define NUMBUTTONS sizeof(buttons)
// Track Array
byte pressed[NUMBUTTONS];


void setup() {
  byte i;

  // set up serial port
  //  Serial.begin(9600);

  // pin13 LED
  pinMode(POWERLED,OUTPUT);
  pinMode(SHIFTLED,OUTPUT);

  // Make input & enable pull-up resistors on switch pins
  for (i=0; i< NUMBUTTONS; i++) {
    pinMode(buttons[i], INPUT);
    //    digitalWrite(buttons[i], HIGH); // we use external Pulls
  }

  delay(1000);
  Keyboard.begin();
}



void check_switches()
{
  byte index;

  for (index = 0; index < NUMBUTTONS; index++)
  {
    if (digitalRead(buttons[index]) and (pressed[index]<DEBOUNCE))
    {
      pressed[index]++;
    }
    else if (!digitalRead(buttons[index]))
    {
      pressed[index]=0;
    }
  }
}


void keySend(char key)
{
  digitalWrite(POWERLED, LOW);
  Keyboard.write(key);
  delay(100);
}

void loop()
{
  digitalWrite(POWERLED, HIGH);

  delay(10);
  check_switches();
  if (pressed[0] >= DEBOUNCE)
  {
    if (!digitalRead(SHIFTLED))
    {
      keySend(KEY_F1); // F1
    }
    else
    {
      keySend(KEY_LEFT_ARROW); // Links     
    }
  }
  else if (pressed[1] >= DEBOUNCE)
  {
    if (!digitalRead(SHIFTLED))
    {
      keySend(KEY_F2);
    }
    else
    {
      keySend(' ');
    }
  }
  else if (pressed[2] >= DEBOUNCE)
  {
    if (!digitalRead(SHIFTLED))
    {
      keySend(KEY_F3);
    }
    else
    {
      keySend(KEY_RIGHT_ARROW); 
    }  }
  else if (pressed[3] >= DEBOUNCE)
  {
    keySend(KEY_ESC); // ESC
  }
  else if (pressed[4] >= DEBOUNCE)
  {
    keySend(KEY_RETURN); // ENTER
  }

  if (digitalRead(buttons[NUMBUTTONS-1]))
  {
    digitalWrite(SHIFTLED, HIGH);
  }
  else
  {
    digitalWrite(SHIFTLED, LOW);   
  }
}
7  Using Arduino / Networking, Protocols, and Devices / Re: Can't get Duemilanove and USBKeyboard.h working on: March 04, 2013, 08:28:14 am
Harghh hrnnllllbbbb!

 smiley-mad smiley-mad smiley-mad

Somehow it started working. I then decided to solder it on a perfborad (using a Pro Mini on headers) to get some more mechanical and electrical stability. It works now a bit better but it is still very wacky, unusable wacky for my case.

I wonder if and then why it can work for others stable?  smiley-eek

I think I get one of the new Arduino Micros, however that makes my project again more expensive  smiley-confuse

Grmpl,
Carsten
8  Using Arduino / Sensors / Re: [strange problem] ADT75 temperature sensor on i2c on: March 04, 2013, 08:09:00 am
Oh! Good advice. I try that.

Sorry for the late reply, notify was not on.

Carsten
9  Using Arduino / Networking, Protocols, and Devices / Re: Arduino<->Arduino Software Serial only 3 bytes at once? on: March 04, 2013, 08:06:27 am
Great tip! Thats probably also the reason why it worked one time  smiley-yell

Carsten
10  Using Arduino / Networking, Protocols, and Devices / Can't get Duemilanove and USBKeyboard.h working on: March 02, 2013, 02:13:50 pm
Hi,

I tried the half day to get my Duemilanove to work as Keyboard.

Sum up:

- Duemilanove
- Arduino IDE 1.0.1
- Protoshield
- start with http://www.practicalarduino.com/projects/virtual-usb-keyboard
- library from http://code.google.com/p/vusb-for-arduino/downloads/list (v0005)

Image of testboard attached.

Sketch compiles fine, but when connected to a computer (tried Linux and WinXP) the device is not seen as Keyboard but "unknown".  Linux gives following as error:

Code:
[ 2349.890021] usb 6-1: new low speed USB device using uhci_hcd and address 50
[ 2355.022512] usb 6-1: device descriptor read/64, error -71
[ 2355.250018] usb 6-1: device descriptor read/64, error -71
[ 2355.480018] usb 6-1: new low speed USB device using uhci_hcd and address 51
[ 2355.621259] usb 6-1: device descriptor read/64, error -71
[ 2355.850014] usb 6-1: device descriptor read/64, error -71
[ 2356.082513] usb 6-1: new low speed USB device using uhci_hcd and address 52
[ 2356.500030] usb 6-1: device not accepting address 52, error -71
[ 2356.620016] usb 6-1: new low speed USB device using uhci_hcd and address 53
[ 2357.052508] usb 6-1: device not accepting address 53, error -71
[ 2357.052518] hub 6-0:1.0: unable to enumerate USB device on port 1

So according to http://code.rancidbacon.com/ProjectLogArduinoUSB this means that there is not real communication and just the pullup works (see top of page, same error with just the Strip board).

There is also something in the ArduinoNotes.txt which confused me much:

Code:
* Note: The pins we use on the PCB (not protoboard) hardware shield are:

     INT0 == PD2 == IC Pin 4 == Arduino Digital Pin 2 == D+

     ---- == PD4 == -------- == Arduino Digital Pin 4 == D-

     ---- == PD5 == -------- == Arduino Digital Pin 5 == pull-up

But on http://code.rancidbacon.com/ProjectLogArduinoUSB the PCB shows 3, 5 and 6. I used the Ports noted in ArduinoNotes.txt which are also in usbconfig.h

So I think I have a problem with the assembly, however I have resembled it 4 times from scratch now and have no idea what to check anymore, I double and triple checked the connections between USB and board, tested several demo PDEs etc. Even tested it on a Diecemila.

Any more ideas? The last posts about that are at least a year old, maybe something is broken?

Cheers,
Carsten
11  Using Arduino / Sensors / [strange problem] ADT75 temperature sensor on i2c on: November 09, 2012, 08:54:17 am
Hi,

I have a strange problem. I am reading two ADT75 via i2c, but ONE of the sensors fails on temperatures above approx. 34°C.

These guys are very small surface mounted chips, so in I soldered them with tiny copper wires on some small stripe-board. One is on address 0x048 the other one on 0x049 (Pin 7 (A0) connected to VDD). The other address pins are open.

I tested several values for Pull-up resistors. No change.  

So did I killed one while soldering? DId someone encountered similar problems (even on other i2c devices)? Any other ideas?

Best regards,
Carsten
12  Development / Other Software Development / Re: Writing code and flash it on Android devices (Nexus 7) or Linux on: October 27, 2012, 05:50:48 am

Currently the only issue that prevents arduino.mk work on Android "out of the box", that I know if, is that we don't have a way of detecting if rm accepts the -f parameter or not.  I could try to add a detection for this, but would you be willing to test it on Android for me?  I have an Android device, but it accepts rm -f!

Sure no problem!

Carsten
13  Development / Other Software Development / Re: Writing code and flash it on Android devices (Nexus 7) or Linux on: October 22, 2012, 12:05:12 pm
I guess this will do just fine.

thanks,
Carsten
14  Development / Other Software Development / Re: Writing code and flash it on Android devices (Nexus 7) or Linux on: October 19, 2012, 12:07:26 pm
Hey,

congrats to your last "project"! Looks sweet.



Quote
a problem with using float math occured, somehow we need to convince the linker to use c math

Is this something I should look at in the makefile?  If so, can you provide me with a simple line of code that goes wrong, for testing purposes?

using sin() should raise that error. See my Makefile how I changed the linker line after $(TARGET).elf:...

Carsten
15  Development / Other Software Development / Re: Writing code and flash it on Android devices (Nexus 7) or Linux on: October 13, 2012, 07:30:20 am
Hi,

I am sorry Notification did not work for this thread.

@Protheus: I uploaded the modules for Android 4.1.1 and 4.1.2 for Tegra CPUs (Nexus 7 at least) to the origin Post (you need to be logged in here to see them)

@lloydvolson: I am not quite sure what you want to achieve here? There is a Arduino Kit for Android which you can use to communicate with Arduino Boards. In my thread I only describe how to write sketches on the Nexus Tablet, the original Arduino-IDE is only needed to get the libraries (source), no matter if it is Linux, Mac or Windows.

Carsten
Pages: [1] 2 3 ... 8