Daniela Murillo - Proyecto Final I&P
De Casiopea
Título | Daniela Murillo - Proyecto Final I&P |
---|---|
Tipo de Proyecto | Proyecto de Curso |
Palabras Clave | tinkercad, arduino |
Período | 2020-2020 |
Asignatura | Interacción y Performatividad |
Del Curso | Interacción y Performatividad 2020 |
Carreras | Diseño, Diseño Gráfico"Diseño Gráfico" is not in the list (Arquitectura, Diseño, Magíster, Otra) of allowed values for the "Carreras Relacionadas" property., Diseño Industrial"Diseño Industrial" is not in the list (Arquitectura, Diseño, Magíster, Otra) of allowed values for the "Carreras Relacionadas" property. |
Alumno(s) | Daniela Murillo |
Profesor | Renzo Varela |
Proyecto
Casco luminoso
Materiales
Código
Código para Arduino desde tinkercad
#include <Adafruit_NeoPixel.h>
// numero de filas y columnas matriz de 8x8 aplicada a 3x8
- define BUTTON_PIN 2
- define NUM_COLS 8
- define NUM_ROWS 8
// pin de inicio // Top row starts at START_PIN
- define START_PIN 9
- define PIN_INC -1
// Set to 1 to wrap pixels
- define ALLOW_WRAP 1
Adafruit_NeoPixel rows[NUM_ROWS] = {0};
// pxel buffer int pixels[NUM_ROWS][NUM_COLS];
// tiempo que se demora // wait between frames int frameDelayMs = 500;
void setup() {
int pin = START_PIN; for (int r = 0; r < NUM_ROWS; ++r, pin += PIN_INC) { rows[r] = Adafruit_NeoPixel(NUM_COLS, pin, NEO_GRB + NEO_KHZ800); }
} // loop de prendido y apagado void loop() {
clear(); drawFilledRect(random(1, 8), random(3, 8), random(5, 8), random(5, 6), randomColor()); drawRect(random(1, 7), random(4, 8), random(5, 7), random(6, 8), randomColor()); refreshDisplay(); delay(frameDelayMs);
}
void drawRect(int x, int y, int w, int h, int color) {
int x2 = x + (w - 1); int y2 = y + (h - 1); for(int c = x; c <= x2; c++){ setPixel(c, y, color); setPixel(c, y2, color); }
for(int r = y; r <= y2; r++){ setPixel(x, r, color); setPixel(x2, r, color); }
}
void drawFilledRect(int x, int y, int w, int h, int color)
{
int x2 = x + (w - 1); int y2 = y + (h - 1); for(int c = x; c <= x2; c++) {
for(int r = y; r <= y2; r++)
{ setPixel(c, r, color);
}
}
}
void clear() {
memset(pixels, 0, sizeof(pixels));
}
void fill(int color) {
for(int r = 0; r < NUM_ROWS; ++r){
for(int c = 0; c < NUM_COLS; ++c){
setPixel(c, r, color); } }
}
void setPixel(int x, int y, int color) {
- if ALLOW_WRAP
x = x % NUM_COLS; y = y % NUM_ROWS;
- else
if (y < 0 || y >= NUM_ROWS || x < 0 || x >= NUM_COLS) { return; }
- endif
pixels[y][x] = color;
}
void refreshDisplay() {
for(int r = 0; r < NUM_ROWS; ++r) { for(int c = 0; c < NUM_COLS; ++c) { rows[r].setPixelColor(c, pixels[r][c]); }
rows[r].show();
}
} //seleccionador de colores azules y verdes int randomColor(){
int redColor = random(0, 50); int greenColor = random(0, 20); int blueColor = random (0, 80); return Adafruit_NeoPixel::Color(redColor, greenColor, blueColor);
}