Show Posts
Pages: [1] 2 3 4
1  Community / Products and Services / Re: Arduino BT on: October 08, 2013, 11:21:10 am
You could go for a ITeaduino BT instead. It's basically the same thing, just without screw terminals and a ATmega328 instead of an ATmega168.
2  Using Arduino / Programming Questions / Re: Using Arduino Leonardo as joystick on: May 11, 2013, 08:10:51 am
Or maybe i'll stick with this, what doesn't kill me just makes me stronger smiley-grin. It doesn't seem to be my day today, I keep missing out on the simplest of stuff...
3  Using Arduino / Programming Questions / Re: Using Arduino Leonardo as joystick on: May 11, 2013, 07:43:31 am
Exactly. I got used to that. But I still can't get it working, regardless of what i'm trying. Don't even ask about the struct. Always just one of the functions. I feel like a complete idiot  smiley-cry. Seriously, it really can't be that hard!

Edit: I think i'll completely start over based on this: http://arduino.cc/en/Tutorial/EsploraKart
It even has a Video  smiley-lol
4  Using Arduino / Programming Questions / Re: Using Arduino Leonardo as joystick on: May 11, 2013, 05:42:50 am
Well, that looks promising! Of course there will be more inputs, ten when it's done. Arcade style. As i have guessed: I've made dumb logical errors. oldVal is  initialised to 1 on purpose, that seems to be the only proper way to use the internal pullups on an Olimexino-32u4. And the Keyboard.releaseAll(); was pure lazyness, I didn't spent much (if any) time thinking about that... *facepalm*
5  Using Arduino / Programming Questions / Re: Using Arduino Leonardo as joystick on: May 11, 2013, 02:48:45 am
I tried using switch states, but my sketch only works right if only a single function is called. If there's more than one function it repeats the keystrokes as fast as an if-loop  smiley-sad. So walking into a single direction works fine, but that's pretty much pointless in a 3D game. Or in video games in general smiley. Anyway, here's the code I didn't complete for all directions as two won't even work:
Code:
int BUTTON_W = 2;
int BUTTON_A = 5;

void setup() {
  pinMode(BUTTON_W, OUTPUT);
  digitalWrite(BUTTON_W, HIGH);
  pinMode(BUTTON_A, OUTPUT);
  digitalWrite(BUTTON_A, HIGH);
  Keyboard.begin();
}


void loop(){

  forward();
  left();
}

void forward(){

  int val_W = 0;
  int oldval_W = 1;

  val_W = digitalRead(BUTTON_W);

  if (val_W != oldval_W) {

    Keyboard.press('w');

  }

  else {
    oldval_W = val_W;
    Keyboard.releaseAll();
  }   
}

void left(){

  int val_A = 0;
  int oldval_A = 1;

  val_A = digitalRead(BUTTON_A);

  if (val_A != oldval_A) {

    Keyboard.press('a');

  }

  else {
    oldval_A = val_A;
    Keyboard.releaseAll();
  }   
}


I just fail to find out how to send multiple keystrokes, but I bet it's simple and there's a completely dumb error in it.
6  Using Arduino / Programming Questions / Re: Using Arduino Leonardo as joystick on: May 08, 2013, 05:36:27 am
Okay, I'll try that after having lunch smiley. I worked trough that about nine months ago and then had my Arduino collecting dust most off the time. I just have to get back into the matter!
7  Using Arduino / Programming Questions / Re: Using Arduino Leonardo as joystick on: May 08, 2013, 05:18:43 am
I'm trying to make my own game controller that's recognized as a joystick. The demo code works, I did just put the files into the wrong directory. I haven't written my own joystick code yet, but here's my not so well working keyboard code:
Code:
int btn[] = {
  2,3,4,5,6,8};

void setup()
{
    for(int i=0; i<6; i++){
      pinMode(btn[i],OUTPUT);
      digitalWrite(btn[i],HIGH);
    }
    Keyboard.begin();
  }


