I am looking for some help well, probably a lot of help.....
Anyway, I have absolutely no experience of Arduino or electronics for that matter but am looking to learn.
I am looking to make a button box for use with a flight simulator or to be more precise, I have already made the box and have mounted five switches and one LED in it.
Three of the five switches are on-off-on the other two are on-off.
I have a Pro Micro 5V board but have absolutely no idea how to wire the switches and LED and beyond that I have no idea about creating a program.
I have looked at various instructions on the internet but nothing specific to what I am using unfortunately.
Ideally I would like to be able to bind keys to the switches from within the flight simulator.
Should I start with writing the code or should I begin with wiring? Either of which, can you suggest where I could get help with both? Preferably on this site please.
In Arduino world you can't do anything without code and wiring, so forget the question.
But my advice would be to start simple, testing as you go, and build up in small stages.
So start with just the led. Connect that to a digital pin on the Arduino, upload the blink sketch from the example menu and upload that. Don't forget the series resistor for the led.
Next, connect up one switch. Write a short sketch to read it and echo the result to the serial monitor.
Then add another switch, update your sketch, re-test everything etc.
Finally, add the code to make the Micro act like a keyboard. This will be the most complex single step. Break it down by starting with getting a single switch to work and to be interpreted as a key press by the pc.
Three of the five switches are on-off-on the other two are on-off.
That made no sense. Post links to the page or data sheet where you purchased the switches and we can advise how to connect them.
For the on-off-on switches, wire the common pin of the switch to ground. Wire the other two pins of the switch to two data pins of the pro micro.
For the on-off switch, wire one pin pin of the switch to ground and the other one to a data pin of the pro micro.
You should now have 3x2 plus 2x1 wires from the switches to 8 pins of the pro micro.
You can use pinMode(somePin, INPUT_PULLUP) for each of the input pins on the pro micro.
Wire the anode of the led to a pin on the pro micro. Connect a resistor (330 phm or so) to the other side of the led and the other side of the resistor to ground.
Now experiment with some examples.
@PaulRB, I think op is talking about double throw swtches.
a good way to handle the on-off-on switches is to connect the throw (center) to ground, and each of the two other pins to an input configured for input pullup with pinMode(pin, INPUT_PULLUP);
Get an intro text, free download, Sparkfun has one and there should be one here also
consider getting a prototype board (has holes for wires and such, just jam them in the holes) and some misc. pieces, jumpers, LED's, resistors switches and such
Work through the first few lessons, that will give you some basics on both wiring and programming - modify the sample programs to do a bit more
Write out you code in English sort of like an outline, helps to sort out what you want to do - THEN start writing the code
Do small pieces as suggested above
I used to do large industrial systems and I always outlined things first to help my thought process, and the code was broken into small subroutines (functions here)
@GoForSmoke no dials or sliders, HOTAS takes care of what's needed though, if I'm successful with this, I would like to maybe make a new controller that outputs FTIT, RPM, OIL Pressure and then a 16 x 4 display.
@saildude thanks, I have various parts from a Fritzing kit and realised there was wiring software to go with it so messing around with that just now, I have a breadboard and perf boards too - I'll take your advice to break it into small parts and start with the LED wiring once happy I'll move onto wiring the switches using sterretje's advice above then I'll look at the coding.
You can not connect a 12V led to an Arduino without taking precautions and that resistor that I mentioned will not be enough. Please provide a link to the product.
Generally, FRITZING diagrams are frowned upon here - for anything more than a blinking LED or a single servo... they're completely 'non-standard', and the colours / layout are more confusing than a sketch on a table napkin.
To be honest, as soon as I see Fritzing, I close that page, and look for someone else to help if I can.
I knpow everyone has to start/learning somewhere... but Fritzing is just sooo wrong!
You should think of the code from the start. If you code the mode for the input pins for the buttons then you won't need pulldowns for the buttons. If you code for button bounce you won't need to wire caps across the switches. The code and wiring should fit the solution together, it will save work.
Do you solder? Do you have heat-shrink tubing and wire/jumpers, maybe a breadboard?
Did you know that you can make multicolor indicators? There's RG leds that can be red,green, amber or off, for example. Amber is both on, it's a 2 pin led. The bulb on those glows the color, does not need a diffuser to be seen.
Grumpy Mike lit ping pong ball halves from inside with 5mm RGB leds and got great looking big dots out of small leds. RGB leds (that I got so far) have clear bulbs. When you look right at one lit, you see pin-bright specs of light from the junctions for illuminating past the bulb. It needs diffusing to be an indicator lamp.
Take care when you buy about common cathode(ground) or common anode(power). I like common cathode (common ground, not common power) better.
If your Pro Micro has pins, female jumper ends will fit well. Look for DuPont cable, it's 40-wire ribbon cable with separate ends for alkl the wires. You peel off as many lines as you need at a time for jumpers or DIY cables. You pick what ends you want, cut, splice, plug and you're good. You might be surprised at how much circuitry can be embedded in a cable as opposed to taking space on a board.
PS -- AC switches and DC switches differ but I think that at 5VDC it won't be a problem.
lastchancename:
Generally, FRITZING diagrams are frowned upon here - for anything more than a blinking LED or a single servo... they're completely 'non-standard', and the colours / layout are more confusing than a sketch on a table napkin.
To be honest, as soon as I see Fritzing, I close that page, and look for someone else to help if I can.
I knpow everyone has to start/learning somewhere... but Fritzing is just sooo wrong!
Point taken however, what would you recommend for a complete beginner like myself? I had read about a program called eagle though, the advice was that it was counter intuitive for beginners.
I had purchased the Fritzing Arduino beginners kit and given its poor formatting I can understand why it may be frowned upon though, given it's a beginners kit, as a beginner, you can't help but assume there's an endorsement between the two?
I am a bit of a Luddite and for my circuits now I just sketch by hand since they are for my own use or a few others - I like to keep some things simple
There are a lot of Fritzing-bashers around here. The product does not deserve all the bad press it gets. The problem is the reputation it has gained because so many newbies post "breadboard view" pictures, and call them schematics. Which of course they are not. Fritzing has a schematic view also, but beginners shy away from that, perhaps because it's less immediately representative of what they have in front of them.
When forum members do post Fritzing "schematic-view" schematics, there is usually no complaining. When there are complaints, it's often some mistake a newby would probably have made using any other schematic editor. But somehow Fritzing gets the blame of course.
All that said, I did start using Fritzing years ago when it was new. But later I switched to Eagle. And while it is more powerful and has much more extensive parts libraries, it is less intuitive!
Okay, thanks GoForSmoke, new search items for me, code the mode and button bounce, excellent.
Don't solder no, but do have an iron. Got breadboards, jumper wires, resistors, leds and various other bits and pieces that I will no doubt learn about in the future oh, and shrink wrap tubing....wonderful stuff I discovered, when I realised I had nipped the thermistor on my printer.....Dupont cable arrives tomorrow, thanks again these look really helpful.
Having introduced the Fritzing bashing in this thread...
I have to agree the schematic view is much ‘better’, but once you learn to crawl, PLEASE learn the styling of ‘real’ schematics - as they are so much more informative, and easy to follow electrically and logically.
Supply rails highest to lowest, from top to bottom...
Signal flow from left to right...
Don’t be afraid to break ‘lines’ to create meaningful circuit blocks.
Just remember to label and connect everything!
a good schematic is far better than a photo of your breadboard, and is a bit like comments in your code - very helpful 6-12-24 months later!
ddoc:
Okay, thanks GoForSmoke, new search items for me, code the mode and button bounce, excellent.
Don't solder no, but do have an iron. Got breadboards, jumper wires, resistors, leds and various other bits and pieces that I will no doubt learn about in the future oh, and shrink wrap tubing....wonderful stuff I discovered, when I realised I had nipped the thermistor on my printer.....Dupont cable arrives tomorrow, thanks again these look really helpful.
The mode in Arduino is pinMode() that lets you set a pin as OUTPUT, INPUT, or INPUT_PULLUP. OUTPUT can be HIGH or LOW, INPUT_PULLUP is HIGH through 20+K resistor and INPUT looks neutral, 1 digiital read takes 1 microAmp.
Changing pin modes lets you multiplex buttons, run capacitive touch buttons, sense ambient light level with the same led being adjusted to match ambient light without the user noticing, neat little tricks you only use because you know how.
Check Youtube for soldering tutorials. I wear magnifiers to see breadboard hole spacing.
One of the books I got to help me learn uses what I am assuming is Fritzing with the sort of like a picture of the breadboard - gray on gray wires - I find it so difficult to work with - a plain old schematic is much better and way easier to troubleshoot also - extra comments on the schematic as well as the code help also -
lastchancename:
Generally, FRITZING diagrams are frowned upon here - for anything more than a blinking LED or a single servo... they're completely 'non-standard', and the colours / layout are more confusing than a sketch on a table napkin.
To be honest, as soon as I see Fritzing, I close that page, and look for someone else to help if I can.
I knpow everyone has to start/learning somewhere... but Fritzing is just sooo wrong!
well, actually the realaity screen shot is frowned upon.
the schematic is valuable.
the reality screen shot helps the user kinda-sorta figure where things go.
the schematic does not make sense to the user, but is all we care about.
what we need to get the OP to do is select SCHEMATIC VIEW.
disclaimer, it is still crap, but about 1,000 times more readable. especially if the parts count is less than a few dozen.