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); } }
code
ReplyDeleteKode ?
Deletein the blog
Deletewdym the code is in here
Deletepp
ReplyDeleteThis code would probably work int leds[] = {2, 3, 4, 5, 6, 7, };
ReplyDeleteint 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);
}
}
Nevermind, this is the code int layers[] = {2, 3}; // Pin numbers for the layers
Deleteint 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);
}
}