![]() |
Forum Index : Microcontroller and PC projects : is it possible to name a PIN ?
Author | Message | ||||
f1fco Senior Member ![]() Joined: 18/03/2012 Location: FrancePosts: 155 |
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: AustraliaPosts: 5111 |
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 StatesPosts: 327 |
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: AustraliaPosts: 121 |
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: FrancePosts: 155 |
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: FrancePosts: 155 |
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 |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |