Show Posts
Pages: [1] 2 3 ... 5
1  Using Arduino / Programming Questions / Re: Problem with code? on: May 12, 2014, 07:38:48 am
If your are powering the servos from the 5V output of the Arduino, you should add a good capacitor. 330uF or more should be OK.

I had problems with a servo connected to th5 5V output of the arduino. When I tried to move the servo, the Arduino was resetted (probably due to noise introduced by tye motor). I solved it adding an electrolitic capacitor. The problem was with one of this cheap chinese servos like this:


2  Using Arduino / Programming Questions / Re: Problem with deep sleep and wake up interrupt on: May 12, 2014, 07:30:25 am
Quote
Ah! I added the delay for avoiding contact bounces.
If you have a switch that bounces for half a second, throw it away.

Ok, it could be less time, but I think a delay is needed.
3  Using Arduino / Programming Questions / Re: Problem with deep sleep and wake up interrupt on: May 12, 2014, 07:27:05 am
Quote
I added this line to avoid it and it works, but I think it should be a better solution.
Code:
     while(digitalRead(2)==LOW)
{
  // Doing nothing
}

Ah! I added the delay for avoiding contact bounces. Otherwise, the digitalRead could read a HIGH value but some microseconds later the value could be LOW and produce the described problem.
4  Using Arduino / Programming Questions / Re: Problem with deep sleep and wake up interrupt on: May 12, 2014, 07:07:59 am
Code:
     while(digitalRead(2)==LOW)    delay(500);
Why do you have to do anything when the pin is LOW? Certainly, delay() is not the thing to do.

This is what I'm asking. Describing the situation: I have a pushbutton connected to pin2 and GND. I've activated the pin2 pullup. When you push the button, the program plays a tone and calls the "gotosleep" function.  When you press again the button, the sywtem wakes up.  All ok until now.

The problem: if you press the button and keeps it pressed, the processog goes to sleep but you can never wake up it again, even pressing the button.

I added this line to avoid it and it works, but I think it should be a better solution. A key bounce could produce the same situation and other sensor input could produce the same problem. Then, I want to find a better solution for the future.

5  Using Arduino / Programming Questions / Problem with deep sleep and wake up interrupt on: May 12, 2014, 06:51:10 am
I have a project which uses deep sleep to save battery.

The wake up is triggered by an interrupt (falling edge on pin 2). It works ok but I discovered that if pin 2 is down (LOW) in the moment the processor goes to sleep, the wake up is never triggered.

I solved the problem by checking the pin is HIGH before seeping, but I think there must be a better solution.


Code:
void pin2_isr(){
  sleep_disable();
  detachInterrupt(0);
}

void gotosleep(){

  //ADDED FOR AVOIDING PROBLENM WITH WAKEUP
     while(digitalRead(2)==LOW)    delay(500);

     attachInterrupt(0,pin2_isr,LOW);
     set_sleep_mode(SLEEP_MODE_PWR_DOWN);
     cli();
     sleep_enable();

     sei();
     sleep_cpu();

//////// afeter wake up

     sleep_disable();
     detachInterrupt(0);
     Serial.println("encendido");
     Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
     tone(BUZZER,880,10);
     delay(100);
     while(kpd.getKey());
     delay(100);
     memchr(s,sizeof(s),'\0');
}
6  Using Arduino / Programming Questions / Re: Interrupts alternatives on: May 12, 2014, 06:03:57 am
and   i would like to use A0 as pulses in.My question is if there is a command or funtion to measure the change HIGH to LOW like
attachInterrupt(0 or 1, function to call, FALLING) on digital pins.

You can monitor change on pins. You target one or more pins and when the status of any of this pins changes, it will trigger an interrupt. In your routine you should (quickly) check the current status of the monitored pins. If you are monitoring more than one, you need to quickly check which of them triggered ths interrupt. You can monitor RISING, FALLING and CHANGE status.

An example:

Code:
#include <PinChangeInt.h>
#define DATA 8

void setup() {
  pinMode(DATA, INPUT);
  PCintPort::attachInterrupt(DATA, &cambio, CHANGE);
}

void cambio() {
if (digitalRead(DATA)==HIGH){  //this is a rising edge
    ........ code .......
      }    
else { //this is a falling edge
    ...... code.....
    }
}


Here is a project where I used this method: http://translate.google.com/translate?js=n&sl=auto&tl=en&u=http://alejandro-anv.blogspot.com.es/2012/12/hackeando-termometro-inalambrico.html (google translated)
I'm attaching the library I used just in case.
7  Using Arduino / Programming Questions / Re: Leonardo keyboard leds emulation? on: March 06, 2014, 02:45:09 am
I'm attaching the patched files resulting of applying usb_key_leds.diff to arduino version 1.0.5

Not tested it yet.
8  Using Arduino / Programming Questions / Re: Leonardo keyboard leds emulation? on: March 05, 2014, 12:11:50 pm
A patch file is a file that indicates how to modify a given source code (or any text file) to obtain a new one with some changes.

Essentialy, a patch file contains data indicating something like "add this line, remove that one, etc.". It is generated by the unix command "diff" that compares two files and responds with this data. Having the patch file and the original file, one can use the command "patch" to obtain the modified version.

