Monday, April 19, 2010

Getting Alpha Kappa Alpha Recommendaction

Arduino: Reading pot and writing PWM

I've got a and an Arduino of the first examples I've done it: read by a pin Analog potentiometer value and assign that value to the PWM, thus, get the LED lights Turn off and as we vary the value of the potentiometer. The circuit is as follows:
(The image of the Arduino board is of the Wikipedia ). The circuit is very simple. Connecting the potentiometer to pin 5 of the analog inputs. We also placed an LED connected to Pin 9 (PWM) with a resistance that does not burn.
What I have done is to use the PWM to put 2 LEDs. The program is very simple too: 1 / * 2
Example using potentiometer and PWM 3 * / 4 5 6 ledPin int = 9 / / LED connected to digital pin 9 int
potnPin 7 = 5, / / \u200b\u200bread the potentiometer Pin
int value = 8 0;
9 10 void setup () {
11 pinMode (ledPin, OUTPUT); 12 pinMode (potnPin, INPUT) ; Serial.begin
13 (9600);
14} 15
16
void loop () {
17
value = analogRead (potnPin) / 4; 18
analogWrite (ledPin, value);
19 Serial.print (value, DEC);
    20
  • Serial.println ();}
21

0 comments:

Post a Comment