To get the light working we worked off a slightly modified version of this schematic, mashed in with the piezo tutiorial. Here is where things got really ambitious, we came up with the idea to incorporate a RGB LED light that would change colors each time there was a note change in “Somewhere Over the Rainbow.” Rainbow lights for a song about rainbows. But eventually, we were able to program in the opening of “Mary Had a Little Lamb,” Mozart’s Lacrimosa, John Coltrane’s “26-2,” and “Somewhere Over the Rainbow.” They were jamming out to the Star Wars theme while we were still trying to get things working. Or, as Eric and Ronda showed, we could have just downloaded a tone library to do this for us. We probably could have done this in a more dynamic way. TimeHigh = period / 2 = 1 / (2 * toneFrequency) To extend the range, we hard coded frequencies for the new notes according to the formula given by the original Arduino code: There is probably a more elegant solution, but we got around this by associating the accidentals with new characters entirely So when the computer sees “cc#”, it processes it as two ‘c’s and one nonsense syllable that it can’t process. But the code finds the notes in the melody by reading character by character through an array. At first we tried to use standard notation – f sharp would be represented by f#. One difficulty here was in the way that way that accidentals would be read by the board. We opened things up by expanding the range of tones the speaker could play, including both a chromatic scale and adding an extra octave. I apologize in advance for whatever vocabulary gap there might be in the discussion below it was my first time coding in C.įor one, this set-up only uses a single octave major scale. We started out working with this schematic, but we wanted to expand things a little. At that point we went off the map, dreaming big and working off the page. From there we decided to skip several chapters to make a little music player using a piezo speaker component. Jeremy brought in a bunch of Arduino kits of all shapes and sizes, and various people went to work to see what they could make out of them.įirst Claire and I got a blinking light to work. We had no idea what we were getting into, which made it all the more fun. It’s a prerequisite for this project to help you understand the topic in more detail.The following was co-authored and co-hacked with Claire.Ĭlaire and I went to the Arduino Hackday hosted by the Scholars’ Lab on Friday. ![]() And this is typically what we use the PWM output for.Ĭheck the tutorial below to learn more about Arduino PWM. ![]() Certain loads like (LEDs, Motors, etc) will respond to the average voltage of the signal which gets higher as the PWM signal’s pulse width is increased.Īs you can see, the LED gets brighter as the pulse width (duty cycle) increases, and it gets dimmer as the pulse width decreases. Pulse Width Modulation ( PWM) is a technique for generating a continuous HIGH/LOW alternating digital signal and programmatically controlling its pulse width and frequency. ![]() Before discussing how to use the PWM output pins, let’s first define what is the PWM technique and what are the properties of a PWM signal. Those pins are designated with a ( ~) mark next to the pin number on the board. By varying the duty cycle for each color input, we can get a desired specific color code as we’ll see hereafter in this tutorila.Īrduino boards have several PWM output pins usually. We use Arduino PWM output to control the RGB inputs for the 3 LEDs (Red, Green, and Blue). It’s better indicated in the figure below. The longest it the ground (common) pin, next to it is the Red LED input, and on the other side there are the Green and Blue inputs. ![]() Given that each LED can have 256 different levels of intensity, the combined RGB LED will therefore have (256 3 ≈ 16.77Million) unique colors.Īn RGB LED has typically 4 leads (pins). It can emit pure Red, Green, or Blue light each at the same time using a separate input lead and light emitting diode.īy varying the intensity of the light for each color LED, we can achieve millions of possible colors over the entire color spectrum. Control RGB LED using MicroPython Table of ContentsĪn RGB LED is basically an electronic device that combines three LED elements in one package.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |