Education

Education

Education

SMD LEDs

Robo Explorers


SMD or surface mounted devices are the components which are placed and soldered on the surface of the PCB instead of going through holes.
This saves much space, drilling energy and much more.

They are exactly the same as the regular LEDs we worked with in the Yellow Tyro Board.

In the Blue Elixir Board we have the SMD LEDs to work as outputs for the ultrasonic sensor.

Normally only a few out of the five leds activate. This indicates that objects are far away from the sensor. As the LEDs progressively activate, the detected objects come closer.

Check out the code :



#define ledPin1 4 //THE GREEN SMD LED IS CONNECTED TO D4
#define ledPin2 5 //THE BLUE SMD LED IS CONNECTED TO D5
#define ledPin3 6 //THE PURPLE SMD LED IS CONNECTED TO D6
#define ledPin4 7//THE YELLOW SMD LED IS CONNECTED TO D7
#define ledPin5 8//THE RED SMD LED IS CONNECTED TO D8


void setup() {
  Serial.begin(9600);
 //ALL THE LEDs ARE SET TO BE OUTPUT
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
  pinMode(ledPin5, OUTPUT);

}

void loop() {

  if (distance <10){ // IF THE DISTANCE OF THE OBJECT IS LEsS THAN 10cm THEN ALL LEDS ARE ACTIVATED
    digitalWrite(ledPin1, HIGH);
    digitalWrite(ledPin2, HIGH);
    digitalWrite(ledPin3, HIGH);
    digitalWrite(ledPin4, HIGH);
    digitalWrite(ledPin5, HIGH);
  }

  if (distance >10 && distance<40 ){ // IF THE DISTANCE OF THE OBJECT IS IN BETWEEN 10cm and 40cm THEN only 3 LEDS ARE ACTIVATED
    digitalWrite(ledPin1, HIGH);
    digitalWrite(ledPin2, HIGH);
    digitalWrite(ledPin3, HIGH);
    digitalWrite(ledPin4, LOW);
    digitalWrite(ledPin5, LOW);
  }

  if (distance >40){
    digitalWrite(ledPin1, HIGH);// IF THE DISTANCE OF THE OBJECT IS BEYOND 40cm THEN only 1 LED is ACTIVATED
    digitalWrite(ledPin2, LOW);
    digitalWrite(ledPin3, LOW);
    digitalWrite(ledPin4, LOW);
    digitalWrite(ledPin5, LOW);
  }

}

Learn from a Professional

Book a Class

Socials

info.jumplabs@gmail.com

Call Us

+4550142069

+919560372931

Damgade 82, 6400 Sønderborg

© Jumplabs Inc. 2023

Reach out to Us

Socials

info.jumplabs@gmail.com

Call Us

+4550142069

+919560372931

Damgade 82, 6400 Sønderborg

© Jumplabs Inc. 2023

Reach out to Us