So confused where to start!

Hello guys, I am sure your all going to grumble when you hear the same tired old line. " I'm new to arduino and need some help" Well your right to be like daaaaaaaaaaang.. I am a little different though, I am in my mid 30s and not some noob kid begging for help.. I have dealt with discrete electronics and components for years. I have built multiple projects large and small. I always wanted to program IC's but never took the time to go that far into electronics.. I own my own business which is machine and die shop. I work with CNC and manual machines daily. I make everything from elevator parts to race car trans valve bodies. I hold a degree in business and several certifications.

So the ability to learn and learn quickly comes natural..

The problem I am having is where in the same hell does one even REALLY start with arduino.. I mean sure if you wanna just copy a sketch and see lights blink but not really know what the code is and how it works. I have read tutorial after tutorial. I have purchased a couple downloads and they all seem to be copies just worded a little different..

Thing is they all want to tell you what to do but NOT how it actually works. I need to know how and why. I don't want to just go copy a sketch and hit go.. I want to know how and why the code does what it does.. I read its C mixed with C++ well which is it.. I sure can't learn both!! Both of these languages are dated but it takes months if not years to get fluent with true coding.. Most likely a few college classes to even get going. Even if I do then all of what I learn will be relevant to programming IC's.. It just all at the point seems daunting..

Am I looking at being at the mercy of libraries or previous sketches?

Is it that we all have to be at the mercy of guys that have coded for years and give us libraries and sketches to edit?

Can one ACTUALLY learn to program the arduino and like controllers without going full hog into coding??
I am getting the feeling that with arduino there is MUCH of c or c++ that just wouldn't be used often and maybe not relevant to sketching. I have no idea but this where I would love to have some guidance.. I have NOOOOO clue.. I would love to know where to get started.. I have read these books and tutorials but after a few examples it leaves A TON in question as to why and how.. Sure I could just learn what does what and make a few things of my own but then I really wouldn't know the grits of what the code is and why it does what it does and so forth..

I think you all get what I am saying.. I am lost please help. I am really interested in using this technology so any guidance at all is MOST appreciated!!

Tester!!

Here's my suggestion:

Get the basics in place. Understand the structure of setup() and loop(), variables, conditional and looping statements. More advanced topics like arrays, pointers, structures/classes,etc can come when you need them.

Then understand simple things like how to read and write digital/analog values, how to not use delay(), running an LCD, etc. Simple building blocks.

Then pick a project you want to do and do it. Nothing like trying basic skills on a project to knit that knowledge together. Specific questions on this forum will get you through some of the harder patches (we all go through those) or give you pointers to better ways of implementing.

Looking at the way other people solve problems (ie, reading their code) is a good way to learn PROVIDED that it is written well. There is a lot of crappy code in Arduino-land that is best not to copy and in time you will learn to discriminate.

This is an exciting and very interesting topic to learn. Go for it!

First off, how does this jive? oldschoolHUtester = I am in my mid 30s :wink:

Both Adafuit and Sparkfun have good tutorials in hardware and software.

Get this book, it is income tax deductible :wink: .

Look at Robin2's discussions found on this site, example:
http://forum.arduino.cc/index.php?topic=223286.0

Read through these:

Keep these discussions in your back pocket:

Master all the example sketches that come with the IDE.

NB! Master the BWD Blink Without Delay sketch which is used to replace the delay() function.

Help out others on this forum.

Have fun.

.

Also, study these:

.

oldschoolHUtester:
Thing is they all want to tell you what to do but NOT how it actually works. I need to know how and why. I don't want to just go copy a sketch and hit go.. I want to know how and why the code does what it does.

I wonder if you are expecting it to be more complex than it really is. I suspect you will understand this

byte countVariable; // define a variable that can hold any value from 0-255

void setup() {
  Serial.begin(9600);
  Serial.println("Hello from Arduino");
}

void loop() {
    Serial.println(countVariable);
    countVariable = countVariable + 1; // can also be written as countVariable ++;
    delay(500);
}

Just take some of the examples that come with the Arduino IDE and study them carefully. Look up stuff in the Reference section of the Forum and if you are still stuck ask a specific question here - such as "what does this line do?"

Maybe have a look at Planning and Implementing a Program. However it was not written for a complete beginner.

...R
Edited to add the missing opening { after loop()

void loop()
    Serial.println(countVariable);
    countVariable = countVariable + 1; // can also be written as countVariable ++;
    delay(500);
}

Whoops !

UKHeliBob:

void loop()

Serial.println(countVariable);
   countVariable = countVariable + 1; // can also be written as countVariable ++;
   delay(500);
}



Whoops !

Sorry - my brain is blind - what did I get wrong? (so I can correct it)

...R
PS. I don't object to the "whoops" as I make mistakes all the time. But it is not helpful for the OP.

