int analogPin=A0;
int ledPin=9;
void setup() {
pinMode(analogPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}

void loop() {
int value=analogRead(analogPin);
Serial.println(value);
int ledValue=map(value,0,1023,0,255);
analogWrite(ledPin, ledValue);
delay(1000);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s