Show Posts
Pages: 1 ... 4 5 [6] 7
76  Forum 2005-2010 (read only) / Interfacing / Re: Newbie having trouble with IR remote servo project on: January 17, 2011, 06:35:00 pm
I'm still a bit confused how to correctly do so.  I've tried all sorts of ways to use those hex values.  Stuff like
if (results.value  == FFA25D) {myservo.write(position1);},   or
if (results.value  == (FFA25D, HEX)) {myservo.write(position1);}
but all I get is compiling errors.

I tried loading the IR recieve example again, but deleted the "HEX" out of the part Serial.println(results.value, HEX);  . This gave different values out of the serial monitor, still unique to each button, such as button 1 is 16753245.  would I have better luck coding with these values rather than the hex values?

also, is there any benefit to using the "case statements", rather than a bunch of "if" statements for each button?  Or will both work equally well?  I only ask because I've learned if statements, but haven't learned case statements yet.
77  Forum 2005-2010 (read only) / Interfacing / Newbie having trouble with IR remote servo project on: January 17, 2011, 05:31:51 pm
I'm trying to be able to move a servo to predefined positions with an IR remote, but I'm having trouble understanding part of the IR programming.  I'm using the IR library by Ken Shirriff.  But here is the biggest problem I am facing so far.

I have searched all over the place, but cannot seem to find any good reference to the commands or code that are available to use.  What I mean by that is, say compared to the servo library, I can find reference to what functions are available for the servos such as myservo.write(),, myservo.attach(), etc.  However I have been unable to find any similar reference for the IR library.  The only commands I found are ones I've attempted to reverse engineer from the examples, and being a newbie, I have found trying to reverse engineer these IR examples to be much more difficult.  If i had a reference to what commands were available, and the correct format to use them in it would be much easier.

Here is the work in progress code that I have so far........

#include <IRremote.h>
#include <Servo.h>
int RECV_PIN = 11;
Servo myservo;   // create servo object to control a servo

int position1;   //servo position 1
int position2;   //servo position 2
int position3;   //servo position 3

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
  position1 = 0;    //default servo positon 1
  position2 = 90;   //default servo position 2
  position3 = 179;  //default servo position 3
  irrecv.enableIRIn(); // Start the receiver
  myservo.attach(9);  // attaches the servo on pin 9
  myservo.write(position3);   //start the servo out at position 3

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value


Now I used the example IRrecvDemo in order to map the buttons of my NEC remote.  For example button one gave me FFA25D, button 2 gave me FF629D, button 3 gave me FFE21D.  But i'm unsure of the correct code to link them, so that pressing button 1 will cause myservo.write(position1).  

Also, I copied all the IR code from the example, and I'm unsure if the serial portions, such as "Serial.begin(9600);" and "Serial.println(results.value, HEX);", are necessary.  Can that stuff be taken out?  Isn't that only necessary if I'm wanting to view the data with the serial monitor?

Thanks for the help.  Eventually what I want it to do is have 3 different buttons for 3 different servo positions.  Then have an up and a down button that move the servo 1 degree at a time in either direction.  Then have 3 storage buttons (so that I can basically program the main 3 servo positions by using the up and down buttons to move the servo exactly where i want it, and press the corresponding store button to store that as position 1, 2, and 3).  Then finally I will want to store those 3 values in eeprom so that I won't have to redo them every time the power is turned off.
78  Forum 2005-2010 (read only) / Interfacing / Re: Hooking microphone up to arduino input. on: January 21, 2011, 01:53:56 am
If you want to discuss something specific, then you must explicitly identify it.

Its just a sound trigger, meaning it hears a sound above a certain level, and activates an output.  It doesn't need to be anything super accurate, just be able to be slightly adjustable so that small ambient noises don't constantly set it off.  Just hoping to hook the mic to the arduino, without having to use a tape player, or other elaborate amplifier, and simply be able to get some sort of value from it so I can set a threshold for when the output is activated.