Opening brace?

I don't object to the "whoops" as I make mistakes all the time

and I know that you know better !

The opening brace of the loop() function is messing,
It should be

byte countVariable; // define a variable that can hold any value from 0-255

void setup()
{
  Serial.begin(9600);
  Serial.println("Hello from Arduino");
}

void loop()
{
  Serial.println(countVariable);
  countVariable = countVariable + 1; // can also be written as countVariable ++;
  delay(500);
}

oldschoolHUtester:
The problem I am having is where in the same hell does one even REALLY start with arduino.. I mean sure if you wanna just copy a sketch and see lights blink but not really know what the code is and how it works. I have read tutorial after tutorial. I have purchased a couple downloads and they all seem to be copies just worded a little different..

Thing is they all want to tell you what to do but NOT how it actually works. I need to know how and why. I don't want to just go copy a sketch and hit go.. I want to know how and why the code does what it does.. I read its C mixed with C++ well which is it.. I sure can't learn both!! Both of these languages are dated but it takes months if not years to get fluent with true coding.. Most likely a few college classes to even get going. Even if I do then all of what I learn will be relevant to programming IC's.. It just all at the point seems daunting..

I'm guessing what you need is to know what goes on inside the chip. Let me first state that the Arduino (and other similar "hobby boards") are MICROCONTROLLERS.

Think of it this way... inside your PC you have a MICROPROCESSOR which does all kinds of calculations and comparisons and controls all the things connected to it (such as the hard drive, the video display, the memory, etc...).

The MICROPROCESSOR is like a bare brain, connected to body parts.

The Arduino MICROCONTROLLER is like a brain with a built in BODY. Not only can it calculate and compare numbers, it can also be connected to external devices to turn them on or off, to read in data (such as a temperature sensor or a tachometer, etc..).

Now, to explain programming and "machine language", let's try this: Think of YOURSELF as a microcontroller. You have a brain and a body, you can carry out instructions given to you. Now, imagine that I am the programmer and I want to program you to obtain a cart, then travel to a location, pick up some bricks, then deposit them at a new locations.

To save space (memory), I will make up simple codes to represent different objects and actions. For example, "Cart" will simply be the letter C. Brick will be B, go to a certain location and deposit the bricks will be D and your arms will be R and a piece of paper to hold your notes will be P.

To start, you (the microcontroller) always begin at the same place (the basement of the building). Whenever I first turn on your power (i.e. POWER ON RESET), I know you will be in the basement (that is your RESET VECTOR).

So, look at this program:

(address 0 is the basement)
LOAD R WITH C // get the cart
P = 100 // write "100" on your paper
loop
GOTO bricklocation // go to where the bricks are
LOAD C WITH B // place one brick in the cart
GOTO 0 // take the cart with the brick to the basement
D // deposit brick
P = P - 1 // subtract 1 from your notes (now it's 99)
IS P = 0? // are you done yet?
NO: GOTO loop // you have more to do!
YES: END // you're done, take a break!

Make sense so far? OK, well the microcontroller does not understand letters... it only understands numbers. What you see above is SOURCE CODE that needs to be COMPILED into raw numeric machine code. A compiler or assembler does this.

In Arduino, when you write a sketch, you generate SOURCE CODE such as above. When you compile it, it becomes raw numeric machine code that you upload into the Arduino board (using the USB cable and bootloader). The numbers go into Arduino memory, the chip starts at 0 (the reset vector) and begins running the code, step by step.

Now, let's compile your program into machine code. Let's assign numbers to each of our functions:
B = 10, C = 20, GOTO = 30, D = 40, R = 50, P = 60, COMPARE = 70

Now look how the compiled code would be inside the chip (the first 4 numbers are the memory address inside the chip)

0000 50
0001 20 // load R with C

0002 60
0003 01
0004 00 // load P with 01 00 (100)

0005 30
0006 brick
0007 location // go where the bricks are

0008 20
0009 00
000A 01 // load the cart with 1 brick

000B 30
000C 00
000D 00 // goto 00 00 (0000) the basement

000E 40 // deposit brick

000F 60
0010 FF
0011 FF // subtract 1 from P (FFFF is -1)

0012 70
0013 00
0014 00 // compare P to 0 (is it zero?)

0015 30
0016 00
0017 05 // not zero, jump back up to location 0005 (loop)

Obviously, when the program ends, you will have moved 100 bricks from where they were to the basement.

Notice that the addresses count in HEXADECIMAL. Instead of 0 through 9, we count 0 through 15. To represent the extra 5 "digits", we use letters A through F. After F, it loops back to 0. Example:

00 (0)
01 (1)
02 (2)
....
08 (8)
09 (9)
0A (10)
0B (11)
....
0E (14)
0F (15)
10 (16)
11 (17)
.......