void loop()
{
  if(digitalRead(btn[5])==0){
    Keyboard.press('0');
    Keyboard.releaseAll();
    delay(250);
  }
  if(digitalRead(btn[3])==0){
    Keyboard.press(216); //left arrow
  }
  if(digitalRead(btn[4])==0){
    Keyboard.press(215); //right arrow
  }

  if(digitalRead(btn[1])==0){
    Keyboard.press(218); //up arrow
  }
  if(digitalRead(btn[1])==0 && digitalRead(btn[4])==0){
    Keyboard.press(218); //up arrow
    Keyboard.press(215); //right arrow
  }

  if(digitalRead(btn[1])==0 && digitalRead(btn[5])==0){
    Keyboard.press(218); //up arrow
    Keyboard.press(216); //left arrow
  }

  else{
    Keyboard.releaseAll();
  }
}


I know, it's awful... smiley-grin
The problem is that it's stuttering because of the repeating which gets me kicked off the server. It makes the game think that I must have got a horrible connection.
8  Using Arduino / Programming Questions / Re: Using Arduino Leonardo as joystick on: May 08, 2013, 03:42:48 am
Edit: I should really stop rushing stuff and properly read the instructions:
Quote
Modified arduino files (replace the files in {arduino executable dir}\hardware\arduino\cores\arduino\ with these):

USBAPI.h
HID.cpp

Well, that's embarrassing  smiley-roll-blue

Still got one question: How do i get it done that a key sent by the Leonardo stays pressed, but doesn't repeat itself all the time? Cant figure that out for days now. Yes, I tried using Google.
9  Using Arduino / Programming Questions / Using Arduino Leonardo as joystick on: May 08, 2013, 02:13:51 am
I am trying to use my Leonardo as joystick by using the Library I found here: http://www.imaginaryindustries.com/blog/?p=80. I tried to compile the example from there but only got this error message:
Code:
wheel_pedals_demo.ino: In function 'void loop()':
wheel_pedals_demo:57: error: 'Joystick' was not declared in this scope
I took a look at the .h and .cpp files, but since i'm not very knowledgable when it comes to debugging libraries I can't figure out what went wrong there. Please help!
10  Using Arduino / Project Guidance / My new project idea: Illuminated Lack table with capsense on: April 10, 2013, 09:46:49 am
Yes, yet another project on the web that involves the ever-popular IKEA Lack side table :-). So my idea is as follows: I want to hollow it out, build a capacitive sensor board from mdf with four squares of aluminium foil stuck to it. It will be contacted with copper tape where i'll solder the wires onto. A sheet of plastic for insulation on top. Then a slightly bigger board of mdf will be turned into a big 8x8 Led matrix, using diffused warm white LEDs. The matrix is meant to be controlled by this I2C board: http://www.adafruit.com/products/870 . The matrix gets stacked over the sensor board. Finally a milk glass plate comes on top of it all. The wires will be pulled through the table's lower side, that's why the sensor board should be slightly smaller than the matrix. A Pro Mini is meant to be the main controller. It'll be stuck to the table with velcro for easy debugging. The whole contraption will be powered by a 9V Wall wart.
My main concerns are: 1.: Could the matrix possibly disturb the sensors? And 2.: has someone got a datasheet for the I2C board?
11  Using Arduino / Programming Questions / Re: Changing function state from inside a if-loop? I'm a little bit stuck here... on: April 09, 2013, 02:02:35 pm
Ok, I applied the changes zx81 proposed and also those from wildbill:
Code:
if(rstState == LOW){                   //reset pulse
      digitalWrite(rstOut,HIGH);           //reset pulse
      delay(40);                           //reset pulse
      LCDMode = 1;
      digitalWrite(rstOut,LOW);           //reset pulse
    }
