credit: www.likecircuit.com
Analog in
PWM pin out
Code
int BD139_Pin = 5; // LED connected to digital pin 9
int analogPin = A3; // potentiometer connected to analog pin 3
int val = 0; // variable to store the read value
void setup()
{
Serial.begin(9600);
// Serial.println("CLEARDATA");
pinMode(BD139_Pin, OUTPUT); // sets the pin as output
}
void loop()
{
val = analogRead(analogPin); // read the input pin
val=val/4;
analogWrite(BD139_Pin, val); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
// Serial.print("DATA,TIME,");
Serial.println(val);
delay(100);
}