element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Arduno Code to C/C++ for LED Cube
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 3 replies
  • Subscribers 391 subscribers
  • Views 1185 views
  • Users 0 members are here
  • led_cube
  • programming in c
  • led cube
  • c++ coding
  • 4x4_led_cube
Related

Arduno Code to C/C++ for LED Cube

dzuz
dzuz over 6 years ago

Does anyone know how to convert arduino code to c/c++?

 

I have made a 4x4x4 LED cube, but I need to have the code in c/c++, not just arduino code.

 

If anyone knows of a converter or can link a site to easily learn c/c++ on an arduino, that would be greatly appreciated. Thanks!

 

-Dan

  • Sign in to reply
  • Cancel

Top Replies

  • fmilburn
    fmilburn over 6 years ago +3
    Hi Daniel, Arduino code is C++ in an IDE with pin mapping and standard access to timers and other hardware features regardless of the microcontroller. There are also numerous libraries providing access…
Parents
  • dzuz
    dzuz over 6 years ago

    I was instructed to change the code below into C or C++. I have to do it with out using digitalwrite. I tried something, to turn all LEDs (turnEverythingOn();) on with the code all the way at the bottom (bolded). Is anyone able to confirm that my code would work?

     

    //initializing and declaring led rows

      int column[18]={13,12,11,10,9,8,7,6,5,4,3,2,1,0,A5,A4};

    //initializing and declaring led layers

      int layer[4]={A3,A2,A1,A0};

     

     

      int time = 250;

     

    void setup()

    {

      //setting rows to ouput

      for(int i = 0; i<16; i++)

      {

        pinMode(column[i], OUTPUT);

      }

      //setting layers to output

      for(int i = 0; i<4; i++)

      {

        pinMode(layer[i], OUTPUT);

      }

      //seeding random for random pattern

      randomSeed(analogRead(10));

    }

    //xxxxxxxxxxxxxxxxxxxxFUNCTION LOOPxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

     

     

    void loop()

    {

      turnEverythingOff();//turn all off

      flickerOn();

      turnEverythingOn();//turn all on

    }

     

    void turnEverythingOff()

    {

       for(int i = 0; i<16; i++)

       {

         digitalWrite(column[i], 1);

       }

       for(int i = 0; i<4; i++)

       {

         digitalWrite(layer[i], 0);

       }

    }

     

    ////////////////////////////////////////////////////////////turn all on

    void turnEverythingOn()

    {

      for(int i = 0; i<16; i++)

      {

        digitalWrite(column[i], 0);

      }

      //turning on layers

      for(int i = 0; i<4; i++)

      {

        digitalWrite(layer[i], 1);

      }

    }

    ///////////////////////////////////////////////////////turn columns off

    void turnColumnsOff()

    {

      for(int i = 0; i<16; i++)

      {

        digitalWrite(column[i], 1);

      }

    }

    /////////////////////////////////////////////////////////////flicker on

    void flickerOn()

    {

      int i = 150;

      while(i != 0)

      {

        turnEverythingOn();

        delay(i);

        turnEverythingOff();

        delay(i);

        i-= 5;

      }

    }

     

    void loop()

    {

    turnEverythingOn();
    }

    void turnEverythingOn()

    {

    DDRD = 0xFF; //setting outputs
    DDRC = 0x3F;
    DDRB = 0xC3;

    PORTD = 0xFF; //PD0-PD7 8pins
    PORTB.0 = 0xFF; //PB0 & PB1 2pins
    PORTB.1 = 0xFF;
    PORTC.0 = 0xFF; //PC0-PC5 6pins
    PORTC.1 = 0xFF;
    PORTC.2 = 0xFF;
    PORTC.3 = 0xFF;
    PORTC.4 = 0xFF;
    PORTC.5 = 0xFF;

    }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • dzuz
    dzuz over 6 years ago

    I was instructed to change the code below into C or C++. I have to do it with out using digitalwrite. I tried something, to turn all LEDs (turnEverythingOn();) on with the code all the way at the bottom (bolded). Is anyone able to confirm that my code would work?

     

    //initializing and declaring led rows

      int column[18]={13,12,11,10,9,8,7,6,5,4,3,2,1,0,A5,A4};

    //initializing and declaring led layers

      int layer[4]={A3,A2,A1,A0};

     

     

      int time = 250;

     

    void setup()

    {

      //setting rows to ouput

      for(int i = 0; i<16; i++)

      {

        pinMode(column[i], OUTPUT);

      }

      //setting layers to output

      for(int i = 0; i<4; i++)

      {

        pinMode(layer[i], OUTPUT);

      }

      //seeding random for random pattern

      randomSeed(analogRead(10));

    }

    //xxxxxxxxxxxxxxxxxxxxFUNCTION LOOPxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

     

     

    void loop()

    {

      turnEverythingOff();//turn all off

      flickerOn();

      turnEverythingOn();//turn all on

    }

     

    void turnEverythingOff()

    {

       for(int i = 0; i<16; i++)

       {

         digitalWrite(column[i], 1);

       }

       for(int i = 0; i<4; i++)

       {

         digitalWrite(layer[i], 0);

       }

    }

     

    ////////////////////////////////////////////////////////////turn all on

    void turnEverythingOn()

    {

      for(int i = 0; i<16; i++)

      {

        digitalWrite(column[i], 0);

      }

      //turning on layers

      for(int i = 0; i<4; i++)

      {

        digitalWrite(layer[i], 1);

      }

    }

    ///////////////////////////////////////////////////////turn columns off

    void turnColumnsOff()

    {

      for(int i = 0; i<16; i++)

      {

        digitalWrite(column[i], 1);

      }

    }

    /////////////////////////////////////////////////////////////flicker on

    void flickerOn()

    {

      int i = 150;

      while(i != 0)

      {

        turnEverythingOn();

        delay(i);

        turnEverythingOff();

        delay(i);

        i-= 5;

      }

    }

     

    void loop()

    {

    turnEverythingOn();
    }

    void turnEverythingOn()

    {

    DDRD = 0xFF; //setting outputs
    DDRC = 0x3F;
    DDRB = 0xC3;

    PORTD = 0xFF; //PD0-PD7 8pins
    PORTB.0 = 0xFF; //PB0 & PB1 2pins
    PORTB.1 = 0xFF;
    PORTC.0 = 0xFF; //PC0-PC5 6pins
    PORTC.1 = 0xFF;
    PORTC.2 = 0xFF;
    PORTC.3 = 0xFF;
    PORTC.4 = 0xFF;
    PORTC.5 = 0xFF;

    }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube