I don't have an Arduino, but looking at some brief code examples, they wouldn't do it that way. It appears that an internal sub/procedure is used to initialize the port pins, and thus shield the user from knowing what a port pin (e.g. portb.1) is. This could be done easily for a single device, or maybe a device family.
Here ya go……CowDuino:
'Here's a led blinky program with Arduino syntax
#chip 16f690,4
'Arduino like pin numbering for leds
#define red = 4
#define green = 5
#define blue = 6
'setup Arduino parameter syntax
#define output 0
#define input 1
#define High 1
#define Low 0
'Arduino like pin dir setting
pinMode(red, output)
pinMode(green, output)
pinMode(blue, output)
Main:
digitalWrite(Red,High) 'Arduino like port pin set/clear
wait 1 s
digitalWrite(Red,Low)
wait 1 s
digitalWrite(Green,High)
wait 1 s
digitalWrite(Green,Low)
wait 1 s
digitalWrite(Blue,High)
wait 1 s
digitalWrite(Blue,Low)
wait 1 s
goto Main
sub pinMode(portpin, direction)
If portpin = 4 Then
If direction = 1 Then
bsf TRISB,4
Else
bcf TRISB,4
End if
End if
If portpin = 5 Then
If direction = 1 Then
bsf TRISB,5
Else
bcf TRISB,5
End if
End if
If portpin = 6 Then
If direction = 1 Then
bsf TRISB,6
Else
bcf TRISB,6
End if
End if
end sub
sub digitalWrite(portpin,state)
If portpin = 4 Then
If state > Low Then
set PortB.4 On
Else
set PortB.4 Off
End if
End if
If portpin = 5 Then
If state > Low Then
set PortB.5 On
Else
set PortB.5 Off
End if
End if
If portpin = 6 Then
If state > Low Then
set PortB.6 On
Else
set PortB.6 Off
End if
End if
end sub
Kent
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here is a better, and more GCBasic like syntax. Lets say the Arduino like pin numbers are used as D0, D1, D2…. and A0, A1, A3…
'Here's a led blinky program with CowduinoPins and GCBasic syntax
#chip 16f690,4
'Arduino like pin numbering for leds
Call CowduinoPins
'reference descriptive names <or not>
#define red D0
#define green D1
#define blue = D2
'set port direction
dir red out
dir green out
dir blue out
Main:
Set Red On
wait 1 s
Set Red Off
wait 1 s
Set Green On
wait 1 s
Set Green Off
wait 1 s
set Blue On
wait 1 s
Set Blue Off
wait 1 s
goto Main
'this sub could be made into an .h file for the GCBasic include folder
'and then assembled in the program with the compiler directive
'#include <CowduinoPins.h>
sub CowduinoPins
#define D0 PortB.4
#define D1 PortB.5
#define D2 PortB.6
#define D3 PortB.7
#define D4 PortC.0
#define D5 PortC.1
#define D6 PortC.2
'etc.......
#define A0 PortA.0
#define A1 PortA.1
#define A2 PortA.2
'etc.......
end sub
Kent
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is it possible to setup the ports as pin numbers similar to the way Arduino does?
i.e.
#define 1 portb.1
set 1 on
You mean like a CowDuino? :=)
I don't have an Arduino, but looking at some brief code examples, they wouldn't do it that way. It appears that an internal sub/procedure is used to initialize the port pins, and thus shield the user from knowing what a port pin (e.g. portb.1) is. This could be done easily for a single device, or maybe a device family.
Here ya go……CowDuino:
Kent
Here is a better, and more GCBasic like syntax. Lets say the Arduino like pin numbers are used as D0, D1, D2…. and A0, A1, A3…
Kent
Closed due to persistent spam bot.