Works like a charm now! Yay! smiley
Thanks for helping to all of you!
12  Using Arduino / Programming Questions / Re: Changing function state from inside a if-loop? I'm a little bit stuck here... on: April 09, 2013, 01:28:45 pm
That was the first thing i tried. Sadly it's not that easy.
13  Using Arduino / Programming Questions / Re: Changing function state from inside a if-loop? I'm a little bit stuck here... on: April 09, 2013, 01:01:32 pm
I bet that there's a way to turn the LCD off via the Pi, but to achieve that I need to learn how to write programs for it, and I'm already struggling here. Also it's meant to work with every Pi after configuring Lcdproc.  And yes, it's purposed to avoid accidental resetting. Oh, and please forgive the missing vowels in my sketch; that's an old habit from long gone years smiley
14  General Category / General Discussion / Re: Single board computers: Which one to buy? on: April 09, 2013, 12:20:04 pm
Those Android-systems are pretty neat, but i like to have a little bit more flexibility on the OS-side. I would have repurposed my old phone, but it broke short after my old contract ran out smiley-roll-blue...
15  Using Arduino / Programming Questions / Changing function state from inside a if-loop? [Solved] on: April 09, 2013, 11:58:51 am
I'm building a ATtiny85-based control and reset-circuit for my Raspberry Pi and the attached HD44780-LCD. It's meant to turn the LCD on or off and trigger a reset to wake the Pi up from shutdown, but the reset should only be possible if the LCD is turned off. After resetting the Raspberry Pi the LCD should turn on by itself. Should be simple, but that's where I'm stuck. I tried a lot of stuff, but I just cant figure out what I'm doing wrong here. The sketch is working, but how do I get the LCD to turn on after triggering the reset?

Here's my sketch:
Code:
int push = 3;                   // LCD on/off button
int val;                        // variable for reading pin 3s status
int val2;                       // variable for reading pin 3s status
int buttonState;
int LCDMode = 0;                // LCD on/off
int gndSwPin = 2;               // transistor for LCD grounds

int ledPin = 0;                 // Blinkenlight

int rstBtn = 4;                 // button for rPi reset circuit
int rstOut = 1;                 // transistor for rPi reset circuit

int value, value2 ;             // fade for Pin 0 LED
long time=0;                    // fade for Pin 0 LED
int periode = 2000;             // fade for Pin 0 LED

void setup()
{
  pinMode(rstOut, OUTPUT);     // reset transistor
  pinMode(rstBtn,INPUT);       // pin 4 button
  digitalWrite(rstBtn,HIGH);   // internal pullup

  pinMode(push,INPUT);         // LCD on/off button
  pinMode(gndSwPin, INPUT);   // transistor for LCD grounds
  pinMode(ledPin, OUTPUT);     // Blinkenlight
  digitalWrite(push,HIGH);     // internal pullup
}

void loop()
{
  int mode;                                // LCD on or off
  mode = chkbtn();                         // see below

  if (mode == 0) {                         //LCD off
    int rstState = digitalRead(rstBtn);    //reset pulse
    if(rstState == LOW){                   //reset pulse
      digitalWrite(rstOut,HIGH);           //reset pulse
      delay(40);                           //reset pulse
    }
    else{
      digitalWrite(rstOut,LOW);              // don't reset
      digitalWrite(gndSwPin, LOW);           // LCD off
      digitalWrite(ledPin, LOW);             // LED off
    }
  }

  if (mode == 1) {
    digitalWrite(gndSwPin, HIGH);        //LCD on
    int ledVal;                          //LED fade
    ledVal=fade();                       //LED fade
    analogWrite(ledPin,ledVal);          //LED fade
  }

}

int chkbtn(){                          // state for LCD

  val = digitalRead(push);             // read input value and store it in val
  delay(10);                           // 10 milliseconds is a good amount of time
  val2 = digitalRead(push);            // read the input again to check for bounces
  if (val == val2) {                   // make sure we got 2 consistant readings!
    if (val != buttonState) {          // the button state has changed!
      if (val == LOW) {                // check if the button is pressed
        if (LCDMode == 0) {            // if its off
          LCDMode = 1;                 // turn LCD on
        }
        else {
          if (LCDMode == 1) {          // if it's on
            LCDMode = 0;               // turn LCD off
          }
        }
      }
    }
  }
  buttonState = val;                   // save the new state in variable
  return LCDMode;
}

int fade(){                            // LED fading stuff
  unsigned long currentMillis = millis();

  time = millis();
  value = 128+127*cos(2*PI/periode*time);
  value2 = 128+127*cos(2*PI/periode*(0-time));
  analogWrite(ledPin, value);
  return value;  
}
Pages: [1] 2 3 4