Assignment 3 : Sensing: Potentiometers

Assignment: Sensing: Potentiometers

Collaborators:

1. Project Description

: Get analog input from three Potentiometers and control three LEDs' blinking and dimming rate

2. Components Used

  • Arduino
  • Three LEDs
  • Resistors
  • Three Potentiometers
  • Diffuser from previous assignment

3. Arduino Code for extra one

 

/* Each potentiometer could control each LED's blinking and dimming rate at the same time. */

// Analog pin settings

int aIn = 0;    // Potentiometers connected to analog pins 0, 1, and 2

int bIn = 1;    //   (Connect power to 5V and ground to analog ground)

int cIn = 2;

 

// Digital pin settings

int aOut = 9;   // LEDs connected to digital pins 9, 10 and 11

int bOut = 10;  //   (Connect cathodes to digital ground)

int cOut = 11;

 

// Values

int aVal = 0;   // Variables to store the input from the potentiometers

int bVal = 0;

int cVal = 0;

 

void setup()

{

pinMode(aOut, OUTPUT);   // sets the digital pins as output

pinMode(bOut, OUTPUT);

pinMode(cOut, OUTPUT);

Serial.begin(9600);     // Open serial communication for reporting

}

 

void loop()

{

 

aVal = analogRead(aIn)/4 ;  // read input pins, convert to 0-255 scale

bVal = analogRead(bIn)/4 ;

cVal = analogRead(cIn)/4 ;

 

digitalWrite(aOut, HIGH);  // Send new values to LEDs

delay(aVal);

digitalWrite(aOut, LOW);

delay(aVal);

 

digitalWrite(bOut, HIGH);  // Send new values to LEDs

delay(bVal);

digitalWrite(bOut, LOW);

delay(bVal);

 

digitalWrite(cOut, HIGH);  // Send new values to LEDs

delay(cVal);

digitalWrite(cOut, LOW);

delay(cVal);

}

 

4. Picture and Video

Option 1 video

Option 2 video

Extra one video