Author Topic: New at Programming...need help  (Read 2117 times)

0 Members and 1 Guest are viewing this topic.

Offline dwb4629Topic starter

  • Beginner
  • *
  • Posts: 5
  • Helpful? 0
New at Programming...need help
« on: December 01, 2008, 07:51:03 PM »

so heres yet another $50 robot question.  i'm done building and i've programmed (sucessfully) everything.  the thing is, is that it doesn't behave properly, more specificaly it really just goes in a straight line with no signs of the the photovoreness it should have.  i found from a previuos forum post that those behaviors are relatively normal the first time you turn on your robot and it was recommended that i test everything thoroughly, including writing little test codes for each component. and i've done all the testing except the code writing part.

this is where my troubles begin.

luckily i found this forum post that had a bunch of test codes already written out:

the problem is i'm not sure how to put this into avr studio to make it work. (also i should now say that i am indeed using the avrisp mkll) what i've tried is starting a new project and copying and pasting the code from the forum post and i get the following error:

../servo_test.c:2: error: expected identifier or '(' before 'while'

this means little to me.  i've been to numerous learn c websites hoping to figure out what to do and i've found nothing, at least what i could comprehend.  so while doing some sweet spacing out at work today, i came up with some theories... i'm guessing that a header file is needed.  if it is, should i start out the code:  #include "headerfile here" but obviously with the header file in the " ". Or is adding the header file the same way as is in the $50 tutorial sufficient?  and what about this makefile?  is that always important? can i use the one from the $50 robot?  and do i add it the same way?  so i came home and tried it out, but with no luck and a ton off errors and warnings and honestly, not much surprise from myself.  if that information is important i can take a screen shot and post it. 

i hope i'm not being to vague, if needed i bet i could clarify on specifics.  if someone can make sense of this and help me out you'll be my freakin hero.
thanks in advance.  you rule!

Offline cosminprund

  • Robot Overlord
  • ****
  • Posts: 284
  • Helpful? 8
Re: New at Programming...need help
« Reply #1 on: December 02, 2008, 03:30:31 AM »
You get that error because you are copy-pasting an code snippet into the "c" file. That is, the code snippet is not an full program. The compiler tries to be helpful but it fails :)
It would be easier if you'd simply use an existing, known-to-compile code base. Considering the project I guess the best code base would be the "photovore" code base itself! Read throw the "photovore_v1.c" file and you'll find the "main" function. That's where the code snippet goes, pay attention to the "****" comments.


Get Your Ad Here