This is an old revision of the document!
I have always liked to play with lights and i had a led strip laying around my pc setup and i thought it would be fun if it was sound reactive. The lights should react to the sound waves, either because of the rithm or the wavelength of the sound.
There are 3 parts of the circuit, one for each color(RGB); the tranzistors are connected to the assigned arduino pins (gnd to gnd) and to the leds; the sound sensor is only connected to the arduino board(GND to GND, Vcc to 5V and out to A0). The power supply is conntected to the breadboard. Ultimately there are 5 different modules connected to each other:
Block scheme:
The following components are required for this project:
Electric scheme:
- sensorValue = (float)analogRead(sensorPin) * (5.0 / 1024.0);
- performs an analog-to-digital conversion using the analogRead function; it reads the analog value from sensorPin and converts it to a digital value
- Timer1.initialize(100000);
- sets the timer interval to 100ms (0.1s); this allows for periodic execution of a function based on the timer interval
- Timer1.attachInterrupt(FlashLEDs);
- attaches the FlashLEDs function to the interrupt triggered by Timer1; this means that every time the timer interrupt occurs (every 100ms), the FlashLEDs function will be executed.
- <avr/interrupt.h>
- TimerOne.h (It is used in this code to set up a timer interrupt for flashing the LEDs)
- MainFunction(): Reads the sensor value, filters the signal, and compares it to predefined values to determine the color to display on the RGB LED strip
- FilterSignal(float sensorSignal): Applies a filter to the sensor signal using a weighted moving average algorithm
- CompareSignalFiltered(float filteredSignal): Compares the filtered signal to predefined thresholds to determine the appropriate color to display
- RGBColor(int Rcolor, int Gcolor, int Bcolor): Sets the color of the RGB LED strip by writing appropriate values to the Rpin, Gpin, and Bpin pins
- setup(): Sets up the initial configuration of the program, including serial communication initialization and timer setup
- loop(): Contains the main execution loop, calling the MainFunction() repeatedly
- FlashLEDs(): A timer interrupt service routine (ISR) that alternates the LED strip between white and off states
Care au fost rezultatele obţinute în urma realizării proiectului vostru.
O arhivă (sau mai multe dacă este cazul) cu fişierele obţinute în urma realizării proiectului: surse, scheme, etc. Un fişier README, un ChangeLog, un script de compilare şi copiere automată pe uC crează întotdeauna o impresie bună .
Fişierele se încarcă pe wiki folosind facilitatea Add Images or other files. Namespace-ul în care se încarcă fişierele este de tipul :pm:prj20??:c? sau :pm:prj20??:c?:nume_student (dacă este cazul). Exemplu: Dumitru Alin, 331CC → :pm:prj2009:cc:dumitru_alin.
Puteți avea și o secțiune de jurnal în care să poată urmări asistentul de proiect progresul proiectului.
Listă cu documente, datasheet-uri, resurse Internet folosite, eventual grupate pe Resurse Software şi Resurse Hardware.