Total Newbie Just Need a Push in The Right Direction

Status
Not open for further replies.

I just recently discovered #define and I use it quite a lot myself now. Makes it so that I can write my code and name the port I/O lines based on what load they're driving or what is driving the pin, which helps me to remember what's connected to each pin.
 
Last edited:
Should have said that the #define and ifdef is an MPASM directive and not to be confused with mnemonics.

Aside from the better readability of using #define for port pins and/or pin values, they are useful in making procedures and functions more versatile. Say for instance, you have an RGB led, or 7seg display routine set up for common anode. It is easy to expand those routines for common cathode, simply by using the #define, ifdef, or ifndef.

Code:
#define ComCathode
...
...
...
	If red_duty > duty then
		#ifdef ComCathode
			red = 1
		else
			red = 0
		#endif
	else
		#ifdef ComCathode
			red = 0	
		else
			red = 1
		#endif
	end if
 

And that's where you start getting into C, which I don't yet understand nor do I know where to start with it lol.

I find it interesting that some people find it more difficult to comprehend assembly than C, but to me for some reason assembly language/syntax actually makes more sense than C does. Probably cause I'm just not yet familiar with C constructs and syntax.
 
That's not really C it's more like basic but there are ( if thens in C) But we better watch where going to confuse the OP

Here with a bunch of stuff he don't need to know right now. We should keep it simple .

Them if then else endif stuff will compile even if it's wrong

Let's get him reading buttons and switching port pins first before we try to turn him into us.
Let him find himself with this or there will be more post then need to be.
 

Well to each their own, the syntax of Basic seems to have stuck for me.

O.K. I'm out on this discussion.
 
Funnily enough I've actually done a bit of C programming at uni, if you need a program to solve certain types of equations or rotate a cube, im your man. I've actually done a bit of assembly as well on a TI DSP board, but the commands are written a bit differently, i think that's what has confused me, along with the fact you don't really need to specify any configurations just include a stdio.h file. Anyway, i've just managed to write the program I need for my project and it seems to be working fine, just need a few adjustments to do with timing, but that's no bother.

My brother just showed me this, Programmers Notepad, which I found quite handy as it highlights commands etc in different colours and provides line numbers for easier error correction, seems to support various different languages too - Programmer's Notepad

Anyway, thanks again everyone that helped, im sure this won't be the last time you hear from me.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…