Advertisement
3rdWard_Arduino

class2_potLED

Jun 10th, 2012
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. // set pin numbers:
  2. int potPin = A0;     // the number of the potentiometer pin
  3. int ledPin = 3;      // the number of the led pin
  4. // variables will change:
  5. int potValue = 0;         // variable for reading the pot value
  6.  
  7. void setup() {
  8.   // initialize the led pin
  9.   pinMode(ledPin, OUTPUT);
  10.   // initialize the Serial communication
  11.   Serial.begin(9600);  
  12. }
  13.  
  14. void loop(){
  15.   // read the value of the pot:
  16.   potValue = analogRead(potPin);
  17.  
  18.   Serial.println(potValue);
  19.  
  20.   analogWrite(ledPin, potValue/4);
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement