Jump to content

How can you add or subract value from a variable???

Recommended Posts

Can anyone explain why the long variable 'frequency' will not change based on pin status?  (loop function)  I know I must be doing something wrong but I can't seem to figure it out.  The program as written works.  I type in for example 7000000 and the DDS programs to 7.0 Mhz.  If a pin is pulled low I want to add or subtract 1500.  But that part does not work.  It always sets the DDS to the input frequency.  I've added print statements to verify what is happening and I know the program is detecting pin state OK. so something is wrong with my logic for adding or subtracting.



file attached:


Link to post
Share on other sites

In C, assignment is =. == is for comparisons.


Also, the ; completes the if clause (unless you start a block with curly brackets). A few of your ifs won't do what you expect.


And instead of goto, open curly brackets and close them in place of the loop1 label.


Spending an hour with a C primer might save you a lot of time down the road. E.g. chapter 3 of this e-book http://www.lakos.fs.uni-lj.si/images/Predmeti/MK/2014/C%20Programming%20for%20Arduino.pdf

Link to post
Share on other sites

Thanks, I'll do that.

Update,  I just removed two ; and two= and the program runs as expected.  I just now need to enhance a couple of things and it is done.


Thanks for your help, you pointed me in the right direction, and that tutorial is great, much better than the C programming text book I have.

Now,, on to a visual basic program for the PC end of this.

Link to post
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.

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.

  • Create New...