[edit] (found the patch file). I am applying it:
# cd /usr/share/arduino/hardware
# patch -p2 </home/anv/Descargas/usb_key_leds.diff
patching file arduino/cores/arduino/HID.cpp
patching file arduino/cores/arduino/USBAPI.h
Hunk #1 succeeded at 111 (offset -1 lines).
Hunk #2 succeeded at 131 (offset -1 lines).
Hunk #3 succeeded at 140 (offset -1 lines).

I'm attaching the result files
9  Using Arduino / Programming Questions / Lonardo ENTER vs. NUMPAD ENTER on: September 08, 2013, 03:40:11 am
A am trying to create a simple program for sending texts to the PS3 using keyboard emulation of Leonardo.

It works but the ENTER key is not accepted by the console. I tryed with a real usb keyboard and the enter key in numeric keypad is not accepted by the console. Then, I must asume that Leonardo libraries are sending this key instead of the normal enter key.

I see in the code that KEY_RETURN is defined as 0xB0 but I checks the documentation about scancodes in internet (like http://www.quadibloc.com/comp/scan.htm) and the codes are very different, then I understand that throug usb the codes sent are different: i.e. The scancode for F1 is 07 but the key definitions in arduino's USBAPI.h says #define KEY_F1 0xC2

Any help please on finding the right code or locating the problem with the PS3?

Update: I found this http://www.mindrunway.ru/IgorPlHex/USBKeyScan.pdf but it says KP Enter is 58 and normal Enter is 28, but USBApi.h indicates KEY_RETURN=0xb0.


10  Using Arduino / Installation & Troubleshooting / Re: Arduino RPM for Mageia 3 on: August 05, 2013, 09:20:15 am
I'll have to check with Mageia community to fix it for the M4 version.

It is possible to create a working mageia packet up from sources, but there are many problems on this. I.E. I found that avr-gcc 4.3 compiled from the sources can't create binaries for arduino leonardo. I asked the Arduino people for the exact pathces they are using but they answered me that they are using the Ubuntu binaries.

Then, I decided to create an rpm packet containing the official binaries with a few changes. Tis is a dirty solution that Mageia comunity will reject to use. Then, I think they will continue with the same sources as in Mageia 2 that were reported not working.
11  Using Arduino / Programming Questions / Re: Leonardo keyboard leds emulation? on: June 23, 2013, 09:46:54 am
Quote
Then, the keyboad chip must be able to receive controls from the PC... what seems to be lacking in Arduino HID implementation...
It's open source. Quit whining and add it, if you need it.
Of corse, just now I am checking the code. But first I wanted to ask if there where some way of doing it without modifying the libraries.
12  Using Arduino / Programming Questions / Re: Leonardo keyboard leds emulation? on: June 23, 2013, 09:10:15 am
Your original posting made no mention of a second keyboard, only the one being emulated by the Leonardo, hence the comment that as you were setting the Shift lock/Num lock status using the Arduino you had sent the status to the PC and did not need to receive it back.

It does not matter how-many keyboards have you connected to the PC. The system is made in a way that allows many keyboards, then, the lock status is managed by the operating system and NOT by the keyboard. Then, the leds are controlled by the PC software and NOT by the keyboard itself. When you press caps lock, it does not turns on the caps lock led. The heyboard send the scan code (row/column) to the PC. The PC software changes the status of a flag and sends back to the keyboard the command for tuning on or off the led. The led status is not decided by the keyboard chip: it is completely controlled by the PC's operating system. Then, the keyboad chip must be able to receive controls from the PC... what seems to be lacking in Arduino HID implementation...
13  Using Arduino / Project Guidance / Re: Read keyboard led status on: June 23, 2013, 07:42:52 am
I have an external usb keyboard of which the status leds follow the leds of the internal keyboard of my laptop. So if I press numlock on my laptop, the numlock leds of both the laptop and the external usb keyboard light up.

I meant 'using the Arduino as a keyboard' using the Keyboard libraries (http://arduino.cc/en/Reference/MouseKeyboard) to send keypresses. I was considering building something akin to this usb-password-typer. http://ob-security.info/?p=631

So I guess catching the led status should be possible via usb, but it might indeed not be implemented in the keyboard library yet.

Did you find anything about this? I am searching for the same feature. May be we need to modify the Keyboard library at HID.cpp...
14  Using Arduino / Programming Questions / Re: Leonardo keyboard leds emulation? on: June 23, 2013, 07:31:13 am
What LED and what status are you talking about? Shift lock, num lock? If so, didn't YOU send that information to the PC?

In the very very old XT keyboards, the num lock/caps lock/scroll lock status where sent only from keyboard to PC. Xt keyboards didn't receive info from the PC. But since many years with the AT keyboards, the communication is bidirectional, then you can connect two keyboards to the PC and hitting num lock in one affects the led status in all keyboards. Then, you can change the caps/scrool/num lock statys by software and this status is shown in the leds. Remember that keyboards does not send "letters" to the PC; it sends row/column of the key. Caps lock key is only another key with it's own row/column scan code and hitting it not necessarily will cause the caps lock led to get on or off. It is controlled by software in the PC.

 
15  Using Arduino / Programming Questions / Leonardo keyboard leds emulation? on: June 23, 2013, 06:34:11 am
I am trying to create an USB keyboard controller with an Arduino Leonardo, but I can't find the way to emulate the keyboard leds. The PC sends the leds status to the keyboard but the Keyboard object on Arduino seems not to have any read function or any way to get the leds status.
Pages: [1] 2 3 ... 5