Assignment 6.1

Post date: Jul 02, 2010 8:31:39 PM

I borrowed the code from assignment 2.2 because it did the same thing and was much easier to look at.

int potPin = 2; // declares variables

int val = 0;

void setup() {


void loop() {

for (int ledPin = 13; ledPin >= 4; ledPin--) // when ledPin is at 13, decrease by one

{ // each time loop is run until ledPin=4

val = analogRead(potPin); // reads potPin and stores value in val

pinMode(ledPin, OUTPUT); // sets ledPin to output

digitalWrite(ledPin, HIGH); // turns ledPin on

delay(val); // delay for whatever val is

digitalWrite(ledPin, LOW); // turns ledPin off

delay(val); // delay for whatever val is


for (int ledPin = 4; ledPin <= 13; ledPin++) // when ledPin is at 4, increase by one

{ // each time loop is run until ledPin=13

val = analogRead(potPin);

pinMode(ledPin, OUTPUT);

digitalWrite(ledPin, HIGH);


digitalWrite(ledPin, LOW);





When the potentiometer is turned fully to the negative side, the LEDs appear to spaz out. If you wave the breadboard perpendicular to the row of LEDs you can see a zigzag pattern, proving that it's just your mind playing tricks on you again.