Make sense?

Try to digest all this stuff, then come back to me with your questions. You'll learn this in no time!

marco_c:
Opening brace?

Thanks. I have corrected Reply #4

...R

Thank you guys for your responses! Krupski's way of explanation was exactly the in depth approach I learn from.. However it did help and aswered a lot of questions right off the bat I don't think I wanna get down to hex or binary just yet..

It's been a loooong time since I have tossed around the idea of coding or learning to code.. I guess I have to admit that I have forgotten a lot or just plain don't know it.. The posts above made a lot of things clear..

Lets see if I have it right.

The IDE takes the code reads compiles it in HEX and then sends it to the chip?? Correct.

It was said that the IDE or compiler is setup for the arduino to interpret C.

I have been rereading some old books and new ones as well on C and it is all falling in place. However some of the coding examples don't match or seem to cross over?? Will all of C be compatible with arduino?

Does arduino have all its own keyword/tokens that must be learned??

Again is all of C compatible?? Or are there a set of libraries, keywords, functions etc I am allowed to used with arduino that it will understand and be useful or compatible for its use??

Slightly different perspective. First of all, you can't be Old School since I learned C in college only a year or two after YOU were born. Otherwise I'm Older than Dirt School :slight_smile:

Second, if you're going to do anything useful with Arduino beyond copying examples and hacking at them, you'll need to learn C. It may be "dated", but it's compact and efficient on resource-limited processors. Sure, you can write tighter, more efficient code in assembly language but the effort and required attention to minutia goes up tremendously. Save C++ for later, but learn C.

Being genuinely Old School, I'd recommend Kernighan and Ritchie:

It's a short book. Work it cover to cover. 95% of the basic language concepts covered in the book (functions, variables, loops, conditionals, scope, pointers, structures, unions, etc) are applicable to Arduino. A few things around the periphery will change -- replace printf() with Serial.print(), main() with setup() and loop(), FILE type, etc. But, you can easily see those in the Arduino examples.

In short, I'd advise you to learn the language. After that, all the cool things you can do with Arduino will fall into place. There are pre-written libraries that handle the grunt work for all kinds of amazing functions -- WiFi connection, RF links, servo control, Web Servers, LCD displays, LED strings, etc. These allow you to concentrate on your specific application.

Thank you VERY much gfvalvo that answered my questions.. With all the "HYPE" around the arduino it makes one think its an easy programmable dummy proof piece of hardware.. My suspicions were confirmed that if you don't want to hack away at someone else's sketch then ya just have to learn the coding side of it for yourself.. I think this should be made more upfront aware to noobs such as myself.. Sure I can do stuff with copy and paste but who wants that???

LOL its good to know that at the age of 37 I'm not alone at being "OLD" LOL.. Now I know someone trumps me.. Usually it's young folks surrounding this type of stuff. After all us old folks usually have jobs, businesses, a wife, house and kids to tend to so taking up another hobby or profession that is this time consuming isn't an easy option.. I guess were the exception not the rule!

OldschoolHUtester screen name came to me from another group I participated in when I was in my mid 20's.. This dabbling so happen to be attributed to smart card programming.. In that world a month out of the loop was oldschool.. I got the nickname because I took a leave from the scene for a spell and when I came back I was still hung up on the HU smart cards that I was testing before I left... I caught hell for this and was flamed into a coma.. LMAO .. I did make a full recovery with honors but soon decided this wasn't for me anymore and moved on.. I still have a deep love for electronics though.. Non the less when I made my full recovery to the scene all my testing buddies gave me the NICK oldschoolHUtester and so it stuck..

Thank you all for your help!

Tester!!

The place to start is in the green bar at the top of your forum page (and every other page of the Arduino site). Click on Learning to get the learning menu and start with Getting Started.

You won't just get guided to and through tutorials, the fundamentals page links you to understanding the hardware (pins) to the level you need.

Want to skip a bunch? If you like to learn the hard way then only learn after you either burn something up (go for smoke!) or just spend HOURS typing, copy-paste-modify block after block only to find out that something basic you blew off could have saved you 90% of that time.

You need to learn the basics of C. Leave C++ for later.

Note that Arduino IDE programming starts you out one step into standard C with setup() and loop() so there's going to be that bit of difference between Arduino and standard C tutorials on the web. It should not be a show stopper especially if you do some of the Tutorial Examples already loaded in your IDE.

I can recommend doing some of the examples in sections 1,2,3 and 5 but not section 4. Section 4 uses C++ Strings that are poorly suited to small memory spaces (like in AVR chips) so what you learn with those you stand a real good chance to have to unlearn then learn the other, original C methods of handling text to get past the limits that those &%$@#! Strings make.

