Arduino ....Software error.... - Page 1
Forum section: electronics / projects

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: April 25, 2013, 05:50:03 pm
content: When i bought my Atmega 2560 i was a total noob in the arduino wolrd but everything i made (basic little things) i have learned a lot .But i was always running into the same problem .... Software.... i have this part of the arduino because its easy and good at the beginning but ass you go deeper into the microcontoller and the modules it becomes a pain in the butt.So i need a website to help me learn arduino programming (Not Any C of Java ones because i need it for arduino and i also have C and C++ Books) with simple projects that are getting harder as you progress also google is not my best friend always.... because my mistakes are so bad or wierd that when i google them i can not find a thing.But there is a good side in this which is all the obstacles i have passed during this time.I love this thing and want to make some things out of it but i do not have the knowledge.So please help me if possible.Thank you.

author: Len
author_rank: Frequent Contributor
timestamp: April 25, 2013, 05:57:01 pm
content: Here are a couple of step-by-step Arduino programming tutorials:http://arduino.cc/en/Tutorial/Foundations(the official Arduino site)http://learn.adafruit.com/lesson-0-getting-started/the-lessons

author: richcj10
author_rank: Unknown
timestamp: April 25, 2013, 08:18:11 pm
content: Post the problem software. That is the best way to learn.

author: Strada916
author_rank: Frequent Contributor
timestamp: April 25, 2013, 08:20:47 pm
content: even better post the code and a screen shot of the error. or Photo of the error.

author: richcj10
author_rank: Unknown
timestamp: April 25, 2013, 08:46:57 pm
content: Quote from: Strada916 on April 25, 2013, 08:20:47 pm^^ that too!

author: IanJ
author_rank: Unknown
timestamp: April 25, 2013, 08:50:54 pm
content: Hi,For beginners the Arduino tutorials/reference pages over at arduino.cc are pretty good.http://arduino.cc/en/Tutorial/HomePagehttp://arduino.cc/en/Reference/HomePageThe reference pages in particular give you plenty examples on how to use functions, variables etc.The best way to learn is to actually set yourself a goal/project and keep at it until you get it working...........even something as simple as lighting up say 8 led's one after another and controlling the speed with a pot......and then displaying the speed on an LCD.Ian.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: April 26, 2013, 09:43:37 am
content: Quote from: richcj10 on April 25, 2013, 08:18:11 pmI am sorry but the thing is not the problem iin this exact code but generally learning about arduino programming.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: April 26, 2013, 09:46:33 am
content: Quote from: IanJ on April 25, 2013, 08:50:54 pmThanks but another thing that i cant understand is the for loopi am confused by its stracture.Code:// for exampleint val =0;for(val = 0; val++);// here i do not declare a variable at the for loop section but at the beggining but the thing i dont get is the third section// the val++ thing ... i dont get the possibilities of the third part

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: April 26, 2013, 09:47:43 am
content: Quote from: Len on April 25, 2013, 05:57:01 pmThanks for the pages and specially for the adafruit site... i did not know that adafruit had an arduino tutorial.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: April 26, 2013, 09:48:36 am
content: Also another thing about the code is that i dont have the code anymore.... i lost it ...

author: notsob
author_rank: Frequent Contributor
timestamp: April 26, 2013, 09:58:31 am
content: Real men don't make backups.

author: Psi
author_rank: Super Contributor
timestamp: April 26, 2013, 10:28:05 am
content: Quote from: ChrisGreece52 on April 26, 2013, 09:46:33 amYou're missing the condition for the loop, val < 5 for exampleSo lets add that in.Code:int val =0;for(val = 0 ; val < 5 ; val++ );{}<variablename>++ is just a fancy/shorthand C way of writing val = val + 1You're telling the loop what to do with the val variable every time around the loop.If you wish you can write the for statement like for(val = 0 ; val < 5 ; val = val + 1 );In 99% of cases you'll want the loop to either count up or down by 1.However, if you wanted the loop to count up in lots of 2 you could have it like thisCode:int val =0;for(val = 0 ; val < 5 ; val = val + 2 );{}In reality you can put whatever code you want there and do all sorts of complex loops that jump up in multiples or in complex patterns.

author: Strada916
author_rank: Frequent Contributor
timestamp: April 26, 2013, 10:28:27 am
content: // for exampleint val =0;Declare val as an integer and make its value 0for(val = 0; val++);++val means to increment val every time the for loop is looped// here i do not declare a variable at the for loop section but at the beggining but the thing i dont get is the third section// the val++ thing ... i dont get the possibilities of the third partThere is a lot of tuts discussing this and many more code variables on the net. ardunio have a tut section as well as many forums and site like adafruit.look at this page it discusses for() function in detail.http://arduino.cc/en/Reference/Foryou are missing a third element in the for loop, the test condition. see above web page

author: Psi
author_rank: Super Contributor
timestamp: April 26, 2013, 10:33:00 am
content: Quote from: Strada916 on April 26, 2013, 10:28:27 amval++ and ++val are differentIt's been a while since i've used ++val in code but i think it does the incrementbeforeprocessing the current statement. (an important distinction if the statement does multiple things)