Sort of like the knock sensor, I've made that and it just used a piezo element and single resistor, and you could adjust the threshold, and it would display how hard the knock was registered with the serial monitor.  I'm looking to do the same type of thing only with a microphone.
79  Forum 2005-2010 (read only) / Interfacing / Re: Hooking microphone up to arduino input. on: January 20, 2011, 10:19:31 pm
Thanks for the help, right now it seems the simpliest preamp diagram I found was this one, and I happen to already have all the parts for it, but will it suit the purpose?

As far as an envelope follower, that is the first time I've heard of it.  Is it really necessary?  I've been reading this page that just has the amp going into the arduino, however it also uses a diode and doesn't explain why (so I don't know if I would need it or not), also his schematic only shows the amp having a gnd and audio in.  Unlike the schematic I found that has +5v, GND, and an output.

This guys got his amp hooked up in some totally different way. although no envelope follower.

Theres just so much different and conflicting stuff its hard to tell the simplest way to just make it work.  I don't need any super accurate sound detection, just maybe 4 levels, none, small sound, medium sound, loud sound.

I've also seen a $5 sound sensor for arduino on ebay that says its capable of monitoring sound levels, I might buy it, but knowing it will take about 2-3 weeks to ship, I'd like to be able to throw something together for the mean time.
80  Forum 2005-2010 (read only) / Interfacing / Hooking microphone up to arduino input. on: January 20, 2011, 09:11:13 pm
I thought this would be simple, but I've spent hours searching for the correct way to do it.  I just want to simply be able to plug in an old computer mic to arduino to measure volume levels for a sound trigger.

My research indicates that I will need an amplified signal to have it work, but when I searched google for simple amplifier schematics, hundreds of different ones popped up, and I'm too much of a beginner to differentiate between them all.  I've seen others using tape recorders and stuff, but it seems like there has got to be a simpler way to do it.  Then I've heard a rectifier may be necessary, and a bunch of other stuff, its all become very confusing with lots of conflicting info.

Isn't there some sort of simple way to do this?  Its not like I'm recording audio in high fidelity.   I just want to hook up a cheap mic and roughly detect volume levels.  I have a wide selection of capacitors and resistors, and even a couple tiny transistors available to use.  

Can anyone tell me the simplest circuit I can make, with the fewest parts, that will make this work?
81  Forum 2005-2010 (read only) / Interfacing / Re: Weird glitch plugging into USB with servo attached on: January 19, 2011, 06:13:55 am
Well its not just the servo that's glitching.  Its the arduino as well, the power and pin13 lights just go crazy and it never actually connects.  All the while, the computer is very rapidly making the noises it makes when a usb device is plugged in and unplugged.  As if I'm plugging it in and unplugging it 5 times per second.  It just goes on like that forever and doesn't connect or initialize right.

If I just unplug the servo signal wire, it works fine.  And it works fine every other time I'm doing something that doesn't involve a servo, even with other sorts of various sensors attached, but for some reason I just can't seem to plug it in with a servo attached or everything bugs out.
82  Forum 2005-2010 (read only) / Interfacing / Re: Weird glitch plugging into USB with servo attached on: January 18, 2011, 06:15:22 pm
I don't have any other battery plugged in when plugging into the usb.  Just usb power only.  Not sure how many amps the servo is, but its a very small 9gram servo.  One of the extremely common HXT900
83  Forum 2005-2010 (read only) / Interfacing / Weird glitch plugging into USB with servo attached on: January 18, 2011, 05:17:39 pm
I tried looking this up, because I figured it would be extremely common, but didn't find anything.

My arduino works completely fine in every respect, except for some reason if I plug the arduino into the usb, with a servo attached to arduino (yellow wire to pin 9, middle red to +5v, and brown to Ground), the servo starts glitching, as well as the arduino/pc.  I get lots of blinky lights from the arduino like its not initializing properly, and the pc doesn't detect it correctly, everythings just kinda going crazy.

I've been getting around the problem by simply unplugging pin 9 whenever I upload code, and then unplugging the usb before reattaching pin 9.  That makes everything work, although I'm still curious why this is happening, does it happen to everyone?  It does seem to make it impossible to use the serial monitor on a project involving a servo.

