Laboratory # 3_ Analog Input
Laboratory # 3_ Analog Input
Objective: To create and simulate a simple Arduino application using Tinker cad simulation.
To be able to apply the principle of Input of Analog Device.
To be able to understand the concept of real-life application of programming.
Sample Code
int sensorValue = 0;
void setup()
{
pinMode(A0, INPUT);
pinMode(11, OUTPUT);
}
void loop()
{
// read the value from the sensor
sensorValue = analogRead(A0);
// turn the LED on
digitalWrite(12, HIGH);
// stop the program for the <sensorValue>
// milliseconds
delay(sensorValue); // Wait for sensorValue millisecond(s)
// turn the LED off
digitalWrite(12, LOW);
// stop the program for the <sensorValue>
// milliseconds
delay(sensorValue); // Wait for sensorValue millisecond(s)
}
Sample Layout
Code
int sensorValue = 0; // Variable to store the value from the sensor
void setup()
{
pinMode(A0, INPUT); // Set A0 as input for the potentiometer
pinMode(11, OUTPUT); // Set pin 11 as output for the LED
}
void loop()
{
// Read the value from the sensor
sensorValue = analogRead(A0);
Screenshot
Code, Circuit (Including Time and Date of the Desktop)