On to new things…

Yashraje
My Design Journey

--

After a moderately successfully foray into the world of Processing, in this weeks update we’re shifting focus to Arduino, which is something I’ve only heard of in passing when talking to my engineer buddies, and they had a few “colourful” words about it to say the least. After a quick run through of the basics of the Arduino board, it’s time to jump in head first and create my first circuit. Full disclosure, we did practice with a basic LED lighting circuit which I haven’t documented.

I started building my circuit by creating an initial loop for the LED light that I wanted to light up as well as including an input method that would allow me to control the current going to the LED, which I’ve included below. As my professor explained, electrons love to flow through a circuit in full force, so I included a 220 Ohm resistor that would allow me to limit the amount of current that flows through the LED and prevent it from burning out due to the excess current. The circuit also includes a potentiometer that allows me to fluctuate the output that goes into the LED. all three of the prices were linked together with 5 Volts of power coming from the Arduino board and a wire heading back to ground to complete the circuit. For the potentiometer, I included a wire heading from the input sire(the side with one pin) into the A0 slot in the Arduino board. This is what will let input the code I write for to be sent to the potentiometer.

Speaking of my code, for this experiment I wanted the LED to dim and brighten when I turned the potentiometer, similar to sliding dimmers switches we see in our homes. So let’s jump into the Arduino software.

int led = 11;void setup() {
pinMode(led, OUTPUT);
Serial.begin(9600);
}
void loop() {
//read the potentiometer
int pot = analogRead(A0);
Serial.println(pot);
int brightness = map(pot, 0, 1023, 0, 255);
analogWrite(led, brightness);
}

I started off by creating an int value which equates to the port that the LED is plugged into on the Arduino board. After setting up up our output, pinMode was used to call the port that the LED is plugged into (I used 11) and Serial.begin to establish that the Arduino board will be communicating with the component on the breadboard. With the setup ready it’s time to set up the loop to adjust the brightness.

When creating the loop, its important to understand that we can’t just add more or less brightness to the LED light, bur we can increase and decrease the intervals between the light turning on, with a lower frequency simulating a birther light and a higher frequency emulating a dimmed light. In order to to do that I started off by drawing the input from the potentiometer. The potentiometers value go from 0 to 1023( 1024 total values), and we know that brightness has a value range of 0 to 255, so in order to let the values “talk” to one another, I used map() to equate the two ranges to one another. Once that was set, we’re good to go.

Now unfortunately for myself and anyone looking forward to to seeing a dimming LED, my light is staying as dark as a premium Columbian roast. There seems to be a bit of a communication error, so it’s looking like some some troubleshooting is in order, but I think that it’s just a matter of choosing the right port that the software is talking to and fixing my USB port on my laptop, so I will update you all in next weeks post the fix and some more tweaks that I plan in adding to it.

--

--