Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 22:04 07 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : is it possible to name a PIN ?

Author Message
f1fco

Senior Member

Joined: 18/03/2012
Location: France
Posts: 154
Posted: 12:03pm 19 Aug 2014
Copy link to clipboard 
Print this post

hello to all,
a simple question :
if I want to light a led, I use this program :
SETPIN 11,DOUT 'pin 11 is digital output
PIN(11)=1 'the led on pin 11 light !!!

is it possible to give a "symbolic" name to a pin ?
exemple :
led=11
SETPIN led,DOUT
led=1 'or led=high ?

in ARDUINO, I can write : int led = 11;
or also : #define led 11

is it a solution in MMBasic ?

thank you for answer and solution
Pierre
73s de F1FCO
 
Gizmo

Admin Group

Joined: 05/06/2004
Location: Australia
Posts: 5029
Posted: 12:17pm 19 Aug 2014
Copy link to clipboard 
Print this post

You could use a sub.



led 1


sub led(x)
Pin(11)=x
end sub



Bit crude, but would work.



The best time to plant a tree was twenty years ago, the second best time is right now.
JAQ
 
Justplayin

Guru

Joined: 31/01/2014
Location: United States
Posts: 309
Posted: 01:08pm 19 Aug 2014
Copy link to clipboard 
Print this post

Yes, you may use variable names instead of the actual pin number. The following code will blink the power led on a Maximite.

Top:
led = 0 ' pin 0 is the Maximite power LED
Pin(led) = 1 ' turn it on
pause 200
Pin(led) = 0 ' turn it off
pause 200
goto Top ' repeat



--Curtis
I am not a Mad Scientist...  It makes me happy inventing new ways to take over the world!!
 
halldave

Senior Member

Joined: 04/05/2014
Location: Australia
Posts: 121
Posted: 03:15pm 19 Aug 2014
Copy link to clipboard 
Print this post


xOn=1
xOff=0
xLED=11

SETPIN xLED,DOUT

For Counter = 1 to 100
Pin(xLED)=xOn
Pause 1000
Pin(xLED)=xOff
Pause 1000
Next Counter

 
f1fco

Senior Member

Joined: 18/03/2012
Location: France
Posts: 154
Posted: 10:24pm 19 Aug 2014
Copy link to clipboard 
Print this post

thank you for answers and ideas
I like the code from HallDave

I try

high=1
low=0
led=11 'digital output for a led
info=10 'digital input for a button, pull up to VCC

led=low 'led is off

DO
IF info=low THEN 'if I push the button
led=high 'the led light
ELSE
led=low
ENDIF
LOOP

I like the way to name inputs and outputs pins in the top of the code
it is easy to change...

and the name (led, buzzer, siren, relais1, relais2... is much easy to understand)

thank you again

Pierre, at Nimes, south of France
hamradio F1FCO
73s de F1FCO
 
f1fco

Senior Member

Joined: 18/03/2012
Location: France
Posts: 154
Posted: 12:43am 21 Aug 2014
Copy link to clipboard 
Print this post

the previous code do not run

the following to blink a led is OK

high=1
low=0
led=11

SETPIN led,dout 'digital output for a led

Pin(led)=low 'led is off

DO
Pin(led)=high 'or =1
Pause 500
Pin(led)=low 'or =0
Pause 500
LOOP

it is a "smart" way to name pins
Pin(led) is meaningful than Pin(11) and you can name the I/Os pins in the top of the program



ti ti ti ti ti ti 'end of transmission

F1FCO, Pierre
73s de F1FCO
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024