blog

pcomp lab #2 - analog inputs and outputs

the second lab was a little more complicated than the first. the objective was to get the LED to dim up or down as the potentiometer increased or decreased the resistance.

i had a bit more trouble this week with the lab than i did the previous week.  setting up the breadboard was fine and most of it made sense logically, save for the fact that i accidentally connected one wire back to power instead of to ground (pointed out by my classmate hiye shin).  the problem came when it was time to write the code.

this is how the code was supposed to be in order to make the potentiometer and LED work but for some reason, even though it's simple, i had a hard time getting here.  maybe it was because i had spent the past few days immersed in processing and so when it came time to write the arduino code, i found myself stuck, but also because i wasn't able to as easily recall what functions called what actions in arduino.  i had to look under the "i give up, explain it to me" links a couple of times in order to figure out what i was doing wrong and what needed to happen in the code to make my setup work.

as evidenced by the video above, i did finally get it to work (but i really do think i need to refresh myself on the basics of coding in arduino to make sure this doesn't happen again in the future).  the next step was setting up the circuit to see if i could get the force sensor to behave in the same way.

i actually ended up using the same code for this one and it worked great.

then, i put both the sensors on the board and tried to see if i could get one LED to light up when one sensor was activated, and the other to light when the other was activated.

i ended up, in this example, creating a set of all new variables (ledPin1 & 2, brightness1 & 2, potValue, and forceValue).  this enabled me to create two different scenarios under void loop(){} that allowed one LED to react to one sensor, and the second to the other one.

UncategorizedRoopa Vasudevan