We initially didn't do what we were suggested to do, but instead began by setting up an Arduino that connected to 6 LEDs via separate digital pins. We then adapted a piece of code from the example library to execute two loops (inside an infinite loop) which would light up the LEDs in sequence and then do the sequence in reverse and repeat.
Here is a picture of the circuit...
And a video of the same setup working...
After we had finished this, we experimented with the code from week 2 and added a potentiometer to the circuit to input a value to an analogue pin and change the speed of the flashing LEDs (more along the lines of what was asked of us for the workshop).
Here is the final code:
int potPin = 2;And here is a video of the final circuit working...
int pins[] = { 2, 3, 4, 5, 6, 7 };
int num_pins = 6;
int val = 0;
void setup()
{
int i;
for (i = 0; i < i =" 0;" val =" analogRead(potPin);" i =" num_pins">= 0; i--)
{
val = analogRead(potPin);
digitalWrite(pins[i], HIGH);
delay(val+50);
digitalWrite(pins[i], LOW);
Serial.println(val);
}
}
After performing this exercise, I feel yet more confident in programming and making circuits using Arduino technology and software. It would be a good idea to start thinking up ideas for a larger scale project that could have use in the public world.
No comments:
Post a Comment