Activity Forums Questions & Troubleshooting Software & Firmware Porting Arduino code…

  • Porting Arduino code…

     Lukas updated 3 years, 10 months ago 3 Members · 6 Posts
  • Lucko

    Member
    January 13, 2021 at 1:18 pm

    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, 11 months ago by  Lucko.
  • mr-controllino

    Administrator
    January 13, 2021 at 1:40 pm

    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

    • Lucko

      Member
      January 13, 2021 at 1:53 pm

      I think so… I did also add

      #include <Controllino.h>

      Anyway I will just use blue numbers for now…

      Thanks!

    • Lucko

      Member
      January 13, 2021 at 2:12 pm

      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, 11 months ago by  Lucko.
    • Lucko

      Member
      January 13, 2021 at 2:23 pm

      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, 11 months ago by  Lucko.
  • Lukas

    Member
    February 16, 2021 at 12:35 pm

    Seems to be an issue with the device or the compilation toolchain. Continues here.

Viewing 1 - 3 of 3 replies

Log in to reply.

Original Post
0 of 0 posts June 2018
Now