Thursday, 25 June 2020

How to make 2*2*2 LEDCUBE using arduino




Circuit diagram
download code from here

Video tutorial

7 comments:

  1. This code would probably work int leds[] = {2, 3, 4, 5, 6, 7, };
    int numLeds = 6;

    void setup() {
    for (int i = 0; i < numLeds; i++) {
    pinMode(leds[i], OUTPUT);
    }
    }

    void loop() {
    for (int i = 0; i < numLeds; i ++) {
    digitalWrite(leds[i], HIGH);
    delay(150);
    digitalWrite(leds[i], LOW);
    delay(10);
    }
    }

    ReplyDelete
    Replies
    1. Nevermind, this is the code int layers[] = {2, 3}; // Pin numbers for the layers
      int columns[] = {4, 5}; // Pin numbers for the columns
      int numLayers = 2; // Number of layers in the cube
      int numColumns = 2; // Number of columns per layer

      void setup() {
      // Initialize layer pins
      for (int i = 0; i < numLayers; i++) {
      pinMode(layers[i], OUTPUT);
      digitalWrite(layers[i], LOW); // Set layers to off initially (LOW assumes common cathode)
      }

      // Initialize column pins
      for (int i = 0; i < numColumns; i++) {
      pinMode(columns[i], OUTPUT);
      digitalWrite(columns[i], LOW); // Set columns to off initially
      }
      }

      void loop() {
      // Loop through layers
      for (int layer = 0; layer < numLayers; layer++) {
      // Turn on the current layer
      digitalWrite(layers[layer], HIGH); // Assuming HIGH turns the layer on

      // Loop through columns in this layer
      for (int col = 0; col < numColumns; col++) {
      // Turn on the LED at this column in the current layer
      digitalWrite(columns[col], HIGH);
      delay(150); // Wait to visualize LED on
      digitalWrite(columns[col], LOW); // Turn off LED in this column
      }

      // Turn off the current layer before moving to the next
      digitalWrite(layers[layer], LOW);
      }
      }

      Delete