Computer Science, asked by prasun35, 8 months ago

code to run a servo motor with LEDs by the help of arduino.​

Answers

Answered by kunalboss49
2

I hope you are understand plz marks me as brainleast and thanks

WEB EDITOR

PROJECT HUB

DEVICE MANAGER

DIGITAL STORE

IOT CLOUD

SIGN IN

Innovation Lab #15 Servo Motor_RGB LED

Innovation Lab #15 Servo Motor_RGB LED © GPL3+

Bongilcheon High School_Innovation Lab Project.

arduino unoledmotorservo

2,589 VIEWS0 COMMENTS2 RESPECTS

COMPONENTS AND SUPPLIES

A000066 iso both

Arduino UNO & Genuino UNO

× 1

12002 04

Breadboard (generic)

× 1

Arduino Servo Motor

× 1

09264 1

RGB Diffused Common Cathode

× 1

APPS AND ONLINE SERVICES

Ide web

Arduino IDE

ABOUT THIS PROJECT

Innovation Lab (170823)

When the servo motor is 0 degrees, the LED turns green and when the servo motor turns 90 degrees, the LED turns red.

CODE

Servo Motor_ RGB LEDArduino

Servo Motor Turn_ RGB LED Color Change

#include <Servo.h>

Servo gol;

long distance;

int red = 3;

int green = 5;

int blue = 6;

void setup() {

gol.attach(9);

pinMode(red, OUTPUT);

pinMode(green, OUTPUT);

pinMode(blue, OUTPUT);

}

void loop() {

distance = 100;

top_open();

delay(2000);

distance = 20;

top_open();

delay(2000);

}

void top_open() {

if(distance < 30) {

gol.write(90);

digitalWrite(red, HIGH);

digitalWrite(green, LOW);

digitalWrite(blue, LOW);

}

else {

gol.write(0);

digitalWrite(red, LOW);

digitalWrite(green, HIGH);

digitalWrite(blue, LOW);

}

}

SCHEMATICS

Servo Motor_ RGB LED

Servo Motor_ RGB LED

15 2 xwcicwcrxe

Similar questions
Math, 11 months ago