Jump to content

Arduino programming for beginners.


Recommended Posts

I've had a couple of questions sent to me about where to start with Arduino programming.

To paraphrase, they go a bit like this:- "I'm happy building other peoples projects, using the IDE, compiling and uploading sketches, but I've no idea where to start with writing something of my own. How did you get started?"

Now, I did indeed find it quite impenetrable to start with, and I know I have hardly scratched the surface yet, and have had some very welcome help here on this forum.

So, how did you start? What would you suggest to a beginner?

Are there any recommended guides or tutorials that quickly take the reader through the basic structure, using comments, void setup/void loop, ending lines with semi-colons and all those things that will trip them up before they've even started etc etc.

Then, where is the best place to go to learn about programming, it's self?

Any thoughts would be very welcome, I'm sure.

Link to comment
Share on other sites

Advert


Hi Chris,

with my work, I decided our company needed to understand Arduino/ Internet of Things and all the other 'stuff'. I bought an Arduino MKR 'kit' which included lots of bits and pieces, went to the arduino website, and followed a few projects. The first one took me ages, but then I started to understand what it was all about.

I created various projects that were work related. Such as scrolling messages on an LCD screen that changed when switches were pushed and triggered indicator lights (My company manufactured the switches and lights).

I recommend 'playing'. Try buying the MKR1000 kit as it has everything you need (even a mini servo!), and then google 'arduino projects' to get an idea on what the collective genii in the world are imagining. when your kit arrives, follow the basic instructions and try out the basic projects they give you.

It's surprisingly easy. If I could do it, anyone can!

Graham

Link to comment
Share on other sites

Whilst I can read - and tweak, when required - both Arduino code and "C", I would hesitate to write either from scratch!

I was taught programming on an IBM mainframe, running Fortran and a DEC PDP-8 running Focal. Neither of these helped me very much when I started playing with early computers like the UK101 or BBC "B"! I did get quite proficient at 8-bit machine code, but modern programming languages seem to work in a whole different way!

No doubt I could do it if I put my mind to it, with a lot of studying. My problem is that it is something I would only use occasionally, and by the time I wanted it again, I would have forgotten what I did the last time!

I know enough to get by, and that keeps me occupied and content! wink

It certainly helps to learn something like Basic. It may not be directly applicable to something like an Arduino, but it does teach you the importance of logical thinking and planning, and is relatively easy to debug!

Once you can get your head around Basic - or a similar interpreted language - then working with compiled languages becomes easier. At least your brain is partially tuned to the right wavelength....!

smiley

--

Pete

Link to comment
Share on other sites

Hi Chris,

I'm very new to the Model flying forums and relatively new to Arduino and have completed various projects including scrolling Max7219 Matrix's and various types of Word clocks some using Real Time Clocks and NTP time with Wemos D1's etc etc, i'm now working on projects with stepper motors and servo's, the servo project is using EasyVR3 and an Arduino uno.

I struggled initially due to not having the correct Libraries or the correct version of the ide where a sketch was initially compiled and also if there are tabs with the sketch at times they don't all come in with the sketch, i found this was due to the fact that the file heading must be exactly the same as the zipped master, say if you renamed the un-zippped sketch as something else, the tabs wont come with the sketch, sounds so simple but very frustrating at the time.

My reference book to start learning Arduino was "Beginning C for Arduino", Second Edition by Jack Purdum it has some good pointers but on the whole this guy is talking a different language to me and iv'e struggled to get my head round it i guess i must be a more Arduino for Dummies type of person.

Initially what with the Hello World and a blinking LED i nearly didn't pursue Arduino any further, i'm glad i did.

Are there any scenarios within model flying where Arduino could be useful? i know you yourself have Arduino projects like the Servo Exerciser and Watt meter, i know Arduino is pretty useful in the Model Railway setups as well.

Kev

Link to comment
Share on other sites

I don't do it....

For other things in coding, it is sometimes good to start from something that already exists and make the changes that you want.

I recall an incident where an Arduino bug in a big multicopter caused significant bodily damage.

Link to comment
Share on other sites

I started in the early 70s on what I thought was an ICL PDP10 using Basic as an introduction to computer programming.

In the early 90s this came useful when working on desktop computers Intel 8080 8 bit chips if I remember correctly also dabbled with machine code in the absence of suitable compilers and Interactive Development Environments.

Next came the microcontroller with IDE and compilers still used basic though.

Today Basic is old hat and any form of C will be useful in the future.

I had to switch to C# when I was using Visual Studio to create Web Sites. I also programmed touch screen PLCs.

Learn C in some form, find a project that is of interest to you and go from there.

And never give up.

You never know where it will lead.

Steve

Link to comment
Share on other sites

  • 2 weeks later...

I have to agree with Kevin re "Beginning C for Arduino" was a bit hard going. Ive found the best education has been having a specific task to achieve and searching the web for examples or similar functionality and tweaking them until it does what you want. My first arduino project was an altimeter about 18 months ago (i posted it in this forum) and now at work im using arduinos for a variety of tasks, one of which has 40 arduinos talking to each other simulating a power station milling systems instrumentation.

