Activity › Forums › Questions & Troubleshooting › Software & Firmware › Porting Arduino code…
-
Hi!
We have some code we would like to port to Controllino from Arduino DUE. We are not using pin names in code so we can easily change a port if needed… Example:
int startPin = 10;
int sensorPin = A0;
int outputPin = DAC0;
……
pinMode(outputPin, OUTPUT);
……
analogWrite(outputPin, output);
I attempted to do the same for Controllino but I don’t think it is working… I’m guessing this should not be int but something else?
int startPin = CONTROLLINO_AI13;
int sensorPin = CONTROLLINO_AI12;
int outputPin = CONTROLLINO_AO0;
For example outputPin is DI12 not AO0…
What am I doing wrong?
Thanks
- This discussion was modified 3 years, 10 months ago by Lucko.
-
Hello Lucko,
Have you installed the CONTROLLINO Libs correctly?
But you can always use the original Arduino pin names (see Pinout the blue numbers).
So in your case use …
int startPin = A15;
int sensorPin = A14;
int outputPin = 12;
regards
Marco-
I think so… I did also add
#include <Controllino.h>
Anyway I will just use blue numbers for now…
Thanks!
-
That did not work… And it was not D12 but DI2 that is activating… That should be 10… And now I’m running really simple test code… A0 is OK but 12 is not working…
#include <Controllino.h>
int outputPin = 12;
int testPin = A0;
void setup() {
// put your setup code here, to run once:
pinMode(testPin, INPUT);
analogWrite(outputPin, 0);
}
void loop() {
// put your main code here, to run repeatedly:
if (digitalRead(testPin)){
analogWrite(outputPin, 255);
}
if (!(digitalRead(testPin))){
analogWrite(outputPin, 0);
}
}
- This reply was modified 3 years, 10 months ago by Lucko.
-
Could it be that a light indicator coming on for DI2 when turn on AO1 on Automation? Since AO1 doesn’t have one.. I don’t have a voltmeter to check voltage on a AO1 if that is a case… And the program was working just fine but when I was testing indicator tricked me…
If I change to AO2 or 13 indicator DI3 turns on…
- This reply was modified 3 years, 10 months ago by Lucko.
-
Log in to reply.