Difference between revisions of "Linear/Slide Potentiometer Module"

From LinkSprite Playgound
Jump to: navigation, search
Line 1: Line 1:
 
[[File:Sliding potentiometer.jpg]]
 
[[File:Sliding potentiometer.jpg]]
  
 +
 +
== Sample ==
 +
 +
<syntaxhighlight lang="c">
 +
 +
int adcPin = A0;    // select the input pin for the potentiometer
 +
int ledPin = A1;      // select the pin for the LED
 +
int adcIn  = 0;  // variable to store the value coming from the sensor
 +
 +
void setup() {
 +
  Serial.begin(9600);        // init serial to 9600b/s
 +
  pinMode(ledPin, OUTPUT);    // set ledPin to OUTPUT
 +
  Serial.println("Sliding Potentiometer Test Code!!");
 +
}
 +
 +
void loop() {
 +
  // read the value from the sensor:
 +
  adcIn = analogRead(adcPin);
 +
  if(adcIn >= 500)  digitalWrite(ledPin,HIGH);  // if adc in > 500, led light
 +
  else digitalWrite(ledPin, LOW);
 +
  Serial.println(adcIn);
 +
  delay(100);
 +
}
 +
 +
</syntaxhighlight lang="c">
 +
 +
Here Linker Slide potentiometer is connected to [A0 A1 V G].
  
  
 
== Schematics ==
 
== Schematics ==
 
*[https://s3.amazonaws.com/linksprite/LinkerKit/sliding+protentiometer.pdf Schematics]
 
*[https://s3.amazonaws.com/linksprite/LinkerKit/sliding+protentiometer.pdf Schematics]

Revision as of 12:23, 25 April 2013

Sliding potentiometer.jpg


Sample

<syntaxhighlight lang="c">

int adcPin = A0; // select the input pin for the potentiometer int ledPin = A1; // select the pin for the LED int adcIn = 0; // variable to store the value coming from the sensor

void setup() {

 Serial.begin(9600);        // init serial to 9600b/s
 pinMode(ledPin, OUTPUT);    // set ledPin to OUTPUT
 Serial.println("Sliding Potentiometer Test Code!!");

}

void loop() {

 // read the value from the sensor:
 adcIn = analogRead(adcPin);
 if(adcIn >= 500)  digitalWrite(ledPin,HIGH);  // if adc in > 500, led light
 else digitalWrite(ledPin, LOW);
 Serial.println(adcIn);
 delay(100);

}

</syntaxhighlight lang="c">

Here Linker Slide potentiometer is connected to [A0 A1 V G].


Schematics