Published on

Level 1 Solutions

Table of Contents

Assignment 1

Print your intro on the Serial Monitor.

void setup()
{
  Serial.begin(9600);  //Begin serial communication at 9600(Baud rate)
  Serial.println("Hi, I'm Bhavya Jain");  //Print text
  Serial.println("ID No- 2020A7PS0240H");
  Serial.println("I'm from Mumbai and my hobbies are reading, sports and robotics!");
}

void loop(){ }

You can see an example intro here.

Assignment 2

Swap the last two numbers of your ID. (Don't Hardcode swapped numbers)

void setup()
{
  Serial.begin(9600);

  //Initialize all variables
  int a = 0;
  int b = 2;
  int c = 4;
  int d = 0;

  //Print original ID number
  Serial.print("Original id no. is ");
  Serial.print(a);
  Serial.print(b);
  Serial.print(c);
  Serial.println(d);

  //Print last 2 numbers in reverse order
  Serial.print("Swapped id no. is ");
  Serial.print(a);
  Serial.print(b);
  Serial.print(d);
  Serial.print(c);
}

void loop(){ }

Try adding your ID number and check

Assignment 3

Make an H-bridge but instead of Motor, you have to use 2 LEDs.

  1. 1st LED should glow in one configuration &
  2. 2nd LED should glow in other configuration
void setup()
{
  pinMode(3, OUTPUT);  //Initialize the pins as output
  pinMode(4, OUTPUT);
}

void loop()
{
  digitalWrite(3, HIGH);  //1st configuration where 1st LED is on
  digitalWrite(4, LOW);
  delay(1500); // Wait for 1000 millisecond(s)
  digitalWrite(3, LOW);  //2nd(reverse) configuration where 2nd LED is on
  digitalWrite(4, HIGH);
  delay(1500); // Wait for 1000 millisecond(s)
}

You can simulate the H-Bridge here.