Why are we connecting these things…
Ok guys, I think I can start to see the issue here…
Firashelou, I think you are (and have been) looking for a tutorial that tells you step-by-step how to connect everything and what code to run. When I say “step-by-step” I mean, I think you are looking for a very specific tutorial, using EXACTLY the parts you have, using the EXACT set up you have. When you have been able to “make it look like the picture” you can get it to work, however, when we add any deviations, we run into problems. As an example, I note your 4-pin unit and the 8-pin unit I linked to… You seemed very confused (and did not want to follow the tutorial) when in reality, the units were almost identical with the pins simply being repeated twice (two grounds, two VCC’s etc). --This leads me to think you can/ have followed tutorials in the past, but only by matching what they are doing --not knowing why these things are connected this way.
I could not help but notice this seems to be the case with your Fritzing… The guys are arguing that the pinout is not correct, you say you matched a tutorial exactly, and then we start talking model numbers of specific parts. --This is what I am talking about. The transmitter does not work because it got plugged into the breadboard a certain way --it works because it has power, gnd, signal and antenna. Almost 1/2 this thread is about pinouts and devices and its for a simple reason --we are all here at step 47, but skipped steps 1-10.
Here’s what you do:
Forget about the motor, forget about the tutorials, turn off the youtube. Disconnect every wire you have everywhere. Now, grab only the TX unit. Hold it in your hand and see if there are any markings near the pins. Are there? If so, write them down. Now, find the specific datasheet for your specific model (specifically from where you bought it) and find the page with the pinouts. Confirm that what is written on the device (if any) matches what is in the manual. Now double check it. Now, in your notebook, draw a little picture of your TX unit, draw the pins, and lable them in the drawing. Draw it clearly so you can not get confused as to which side of the device you are looking at. You may even want to grab a marker and put a dot over pin 1. Take your time, be sure you are correct before you draw that picture in your notebook. ***Nothing goes in the notebook that you are not 100% sure about.
Repeat the above with the RX unit. Take your time, use the same amount of care. Put everything in your notebook.
You should not need a tutorial for any of the above, just the 2 units and datasheet(s).
Once you are 100% sure you have the pinouts correct, plug each unit into its breadboard. Connect nothing else. Go back to your datasheet and confirm the VCC requirements of the units (are they 3.3v or 5v units?). Once you have determined the power required, connect only GND (ground) and VCC (3.3v/5v) to each unit. At this point, you may also connect the short piece of wire needed for the antenna. Do not connect anything else.
At this point, we can be fairly sure we have everything connected correctly. --Not because we matched what a youtube video “looked like” but because we checked datasheets, checked pinouts, and knew why we were connecting what-to-what. I should also note that we do NOT have a motor connected right now. --The reason is, we have no idea if the motor’s connections work or not. We have not tested the motor by itself, we can not trust it as a “indicator” at all, we should not use it for testing.
If we look at our notebook and out breadboards, we will notice we probably have 2 connections left, one on each unit --TX/RX. The TX will have to come from an output of one arduino, the RX to the input of another. At this point, we don’t look at the youtube or the tutorial to find where they go, we look to the code. It usually does not matter what goes where, as long as the pin defined in the code, matches real life. Confirm your pin numbers and make your final two connections.
Now, at this point, I would actually use the tutorial (or at least its code). I would try to find the easiest, simplest sample code I could find and run it. Specifically, I would use the example included with your library. Do not modify it, and make note of any comments included in the header of the code. --If any weird connections are required, they are usually noted in the comments of the code example.
Run the example code. Confirm that it works. If it does, we now know one important thing: Your TX and RX units are wired correctly and work. Do not change or disconnect anything from here-on-out. This is now a constant. As we move on and you change things (and it stops working) we will now know the problem is the thing you added or changed, we can trust the basic set-up (we tested it individualy).
From here, I suggest going back to the ASCII stuff, and more importantly, sending that 1,2,3, count. Have the TX send a simple count 0-255, once a second. Try to catch this on the RX end. Play with different formats --defining the variable to be sent as a byte, char, str, etc. Read any info you can find about the library and how things get sent. Same thing with the receiver --do you need to convert variable types as they come in? --Play with this, play with this, play with this. --Don’t follow tutorials, do this like a scientist --one thing changed at a time, run it, note the results. Read the Arduino website about data types, hit the arduino playground for info about the TX units, read info about the library. In the end, be able to send a 27 and get a 27 --or be able to send an “A” and get an “A”.
Now, take all of the above and forget about it. Grab only your pot. Use the basic arduino example (in the IDE) to read your pot and send the numbers to the serial monitor. Test the pot by itself. You should be getting close to a 0-1023 range in the serial monitor. Convert this number to a byte using the Map function or by simply dividing by 4. Repeat the test above and confirm that you are now getting numbers (from the pot and ADC input) of 0-255 in the serial monitor.
Now, go back to the code you use for the “counting” test (remember, we tested it by itself and we know it works). Remove the counting bit, and instead add the code needed to read your pot and convert to 0-255. I would leave in the 1 second delay however. Now re-run this code. Does this code work just like the counting code? Does the number change on the RX end as you turn the pot on the TX end? --I would be it does work… We tested each part by itself! –If this does not work, you should have no problem finding out why --you tested each part by themselves, you know how they work.
At this point, you can move on to your motor. Test it by itself. Build the little circuit, and connect the final “control wire” (going to the base of the transistor) to the PWM output pin of your Arduino. Write some code to play with the analogWrite command and be sure your motor works and you can control its speed.
And that’s it. --You can now read a pot, send a number, control PWM via analogWrite --and you know each one works by itself. Just put them together now.