O LEVEL practical exam questions in internet of things-and-its-applications

 Question - 1 [ O Level JUL-2022]

Arduino program to Blink a Light Emitting Diode LED

Solution:

Write a program using Arduino to Blink a Light Emitting Diode (LED). Also describe the connections used in a circuit with the Arduino Uno development board.

Components Needed:

Arduino Uno

LED

Resistor (for LED current limiting)

Circuit Connections:

Connect the cathode (shorter leg) of the LED to the digital pin 13 on the Arduino.

Connect the anode (longer leg) of the LED to the ground (GND) on the Arduino.

void setup() { pinMode(LED_BUILTIN, OUTPUT); } void loop() { // turn the LED on (HIGH is the voltage level) digitalWrite(LED_BUILTIN, HIGH); delay(1000); // Wait for 1000 millisecond(s) // turn the LED off by making the voltage LOW digitalWrite(LED_BUILTIN, LOW); delay(1000); // Wait for 1000 millisecond(s) }

Output/ Explanation:

Question - 2

Arduino program to fade the led bulb using for loop

Solution:Arduino Code to fade the Lead Bulb using for loop

Write a Arduino Code to fade a LED bulb using For loop and repeat the Process

void setup()
{
 // pinMode(10, OUTPUT);
  //to analogWrite
}
void loop()
{
  for(int a=0;a<=255;a++)
  {
 	 analogWrite(10,a);
  	 delay(10); // Wait for 10 millisecond(s)
  }
  for(int a=255;a>=0;a--)
  {
  	analogWrite(10, a);
  	delay(10); // Wait for 10 millisecond(s)
  }
}
Output/ Explanation:

In digitalWrite() we can write only HIGH and LOW but if we want to write some other values means between 0 to 1 the we need to analogWrite. when we use analogWrite() the we don't need to set pinMode()




Post a Comment

Previous Post Next Post