I'm using windows 7 64bit, Arduino 0022, Arduino Duemilanove
84  Forum 2005-2010 (read only) / Interfacing / Re: Newbie question. Getting IR reciever to work. on: January 16, 2011, 08:49:43 pm
Thanks for the help, I downloaded that library that Big Oil linked to.

As far as the wiring of the IR reciever, I'll just assume the pinout listed for the similar model in the hong kong instructions is right, and if I fry it I'll buy another.

I did find a picture in those hong kong instructions where it shows Right pin going to VCC, middle pin ground, and left pin VOUT going to the arduino board, but it also has one of the 10K resistors going from VCC to VOUT.  Does doing it that way make any sense?  Basically always having current flowing through a 10K resistor into the arduino input pin?
85  Forum 2005-2010 (read only) / Interfacing / Newbie question. Getting IR reciever to work. on: January 16, 2011, 06:53:42 pm
So I'm pretty new to arduino, but have gone through all the tutorials.  And also spent a lot of time researching before asking this.

I bought a IR remote for arduino package off ebay from a hong kong seller.  It came with a NEC protocol remote, reciever, 2 10K resistors, and  some arduino code.  Unfortunatly the instructions aren't very good, and are half in japanese characters or something.  And the code seems to be designed for displaying the remote signal on an LCD, which isn't what I'm going for.

I've searched all over for instructions, and have about 25 tabs open right now, but there are 3 main problems.

1. None of the many many pages I've looked at showed how to properly hook up the IR sensor.  I've searched the web for the correct pinouts, however I seem to find all different sorts of pinouts for all different IR recievers.  The IR reciever I have here is a 9744S.  The instructions that came from the seller list show VOUT on the left, GND in middle, and VCC on the right.  However the picture in those instructions are for an IRM_3638 reciever.  So I don't know how to figure out the correct pinout.  Will I fry the thing f I hook it up wrong?

2. Also, I seem to have been unable to find info on where these 2 10K resistors are supposed to go.  I have no idea, and have been too afraid to hook the thing up without them for fear of frying it.

3.They all seem to have very different code, plus some seem outdated.  One mentioned an actual IR library, but my software doesn't seem to have any sort of IR library in the menu.

If I knew how to correctly hook up the IR remote, I could just experiment with all those codes, but so far I've been worried about frying the thing with the wrong polarity, or having the resistors wrong.

Can anyone help point me in the right direction on getting this NEC protocol remote to work?  All I'm trying to do is a very simple project controlling a servo.  I want to be able to simply press buttons on the remote to make the servo move to specific positions.  I've done some servo tutorials already and think i mostly understand the servo part.  Just need to get this remote part working first.

86  Forum 2005-2010 (read only) / Interfacing / Re: Help controlling a servo remotely on: November 28, 2010, 01:47:09 pm
Thanks so much for the help so far.  I'm getting ready to purchase an arduino, most likely a small one, but I have a couple questions.
1. I've seen some of the small arduinos are 3 volt, but for this application wouldn't I want to make sure to get a 5 volt one since servos run on 5 volts?  Its a little confusing, the nano for example says in the specs it has 5 volt operating current, but in the picture it shows a 3.3 volt output?  So would I want to steer clear from the nano and get one with a 5 volt output for the servos?
2. As far as the remote, would I be best off purchasing something like what's in the following link, would that be easier?  Or would it be just as simple to use some sort of scrap remote I have, like from my car stereo, and just get a little ir sensor from radio shack or something, or would that be more difficult?

3. Is there any reason I might want to consider an RF remote?  Or would that just be more expensive and more complicated?
87  Forum 2005-2010 (read only) / Interfacing / Re: Help controlling a servo remotely on: November 28, 2010, 02:10:57 am
The reason I want to press it half way, then the rest of the way is because like most digital cameras you press it half way and it does all the "thinking" (to put it simply), and then when you press it the rest of the way it fires the shot almost instantly.  If you just press the button all in one motion there will be a delay.