I used to do tool and die in a job shop. That's where I learned PC programming. I started with generating tapes for a turret press and moved on from there. My teachers were need, a book and a PC but I was in my mid 20's then. In 3 years of part time coding, most time shop work (got up to the title of production engineer) and estimating bids I got to where I could move on to full time programming elsewhere. That was in 1983.

Seriously though, there's times when I wish I stayed cutting metal. You can measure the metal. I liked coding to do metal work, nothing wrong with that, it helped the shop a LOT... it was the creeps and ripoffs I did work for elsewhere that gave my some regrets (regret not choking one or three).

  • PLAY with the examples. Only by DOING will you really learn. There is no substitute.
  • Keep a browser window open when you use your IDE. Open a tab to hold every page pertinent to what you're working on. Always have one tab with the Arduino Reference page in it and refer to that page every time you see or use a command/statement that you don't know solid.

The very act of looking up syntax and use will reinforce your memory/learning. If you want to impress any of that more strongly into your neural connections, take notes by hand as you go and be sure to have caffeine on hand (ie cheat fatigue).

When (not if) you do get tired and begin to lose focus at all, take a break and let your head catch up. Do some shop work or something if time is precious. If you have a bug that may be simple like a typo or not and you can't see it, you may be left-brain fixated. Take a break until you're not still chasing the same thought path (it MUST be... dadda dadda dadda) and go back when you have "fresh eyes". Often that's all it takes and boy do those lessons stick!

With Arduino what you load on the chip owns the chip. There is no operating system (except if you write one) to learn. You have to write your own bugs and troubleshoot them so start small and keep changes down to as few at a time as necessary, preferably ONE at a time on a copy of what worked last so you don't lose that (use Save As before adding new change or archive the project folder).

Calipers and mics,
GFS

What I like about the Arduino is that you can get something simple working after just learning a little bit. Seeing my LED flash at the interval I chose was very satisfying.

Some people learn best by working through text books from A to Z. Others learn best by seeing a short finished example and then studying how it works.

Most of the concepts in programming - data, functions, variables, IFs, WHILEs, arrays, etc are universal across all programming languages.

...R

Seeing my LED flash at the interval I chose was very satisfying.

I know what you mean. I thought that everyone modified the Blink sketch as their first programming experience with the Arduino.

One additional comment based on my own experience when I started with Arduinos a year ago or so.
After having learnt the first steps and after you got hungry to eat more Arduino :slight_smile: you will be shooting for more.

Your goals will get more challenging and - no surprise - more complex.

So it was with me after a few months and I wanted to realize a project which was pretty challenging (at least at that time for me and my then knowledge level).

What I had learnt from the beginning was, to start with pieces of code to test one function after the other and then merge the pieces together to get the full cake. But - there is a but.

Sometimes, when you don't pay attention, you bring in new bugs you have never thought of before. And when you forgot to save your previously working code under another name - the new sketch has taken over and killed your working code ...

Unless you are working with a subversioning system like SVN or similar you should pay attention to save your working copies in a safe place and save your new version under a new name (maybe with an increased version number) so you can always step back and have a latest working version befor you try to "imworse" it with the new correction/update or whatever your intention is.

It's like learning to read and write.

You don't have to memorize the dictionary but you do need to learn the alphabet and sentence structure.

With C you don't want to skip the basics. Going through tutorial examples will get you exposed to those with far less pain than trying to do something big and flashy knowing only that int can hold numbers (but not what range of values) and how an if statement works but not the else that can go with it or loops or arrays.

Imagine the kind of woodwork you could produce with only a hammer and flat blade screwdriver. You don't need to know every tool there is to do woodwork but a saw, vise and square almost seem necessary. Save the drill for next, chisel for later, and leave power tools until after you get basic hand tools down.

A good machinist can do wonders with a file, but find one that doesn't consider a vise important. What you are facing isn't "be an expert before anything" but think about who you would let work in your shop and who you would either teach or make learn a few things first.

Starting to learn C for someone who does not know programming is a tough call. I've been teaching C for almost 35 years and wrote my first C book in 1983 when the only C book available was K&R. If you know programming, K&R and ones similar like those by Steele, Feuer, and the like are excellent. However, if you have no programming experience, they are often a horrible choice, especially if you are going to approach it in a self-teach mode.

I would suggest going Amazon and google "Beginning C", "C for beginners", "Introductory C", or something similar that reflects your "starting level" and then read several of the reviews that are published there. That will give you and idea of: 1) the book's content and approach, and 2) some insight into the starting level of the reviewer. You may be able to find a review written by someone who more-or-less squares with your current background. Also, Amazon usually has a "Look Inside" banner that lets you see the Table of Contents. If you've tried to learn C but have a stumbling block (e.g., pointers), see how that topic is presented in the TOC. Amazon also let's you read a few pages, too.

Collectively, these steps should allow you to remove some of the uncertainty when choosing a book.