Devices & Components
ARDUINO UNO WiFi REV2
Jumper wires (generic)
16x16 RGB LED Matrix WS2812B
5V 40A Power Supply
Ultrasonic Sensor - HC-SR04 (Generic)
Software & Tools
Arduino IDE
Project description
Code
SYNERGYALEDMATRIX32x16.ino
arduino
1//SYNERGYA 32x16 2//LED MATRIX WITH ULTRASONIC SENSOR 3//by Camila Cirne, Francisco Luz, Gislaine Reis, Pedro Coelho and Thiago Arajo 4 5#include <Ultrasonic.h> // Add the Ultrasonic by Erick Simes' library 6#include "FastLED.h" // Add FastLED library 7 8#define NUM_LEDS 512 // set the number of LEDS (for 1 matrix 256, for 2 matrices 512 and so on...) 9#define DATA_PIN 3 // set the pin number from the Arduino board 10CRGB leds[NUM_LEDS]; 11 12const int someoneArrivedPin = 7; // set the TRIG terminal in the Arduino board from the Ultrasonic sensor 13const int someoneLeftPin = 6; // set the ECHO terminal in the Arduino board from the Ultrasonic sensor 14 15void setup() { 16 delay(2000); 17 FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS); // WS2812B is the matrix model were using 18 FastLED.setBrightness(150); // Setup the general brightness (0-255) 19 FastLED.clear(); 20 Serial.begin(9600); // Start the serial port to initialize the ultrasonic sensor 21 pinMode(someoneArrivedPin, OUTPUT); // set OUTPUT and INPUT accordingly to the ultrasonic sensor library 22 pinMode(someoneLeftPin, INPUT); 23} 24 25Ultrasonic ultrasonic(someoneArrivedPin, someoneLeftPin); 26 27int randomInt; 28int randomInt2; 29 30void loop() { 31 for(int i = 0; i < 10; i++){ // Outerloop 32 for(int j = 0; j < 1000; j++){ // TURN LEDS ON - Innerloop 33 if (ultrasonic.read() > 10 and ultrasonic.read() <=100){ // Return the distance in cm in the if condition 34 randomInt = (rand()%512); // random intenger that chooses the leds which will be turn on 35 randomInt2 = (rand()%256); // random intenger that chooses the color Hue of the given leds 36 leds[randomInt].setHue(randomInt2); 37 FastLED.show(); 38 } 39 } 40 for(int k = 512; k > 0; k--){ // TURN LEDS OFF - 2nd Innerlooop 41 leds[k] = CRGB::Black; 42 FastLED.show(); 43 } 44 } 45}
Downloadable files
Circuit View
Circuit View

Documentation
Laser cutter box
Laser cutter box
Comments
Only logged in users can leave comments