Pages: 1 2 [3]   Go Down
Author Topic: Quick suggestion on approaching this problem  (Read 2679 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's the problem then. There is no way that a serial port sending ASCII codes can convey information about how long a key was pressed. I think a Leonardo could do it, because I believe it can emulate a USB PC keyboard, for which the up- and down-codes are sent separately.

Problem with that is that the Leonardo doesn't have enough analog pins.

Do you know how I can fix the issue where your code works flawlessly in the serial monitor but starts glitching when I turn on aac keys?

Not without using a Leonardo or other device that can emulate a keyboard that returns scan codes. How many analog inputs do you need, and why? The Leonardo has 12, and you can add more using an external ADC or analog multiplexer.
That's the problem then. There is no way that a serial port sending ASCII codes can convey information about how long a key was pressed. I think a Leonardo could do it, because I believe it can emulate a USB PC keyboard, for which the up- and down-codes are sent separately.

Problem with that is that the Leonardo doesn't have enough analog pins.

Do you know how I can fix the issue where your code works flawlessly in the serial monitor but starts glitching when I turn on aac keys?

Not without using a Leonardo or other device that can emulate a keyboard that returns scan codes. How many analog inputs do you need, and why? The Leonardo has 12, and you can add more using an external ADC or analog multiplexer.

I'm just wondering because it has that same issue when using it to print the letter a in a word document. 

I need 13 analog pins.  I want to go one full octave from c to c
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6639
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Why are you using analog pins, when it looks to me that you only need to detect whether a note is pressed or not?
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why are you using analog pins, when it looks to me that you only need to detect whether a note is pressed or not?

I initially tried using the digital route and was noticing it was rather unstable.

But you are correct all I need to detect is on or off
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6639
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Given that your threshold was 830 out of 1024 and you register a key press if the value is above threshold, I deduce that you are using pulldown pullup resistors, and that to use digital inputs, you need to decrease increase their value by a factor of about 4. If the Arduino by itself doesn't give good results using digital inputs, you could pass the signals through 74HC14 hex inverters first.

btw I've never used a Leonardo, but I understand that it can emulate a PC keyboard via the USB port.

[EDIT: corrected the above, on the assumption that interrupting a light beam causes a note to sound.]
« Last Edit: January 04, 2013, 07:19:41 pm by dc42 » Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Pages: 1 2 [3]   Go Up
Jump to: