la imagen que se aprecia aquí, la saque de internet, les enseña como deben de hacer el cubo(las patitas negativas del led son los horizontales y las patitas positivas del led son los verticales) pero ha diferencia de la mía es que en mi trabajo yo empece con el PIN 0, es igual a la imagen con la condición que deben de mover un PIN a la derecha(o sea, en vez de comenzar desde el PIN 1, yo empece con el PIN 0 y termine en el PIN 11, solo deben de correr un PIN).
MATERIALES:
-27 leds
-9 resistencias de 100 ohmios
-3 resistencias de 1000 ohmios (1K ohmio)
-Cable multipar o de red
-3 transistores NPN 2N 3904
AQUÍ UN VIDEO DE MI CUBO DE LEDs(mas abajo el código)
CÓDIGO:
void setup() {
// initialize the digital pin as an output.
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT); // LEDs verdes
pinMode(10, OUTPUT); // LEDs amarillos
pinMode(11, OUTPUT); // LEDs rojos
}
void loop() {
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
for (int i=0; i <= 3; i++) // run loop 6 times
{
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
delay(300);
digitalWrite(3, LOW);
digitalWrite(5, LOW);
digitalWrite(2, HIGH);
digitalWrite(6, HIGH);
delay(300);
digitalWrite(2, LOW);
digitalWrite(6, LOW);
digitalWrite(1, HIGH);
digitalWrite(7, HIGH);
delay(300);
digitalWrite(1, LOW);
digitalWrite(7, LOW);
digitalWrite(0, HIGH);
digitalWrite(8, HIGH);
delay(300);
digitalWrite(0, LOW);
digitalWrite(8, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
delay(300);
digitalWrite(3, LOW);
digitalWrite(5, LOW);
digitalWrite(2, HIGH);
digitalWrite(6, HIGH);
delay(300);
digitalWrite(2, LOW);
digitalWrite(6, LOW);
digitalWrite(1, HIGH);
digitalWrite(7, HIGH);
delay(300);
digitalWrite(1, LOW);
digitalWrite(7, LOW);
digitalWrite(0, HIGH);
digitalWrite(8, HIGH);
delay(300);
digitalWrite(0, LOW);
digitalWrite(8, LOW);
}
for (int i=0; i <= 3; i++) // run loop 4 times
{
byte pins[] = {0, 1, 2, 5, 8, 7, 6, 3};
// above array of 8
{
for (int i=0; i <= 3; i++) // run loop 3 times
{
byte level[] = {11, 10, 9};
for(int i=0; i<=2; i++) // loop equals number
{ // of values in array
digitalWrite(level[i], HIGH); // write index value
for(int i=0; i<=7; i++) // loop equals number
{ // of values in array
digitalWrite(pins[i], HIGH); // write index value
delay(200); // pause 200ms
digitalWrite(pins[i], LOW); // write index value
}
digitalWrite(level[i], LOW); // write index value
}
}
}
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
for (int i=0; i <= 4; i++) // run loop 4 times
{
digitalWrite(0, HIGH);
delay(300);
digitalWrite(4, HIGH);
delay(300);
digitalWrite(8, HIGH);
delay(300);
digitalWrite(4, LOW);
delay(400);
digitalWrite(6, HIGH);
delay(300);
digitalWrite(4, HIGH);
delay(300);
digitalWrite(2, HIGH);
delay(300);
digitalWrite(4, LOW);
delay(400);
digitalWrite(3, HIGH);
delay(300);
digitalWrite(4, HIGH);
delay(300);
digitalWrite(5, HIGH);
delay(300);
digitalWrite(4, LOW);
delay(400);
digitalWrite(7, HIGH);
delay(300);
digitalWrite(4, HIGH);
delay(300);
digitalWrite(1, HIGH);
delay(300);
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
delay(200);
}
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
for (int i=0; i <= 3; i++) // run loop 5 times
{
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
digitalWrite(4, HIGH);
delay(500);
digitalWrite(1, HIGH);
digitalWrite(3, HIGH);
digitalWrite(5, HIGH);
digitalWrite(7, HIGH);
delay(200);
digitalWrite(9, HIGH);
digitalWrite(11, HIGH);
delay(200);
digitalWrite(0, HIGH);
digitalWrite(2, HIGH);
digitalWrite(6, HIGH);
digitalWrite(8, HIGH);
delay(500);
// all off
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
}
for (int i=0; i <= 4; i++) // run loop 4 times
{
digitalWrite(5, LOW);
digitalWrite(8, LOW);
digitalWrite(0, HIGH);
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
delay(300);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(6, HIGH);
delay(300);
digitalWrite(3, LOW);
digitalWrite(0, LOW);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
delay(300);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(2, HIGH);
digitalWrite(5, HIGH);
delay(300);
}
}
}
y cuales son als librerias help me!! es q lo estoy usando como proyecto final
ResponderEliminarHola amigo este código según veo es 100% libre de librerías es código originario del Arduino que puedes modificar a tu gusto
EliminarEste comentario ha sido eliminado por el autor.
Eliminarfunciona gracias por el aporte
ResponderEliminarGenial, ya lo hice funcionar, gracias!!!
ResponderEliminarexcelente aporte funcionando en 2016
ResponderEliminarsolo me enciende el nivel uno, ¿a que se debe?, porfa gracias
ResponderEliminarFijate si estás haciendo bien las conexiones a las salidas declaradas para cada nivel, si miras las salidas son 9/10/11 trata de que coincida para que haga bien el efecto de luces saludos
EliminarTrato de cargarlo a mi arduino Mega pero me marca un montón de errores en el código, que puedo hacer?
ResponderEliminaral gun codigo para que paresca que esta llovindo
ResponderEliminarMe compilo Muchas gracias.
ResponderEliminarme dice libreria zip invalida
ResponderEliminarexcelente pero solo me prende en nivel uno
ResponderEliminarcreo que algo hice mal :v
Algun codigo que tengas que me puedas proporcionar pero para que me de letras?
ResponderEliminarLes dejo el código adaptado al diagrama que muestra.
ResponderEliminarvoid setup() {
// initialize the digital pin as an output.
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT); // LEDs verdes
pinMode(11, OUTPUT); // LEDs amarillos
pinMode(12, OUTPUT); // LEDs rojos
}
void loop() {
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
for (int i=0; i <= 3; i++) // run loop 6 times
{
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
delay(300);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(3, HIGH);
digitalWrite(7, HIGH);
delay(300);
digitalWrite(3, LOW);
digitalWrite(7, LOW);
digitalWrite(2, HIGH);
digitalWrite(8, HIGH);
delay(300);
digitalWrite(2, LOW);
digitalWrite(8, LOW);
digitalWrite(1, HIGH);
digitalWrite(9, HIGH);
delay(300);
digitalWrite(1, LOW);
digitalWrite(9, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
delay(300);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(3, HIGH);
digitalWrite(7, HIGH);
delay(300);
digitalWrite(3, LOW);
digitalWrite(7, LOW);
digitalWrite(2, HIGH);
digitalWrite(8, HIGH);
delay(300);
digitalWrite(2, LOW);
digitalWrite(8, LOW);
digitalWrite(1, HIGH);
digitalWrite(9, HIGH);
delay(300);
digitalWrite(1, LOW);
digitalWrite(9, LOW); //cambiados//
}
for (int i=0; i <= 3; i++) // run loop 4 times
{
byte pins[] = {1, 2, 3, 6, 9, 8, 7, 4};
// above array of 8
{
for (int i=0; i <= 3; i++) // run loop 3 times
{
byte level[] = {12, 11, 10};
for(int i=0; i<=2; i++) // loop equals number
{ // of values in array
digitalWrite(level[i], HIGH); // write index value
for(int i=0; i<=7; i++) // loop equals number
{ // of values in array
digitalWrite(pins[i], HIGH); // write index value
delay(200); // pause 200ms
digitalWrite(pins[i], LOW); // write index value
}
digitalWrite(level[i], LOW); // write index value
}
}
}
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
for (int i=0; i <= 4; i++) // run loop 4 times
{
digitalWrite(1, HIGH);
delay(300);
digitalWrite(5, HIGH);
delay(300);
digitalWrite(9, HIGH);
delay(300);
digitalWrite(5, LOW);
delay(400);
digitalWrite(7, HIGH);
delay(300);
digitalWrite(5, HIGH);
delay(300);
digitalWrite(3, HIGH);
delay(300);
digitalWrite(5, LOW);
delay(400);
digitalWrite(4, HIGH);
delay(300);
digitalWrite(5, HIGH);
delay(300);
digitalWrite(6, HIGH);
delay(300);
digitalWrite(5, LOW);
delay(400);
digitalWrite(8, HIGH);
delay(300);
digitalWrite(5, HIGH);
delay(300);
digitalWrite(2, HIGH);
delay(300);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
delay(200);
}
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
for (int i=0; i <= 3; i++) // run loop 5 times
{
digitalWrite(10, LOW);
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
digitalWrite(5, HIGH);
delay(500);
digitalWrite(2, HIGH);
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
digitalWrite(8, HIGH);
delay(200);
digitalWrite(10, HIGH);
digitalWrite(12, HIGH);
delay(200);
digitalWrite(1, HIGH);
digitalWrite(3, HIGH);
digitalWrite(7, HIGH);
digitalWrite(9, HIGH);
delay(500);
// all off
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
}
for (int i=0; i <= 4; i++) // run loop 4 times
{
digitalWrite(6, LOW);
digitalWrite(9, LOW);
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
delay(300);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(7, HIGH);
delay(300);
digitalWrite(4, LOW);
digitalWrite(1, LOW);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
delay(300);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(3, HIGH);
digitalWrite(6, HIGH);
delay(300);
}
}
}
Gracias por compartir iniciandome en arduino veremos que tal. 🤟😎
ResponderEliminarThe Casinos Near Harrah's Cherokee Casino Resort
ResponderEliminarClosest casinos to Harrah's Cherokee Casino Resort in Cherokee. 의정부 출장안마 MapYOGA.com 경산 출장마사지 only has a 안산 출장안마 short drive 화성 출장안마 from 춘천 출장마사지 Harrah's Cherokee Casino Resort.