The biggest thing I'm trying to find out now is what all components I need, since I have no experience with arduino.  Ran Talbott mentioned almost any arduino will do. However is an arduino the practically only piece of hardware I need?   Can I plug in (or solder) a cheap ir sensor, and servo onto it, and write a simple program and it will be good to go?  Or am I going to have to buy various "shields" such as some sort of servo control shield, and some sort of remote control recieving shield, and stack them all together for this project?
88  Forum 2005-2010 (read only) / Interfacing / Re: Help controlling a servo remotely on: November 27, 2010, 10:03:30 pm
That is a very good idea, I had looked for similar type of remotes/recievers on ebay (although that one looks nicer than the ones I had found).

The only thing is I don't know that it can necessarily control a servo (or can it?).  Perhaps it can control a solenoid though, but I don't know if a solenoid would be able to do both a half press and full press (aren't solenoids all or nothing?)  Also when I searched for solenoids on ebay I don't find any small rc type ones, they were all big automotive ones (at least all the cheaper $10-$20 ones I was seeing in my search)
89  Forum 2005-2010 (read only) / Interfacing / Help controlling a servo remotely on: November 27, 2010, 08:18:46 pm
I am completely new to arduino, and have done a lot of reading about it, however with so many different arduino boards, and clones, and shields, etc, it is a bit confusing, and I'm hoping someone can help point me in the right direction what I would need for this particular project.

I have a nikon p100 camera, which does not have remote control shutter support.  So I'm hoping to mount a servo right above the shutter button, that can be controlled by remote control to physically press the button.

I want to be able to program the servo with the right amount of range so that I can press one button on my remote control to press the shutter button half way, and press a second button on my remote control to press the shutter button the rest of the way.

The reason I don't use a standard rc tx/rx to control the servo is because the tx is too big and expensive, I want a very small hand held keyfob type remote to control the shutter.

I already have some extra servos from RC planes that I think would work great, I just need to know which arduino board would be best to use to control the servo, and also what sort of remote control control device would interface well with that board (might have to be rf, since I will likely use it in sunlight, although i'd consider IR also, as long as it would work without problems in sunlight)

90  Forum 2005-2010 (read only) / Frequently-Asked Questions / Possibly the cheapest Sound sensor/Sound trigger on: January 23, 2011, 02:05:21 am
So I thought I'd share, I might have found one of the easiest/cheapest sound sensors for Arduino.  (If anyone knows a cheaper/easier one I'd like to hear about it).

Before I found it, I was having all sorts of trouble simply finding a way to hook up a microphone to arduino for a sound trigger with adjustable threshold.  Granted I am very new to all this stuff, so its been like a crash course for me, and much confusion along the way.  I spent hours searching all over these forums, all over the web.  Some people did indeed have an easy method using a guitar amp, or tape recorder, however I wanted to find a way to do it myself without relying on such a device (and not have to carry a guitar amp around).  Others pointed me in the way of rather expensive premade amps, envelope followers, etc.  I tried making my own amp with a LM386 chip, and making a rectifier to follow it (both of which I was completely unfamiliar with beforehand), but didn't seem to have much luck, it seemed to only detect very loud noises.  Hours and research and frustration trying to do what I feel should be the simple task of hooking up a mic to arduino to detect sound levels, I was just about to order the cheapest "arduino sound sensor" I could find, one of these...

....when I just stumbled upon one of these....

....It said in the description "can be direct connected to listening device, no amplifer is needed".  Well luckily, I just happened to already own one in my parts bin, that I had bought awhile ago for about $2.50 shipped.  Although I haven't pulled the shrink tube all the way off to look, it feels like its almost the identical type circuit board as that cheap arduino sound sensor.  I chopped and stripped the cords to find a red, black, and yellow wire.  I hooked them up to the arduino put a diode along on the input (not sure if its even necessary, but had seen other people using diodes, so I just did it), and so far it seems to work fine.

I put it in the serial monitor and with no sound I get a value of about 460.  With sound the value fluctuates up and down (I had a 100ms delay between each print of the serial monitor, so i'm sure its fluxuating a lot more than I am actually seeing). In any case I was able to adjust the threshold to be able to pick up all sorts of levels of noises, even as quiet as me rubbing my fingers together near the mic.

Just thought I'd share in case anyone else is struggling doing the same thing.  If anyone knows any improvements, or better (but still just as cheap), ways to do it, let me know.

Pages: 1 ... 4 5 [6] 7