20200205_215648.jpg

Modelling wise I am also developing a cockpit display for a jet project 25mmx25mm, again adapted from a totally different example found on the net (pilots please excuse any errors in its readings as there is artistic license in play!) I can see it wouldnt be that difficult to have a display that actually worked using various sensors (but lifes too short)!

unknown.jpg

At work i am now circuit boards using the ATmega328 chip directly but using arduino C to program them. This sub board (hand soldered prototype in picture) replaces 2 ics that are no longer available in one of our products. The key thing again was having an idea and end result to aim for and searching the web. I still find myself grabbing hold of the blink sketch from time to time (Blink is example 1 in the examples). Stick with it as its a fascinating subject, im glad i did as my job has totally changed as a result. I have never written a sketch from scratch by the way.

20190930_152921.jpg

Link to comment
Share on other sites

I did initially learn how to program in Arduino from the Arduino website. Most if not all of the information is there, but I have to say navigating to the core tutorial(s) is a bit hard. Probably the best way to start is to upload the ubiquitous "Blink"-sketch and start HERE to learn how it functions. You can then work your way up with the Reference Page to learn about all other functions, variables and structures.

But the main ingredient is and will always be perseverance. You have to enjoy creating stuff in Arduino, do not see it just as a quick way to create a custom piece of electronics to suit your immediate need. And you have to do it often to stay in form, but even then you have to refer to quite basic things now and then (I know I do). In that respect it is the same as designing stuff in 3D cad (one of my other hobbies).

I never felt the need to learn any C-language, my only background is a bit of Basic in the distant past (for my MSX computer). But you have to have a mind for structuring a program, with all the (nested) decision and looping functions. It is not impossible to create that structure in Arduino from scratch, but it often helps to work out the process in a block diagram.

I have to add that I am in no way an expert, my creative work in arduino is pretty basic. And I often use other people's creations to learn from and customize it to suit my preferences. HERE is a nice forum, with an arduino-oriënted section that I visit frequently. A lot of these projects are way over my head in complexity, but there are some that I copied and customized successfully.

Max.

Edited By Max Z on 26/07/2020 10:36:32

Link to comment
Share on other sites

I have a few available, see **LINK**:

ServoReverser: allows a servo signal to be reversed, and/or to be slowed down.

SPortToHub: poll SPort sensors and output hub protocol.

SbusToPpm: 16 channel SBUS decoder.

APM_Mavlink_to_FrSky: Convert Mavlink telemetry to FrSky, either SPort or Hub protocol.

Note that most of these override standard Arduino libraries so I may have accurate control of timing.

Mike

Link to comment
Share on other sites

Other uses for hardware/software in our sport.

1. Arduino used to make a 2.4Ghz version of an old time reed Tx.

2. Same for single channel units.

3. I used a PIC micro to operate cargo doors and paratroopers on the TN A400 using only one channel.

4. Same for servo reverse and servo slows. I know you can buy such devices but making your own is more fun.

Once you acquire such programming skills the projects you come up with will surprise you. I regard it as just another part of our sport.

Nik

Link to comment
Share on other sites

Posted by Bob Burton on 29/07/2020 14:13:42:

Plenty of help available on the Arduino forum of which I am a moderator (UKHeliBob)

forum.arduino.cc is quite the least friendly forum I have ever used. In fact I'd go further than that, a lot of responders are aggressively dismissive. Pick any topic at random and you'll see. Really discouraging for beginners who at best get an 'RTFM' and are dismissed as an inconvenience.

Cheers
Phil

Link to comment
Share on other sites

Posted by Phil Green on 29/07/2020 23:36:02:
Posted by Bob Burton on 29/07/2020 14:13:42:

Plenty of help available on the Arduino forum of which I am a moderator (UKHeliBob)

forum.arduino.cc is quite the least friendly forum I have ever used. In fact I'd go further than that, a lot of responders are aggressively dismissive. Pick any topic at random and you'll see. Really discouraging for beginners who at best get an 'RTFM' and are dismissed as an inconvenience.

Cheers
Phil

That really is not my experience. Long term members of the forum do get annoyed when people do not read the sticky topics on how to post programming questions, which results in code being posted in italics (if it is posted at all) and no details being given of the hardware being used. That certainly leads to advice to read the sticky topics but unless questions and code are posted properly then it is very difficult to provide help

The equivalent here would be a post saying "I have problem with my transmitter. Can you help me ?"

Advice, including writing code, is freely available on the forum but members are expected to do some work for themselves. It is not unknown, for instance, for school, and even University assignments to be posted in full in the expectation that someone will write the code for them.

If anyone here has any Arduino based questions please feel free to ask them here or via PM and I will do my best to help. I would be interested to know how many members here are also members of the Arduino forum

Link to comment
Share on other sites

I could post examples, some responders are downright rude, arrogant and dismissive but reading between the lines I gather that you're 'politely aware' of that Bob. As a well established enthusiast (and a microelectronics teacher) I found their treatment of beginners (some only kids) was appalling and so I avoid it - unless its improved over the last few years.

Cheers
Phil

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...