Potentiometer breakout met knop

3,95

1 op voorraad

SKU: HE0546-600 Categorie: Verzenden:

Beschrijving

Potentiometer breakout met knop. Gebaseerd op een 10KOhms verstelbare potentiometer. VCC output veranderd van als er aan de knop word gedraaid. Te gebruiken met 3.3V en 5V logica microcontrollers. Te gebruiken als volume control of licht dim applicaties. Rotatie hoek van 0 – 280 graden.

Arduino code voorbeeld:

//Hardware: A Rotary Angle Sensor and a LED
//Board: Arduino UNO R3... 
//IDE:   Arduino-1.0
//Function: Rotate the potentiometer to adjust the LED brightness.

/*********************************************************************/
/*macro definitions of Rotary angle sensor and LED pin*/
#define ROTARY_ANGLE_SENSOR A0
#define LED 3//the SIG pin on the LED module is connected with D3 of Arduino/Catduino

#define ADC_REF 5//reference voltage of ADC is 5v
#define VCC     5    //the default value of VCC of the control interface is 5v
#define FULL_ANGLE 280//full value of the rotary angle is 280 degrees

void setup() 
{
	Serial.begin(9600);
	pinsInit();
}

void loop() 
{
	int degrees;
	degrees = getDegree();
	Serial.println("The angle between the mark and the starting position:");
	Serial.println(degrees);
	
	int brightness;
	/*The degrees is 0~280, should be converted to be 0~255 to control the*/
	/*brightness of LED */
	brightness = map(degrees, 0, FULL_ANGLE, 0, 255); 
	controlBrightness(brightness);
	
	delay(500);
}
void pinsInit()
{
	pinMode(ROTARY_ANGLE_SENSOR, INPUT);
	pinMode(LED,OUTPUT);
}

/*PWM control brightness                               */
/*If brightness is 0,the LED is off.                    */
/*The Greater the brightness, the brighter the LED.*/
/*The range of brightness is 0~255                      */
void controlBrightness(int brightness)
{
	analogWrite(LED,brightness);
}
/********************************************************************************/
/*Function: Get the angle between the mark on the potentiometer cap and the starting position	*/
/*Parameter:-void                                                                                                          */
/*Return:     -int,the range of degrees is 0~280                                                                 */
int getDegree()
{
	int sensor_value = analogRead(ROTARY_ANGLE_SENSOR);
	float voltage;
	voltage = (float)sensor_value*ADC_REF/1023;
	float degrees = (voltage*FULL_ANGLE)/VCC;
	return degrees;
}

Reviews

Er zijn nog geen beoordelingen.

Enkel ingelogde klanten die dit product gekocht hebben, mogen een beoordeling schrijven.

Verzending binnen Nederland

Dit product word bezorgd via PostNL pakketpost.
- € 6.95 verzendkosten voor orders onder de € 100,-.
- Orders boven de € 100,- worden gratis verstuurd.
- U kunt ook gebruik maken van pakjegemak. Meer info pakjegemak

  • Op werkdagen voor 16:30 uur besteld, zelfde dag verzonden!
    Klik hier voor de kosten buiten Nederland.
  • Product vraag?

      Uw naam (verplicht)

      Uw email (verplicht)

      Uw vraag