9 years, 3 months ago.

Anyone knows what went wrong, tried compiling this for the FRDM K64F?

I tried running this code, in the K64 but I get a compilation error... Can anyone tell me what I have done wrong?

  1. include "mbed.h" int led[4] = {0,1,2,3}; int main() { for(int i=3; i<4; i++){ DigitalOut(led[i]); } while(1){ for(int i=3; i<4; i++){ led[i] = 1; } for(int i=3; i<4; i++){ led[i] = 0; } } }

Error: No default constructor exists for class "mbed::DigitalOut" in "main.cpp", Line: 6, Col: 21

I'm new to using the k64f, this program would run fine in an arduino....

Question relating to:

Please use code tags, otherwise it is difficult to read your code.

posted by David Fletcher 27 Jul 2015

2 Answers

9 years, 3 months ago.

Hi Stive,

Please have a look on the page https://developer.mbed.org/handbook/DigitalOut

on how to use DigitalOut.

Also, like David said, please use code tags:

Code from Stive

#include "mbed.h"

int led[4] = {0,1,2,3};

int main()
{
   for(int i=3; i<4; i++)
   {   
      DigitalOut(led[i]);
   }

   while(1)
   {
      for(int i=3; i<4; i++)
      {
         led[i] = 1;
      }
      for(int i=3; i<4; i++)
      {
         led[i] = 0;
      }
   }

}

Regards, Miloje

Accepted Answer

Thank you, but its sad that the K64F needs a pin name for each pin, unlike the arduino.

posted by Stive Hassan 27 Jul 2015
9 years, 3 months ago.

I don't think you can use DigitalOut with arrays.