User manual

Ausgabe 19.05.2017 Copyright by Joy-IT 16
int potpin=0; // inialises analog PIN 0
int ledpin=11; // inialises digital PIN 11 (PWM output)
int val=0; // saves the value of the sensor
void setup()
{
pinMode(ledpin,OUTPUT); // sets digital PIN 11 to output
Serial.begin(9600); // sets baudrate to 9600
}
void loop()
{
val=analogRead(potpin); // reads analog value and assigns it to „Val“
Serial.println(val); // shows „Val“ value
analogWrite(ledpin,val/4); // turns on LED and assigns brightness
//(maximum PWM output is 255)
delay(10); // waits 0,01 seconds
}
Aer transferring the code, we can noce the
value changing by moving the potenometer.
We can also noce the brightness of the LED
changing.