author: BravoV
author_rank: Super Contributor
timestamp: April 26, 2013, 10:41:26 am
content: Your problem is like you have not able to crawl properly, but want to jump like an athlete does.Get the basic right starting by learning the basic syntax and understand how to use it properly first before anything else.Your current skill and knowledge is way too low that even to start from the scratch like a simple project like blinking a led is almost impossible, unless you copy & paste other people code.

author: Strada916
author_rank: Frequent Contributor
timestamp: April 26, 2013, 10:43:41 am
content: Quote from: Psi on April 26, 2013, 10:33:00 amwoops yes they are should have been "val++"DescriptionIncrement or decrement a variableSyntaxx++; // increment x by one and returns the old value of x++x; // increment x by one and returns the new value of xx-- ; // decrement x by one and returns the old value of x--x ; // decrement x by one and returns the new value of xHere is the full page about inc/dec values. [urlhttp://arduino.cc/en/Reference/Increment]

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: April 26, 2013, 10:47:47 pm
content: Quote from: Psi on April 26, 2013, 10:28:05 amThanks now the fog is a lot thinner

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: April 26, 2013, 10:51:48 pm
content: Quote from: Strada916 on April 26, 2013, 10:28:27 amThanks about the clarification also on the arduino.cc in tutorials it says that the for(int val = 0;val < 5; val++)is optional

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: April 26, 2013, 10:56:10 pm
content: Quote from: BravoV on April 26, 2013, 10:41:26 amI am sorry but i think that with a bit or reading basic tutorials about the microcontroller you can get into C++ and programm the arduino easily.Also i learned from others : i got the code ready for the things i needed then i read the code so i can learn from it , i f i did not get one part i was searching about the part or messing with the vallues and then as a last step i was trying to replicate the code from scratch with the goal i had in my head.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: April 26, 2013, 10:59:36 pm
content: Also i made an error that i understood just now.Declaring the variable is optionalNOT the initialization of the variable.!!!

author: TerminalJack505
author_rank: Super Contributor
timestamp: April 26, 2013, 11:00:41 pm
content: There's a subtle problem with yourforloop.You probably don't mean to say:Code:for(val = 0 ; val < 5 ; val++ );{}But, instead likely mean this:Code:for(val = 0 ; val < 5 ; val++ ){/* This code is executed 5 times. */}Notice how the semicolon is missing from the end of the line in the second case.The semicolon in the first case will be interpreted by the compiler as follows:Code:for(val = 0 ; val < 5 ; val++ ); /* This is a null statement. In other words, do nothing 5 times. */{ /* This is a block of code. But this code is not associated with the for statement. *//* It will execute just once. */}

author: Strada916
author_rank: Frequent Contributor
timestamp: April 26, 2013, 11:03:43 pm
content: Quote from: ChrisGreece52 on April 26, 2013, 10:51:48 pmyes that is true.I have one word for you. Google.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: April 26, 2013, 11:03:57 pm
content: thank you had not noticed.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: April 26, 2013, 11:05:35 pm
content: Quote from: Strada916 on April 26, 2013, 11:03:43 pmyeah but google does not always cover you

author: richcj10
author_rank: Unknown
timestamp: April 30, 2013, 02:36:12 am
content: You really should just pick a off the wall project to do it to learn C/arduino/whatever. That really this best way. When I started, I did a RFID door lock system. It took me 3-4 months to get it right. It is like riding a bike, do you learn by reading a book or just getting on the bike?

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: April 30, 2013, 10:05:15 am
content: Quote from: richcj10 on April 30, 2013, 02:36:12 amYou are so right!!! I did not think it like this .... and reading books and learning C thought that was the way to go.... but you are right.I was always thinking a projects with motors and servos.... and why not some I^2C communication.... ill do a reasearch and start the project.THANK YOU

author: Rerouter
author_rank: Super Contributor
timestamp: May 01, 2013, 08:26:57 am
content: also have to agree, its far easier to learn a programming language by jumping in and assigning some random task than sitting down reading the text books and still failing to understand how to apply what you have learned,my own recent project has greatly expanded my understanding of C and AVR micro's, for instance bitSet and bitClear are seriously faster than digitalWrite, but far less portable to other chips and platforms, and the existing lcd library disables interrupts, and a ton of other small tidbits that can catch people out, and in general speed loops up

author: Psi
author_rank: Super Contributor
timestamp: May 01, 2013, 08:44:00 am
content: Quote from: TerminalJack505 on April 26, 2013, 11:00:41 pmNice spotting.That will teach me for copying and pasting code.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: May 01, 2013, 12:40:21 pm
content: Ill post any problem i run into with the code here so i can learn from my mistakesand now i remembered a terrible mistake i made and could not understad the mistake i madeCode:if (value>120)[color=red];{"do something"}else{"do something else"}and kept getting the error : else without a previous if ......

author: jancumps
author_rank: Unknown
timestamp: May 01, 2013, 01:06:25 pm
content: Drop the smicolon in the first line.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: May 01, 2013, 09:41:44 pm
content: Thanks but this occured a while ago i was just reffering to it as an example.