I'm building a propeller clock, for this i want to add into my code (once i have it ) a function that receives an argument (A-Z or 0-9) and send the data through PORTB.
Example:
Code:
SYMB(C); //Where SYMB is my function or subroutine
SYMB(C);
SYMB(S);
------------------
char SYMB(){
switch SYMB
case C:
PORTB=XXX;
break;
case s:
PORTB=XXX;
break;
}
Or something like this
Any ideas?
newguy
Joined: 24 Jun 2004 Posts: 1911
Posted: Sat Mar 26, 2016 1:14 pm
Almost.
Code:
void SYMB(char c) {
switch (c):
case 'C':
...do something
break;
case 's':
...do something else
break;
}
Ttelmah
Joined: 11 Mar 2010 Posts: 19561
Posted: Sat Mar 26, 2016 1:20 pm
Code:
void symb(char val)
{ //you were saying that the function returned a character
//not that it accepted a character
switch (val)
{
case 'C': //This is the character 'C'
output_b(xxxx);
break;
case 's': //The character 's'
output_b(yyyy);
break;
}
}
Generally in C, use the standard that ALL CAPITALS is a #define.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum