Do any of you guys have helpful tips and advice for a beginner in programming and Arduino usage? This is obviously coming from someone with zero coding experience and open-source hardware knowledge. Any past experiences and tips on how to learn would be extremely helpful. Thanks!
Duly noted, lmao thanks
Hi,
I'll give you my opinion, which definitely doesn't apply to everyone.
I'm new to arduino (in the last 6 months) but not new to microprocessors. I came to arduino because the boards were readily available for small one or two build projects. I've been using the arduino pro mini's.
Remember this is only my opinion, I'm sure there are many other opinions.
The arduino platform and especially the IDE is designed to help the new user accomplish some useful task(s) before they reach their frustration limit and give up. To that end it succeeds. The programming language is C++ and (I think) with some C mixed in and a lot of specialized commands (actually macros) to run many of the peripherals.
It is very forgiving when it comes to strict programming structure, or maybe it is just syntax.
There are many commands that allow you to use the processor functions without really knowing the idiosyncrasies of the processor.
I personally found the lack of strict definitions and the inability to control the explicit settings of the processor not to my taste. I prefer to understand the processor functions at the datasheet level.
For instance:
Task, Arduino IDE, create a PWM output
The statement: analogwrite(pin, value)
will created a PWM's output of ~ 490 Hz
In C using the Atmel Visual Studio you must:
- define the clock frequency
- define the value of the clock prescaler
- define the output pin as an output pin (as opposed to an input pin)
- define the mode the PWM section of the processor will be set to.
- define the PWM dutycycle
- turn on the PWM
A lot more code but one has complete control over the processor functions. Where the arduino IDE makes a lot of those decisions for you so you don't have to but you loose detail control.
Folks will point out you can use C++ or C in the Arduino IDE environment however you loose some of the syntax checking that I personally welcome as a means to learn better coding methods.
So if you don't know or you aren't sure where to start, I would suggest you study the datasheet of one of the arduino processors if only to get a sense of that the processor can do. (i.e. Analog input (A/D), PWM, Timers, Pulse width capturing Pulse frequency capturing etc).
I would then study the C language perhaps with the excellent book "The C programming Language
By Brian W. Kernighan and Dennis M. Ritchie"
I hope this helped and not made the topic more confusing.
BTW I like purple, but there is likely some unwritten rule against off color test. Maybe similar to all capitols is equivalent to shouting.
Good luck
John
Eschew the Blink sketch, and get your head around BlinkwithoutDelay as soon as you can. Pretty much anything meaningful you want to do will be more difficult if you let Blink get a hold.
Spend as much time as necessary here: it's full of good stuff.
Don't be afraid to ask, but always try first. Then when you do ask, remember to post your code using the </> tags, along with schematics of your system, and links to datasheets of all but the most mundane generic components.
Well done on losing the purple
JohnRob:
So if you don't know or you aren't sure where to start, I would suggest you study the datasheet of one of the arduino processors
Yeah, right.
Incremental. Code some. Debug some. Repeat. With the exception of time critical things your code should be riddled with Serial.print calls. (Ideally you would use "test-driven development" but I don't have the patience for it so I rarely suggest it for others.)
Correct then optimize. Always get the code working correctly before optimizing.
Profile then optimize. Always profile the code before optimizing.
Choosing an efficient algorithm is not the same as optimizing. Choose algorithms carefully, wisely, and early.
Get a PC development tool installed and working (I use Visual Studio). Some of the code you write can be first written on a PC which is a much more forgiving environment.
Use the highest possible baud rate (I believe it is currently 250000 for Serial Monitor).
Don't use interrupts unless there is absolutely no other way to solve the problem.
Advice from someone else: The first time you buy a piece of hardware (e.g. a sensor you have never used) get two (or more). Assume you are going to make a mistake that results in the new hardware being turned into slag. In the best case you have a second one to play with. In the worst case you don't care because you have a second one to replace the damaged one.
Get a good quality powered USB hub and use it. Never connect a microcontroller (an Arduino board) directly to your computer. A hub can be replaced for $50. An Arduino can be replaced for $35. Your computer is orders of magnitude more expensive. Protect your computer.
USB cables do occasionally fail.
As a noob myself, my simple little advice to you is to keep spares of everything. It makes it easier for you to find out whether your hardware is broken or is it just some other fault.
I recall an old saying that you should get three. Something along the lines of one to lose, one to abuse, one to use.
You are posting this in the hardware forum, here are some hardware tips.
https://forum.arduino.cc/index.php?topic=445951.0
Arduino links.
Watch these:
Some things to read:
https://learn.adafruit.com/category/learn-arduino
https://learn.sparkfun.com/tutorials/how-to-read-a-schematic
http://playground.arduino.cc/Code/AvoidDelay
https://forum.arduino.cc/index.php?topic=384198.0
https://learn.sparkfun.com/tutorials/using-the-logic-level-converter
http://arduino-info.wikispaces.com/
.
Oh, here's something. While learning, use your Arduino to actually solve a real life problem you face, instead of simply repeating all those popular projects you see online like a weather station or a motor controller. This way not only will you learn faster but might also help others who may be facing the same issue.
Best advice I can give is to stay away from ebay and amazon. Stick with reputable vendors who back their product with datasheets, libraries, demos, and customer support. Adafruit and Sparkfun are good places to look at, along with this forum if you get stuck.
Even if you don't want to get deep into the electronics end of it, you should still learn some of the basics. Hooking up modules and peripherals still requires an understanding of voltage/current and ohms law (easy).
tinman13kup:
of voltage/current and ohms law (easy).
Which leads to my next tip: your tool kit really must include a multi-meter.