In this example the input analog signal is resistance. The circuit arrangement is given below.
As shown, the center pin of POT is connected to analog pin-0. Other two terminals are connected to 5V supply and ground. Digital port pin-13 is having in-build LED.
int sense_pin = A0; // Select the input pin for the potentiometer
int led_pin = 13; // Select the pin for the LED
int sensor_value = 0; // Variable to store the value coming from the sensor
void setup()
{
pinMode(led_pin, OUTPUT); // Declare the led_pin as an OUTPUT
}
void loop()
{
sensor_value = analogRead(sense_pin); // Read the value from the sensor
digitalWrite(led_pin, HIGH); // Turn ON the led_pin
delay(sensor_value); // Stop the program for milliseconds
digitalWrite(led_pin, LOW); // Turn OFF the led_pin
delay(sensor_value); // Stop the program for milliseconds
}
As shown, the center pin of POT is connected to analog pin-0. Other two terminals are connected to 5V supply and ground. Digital port pin-13 is having in-build LED.
int sense_pin = A0; // Select the input pin for the potentiometer
int led_pin = 13; // Select the pin for the LED
int sensor_value = 0; // Variable to store the value coming from the sensor
void setup()
{
pinMode(led_pin, OUTPUT); // Declare the led_pin as an OUTPUT
}
void loop()
{
sensor_value = analogRead(sense_pin); // Read the value from the sensor
digitalWrite(led_pin, HIGH); // Turn ON the led_pin
delay(sensor_value); // Stop the program for milliseconds
digitalWrite(led_pin, LOW); // Turn OFF the led_pin
delay(sensor_value); // Stop the program for milliseconds
}
No comments:
Post a Comment