Question: Could someone please tell what programming language this is? and also comment to the side for functions of each code. Thanks a lot. #include Servo

Could someone please tell what programming language this is? and also comment to the side for functions of each code. Thanks a lot.

#include

Servo myservo;

const int servo = 9;

const int button = 12;

const int ledPin = 13;

const int pingPin = 7;

const int BowlFull = 5;

int buttonVal = false;

void setup() {

Serial.begin(9600);

myservo.attach(servo);

}

void loop() {

long duration, inches, cm;

pinMode(pingPin, OUTPUT);

digitalWrite(pingPin, LOW);

delayMicroseconds(2);

digitalWrite(pingPin, HIGH);

delayMicroseconds(5);

digitalWrite(pingPin, LOW);

pinMode(pingPin, INPUT);

duration = pulseIn(pingPin, HIGH);

// convert the time into a distance

inches = microsecondsToInches(duration);

cm = microsecondsToCentimeters(duration);

buttonVal = digitalRead(button);

if(buttonVal == LOW) {

if (cm > BowlFull) {

//if (inches > BowlFull) {

myservo.write(30);

delay(2000);

myservo.write(180);

delay(2000);

}

}

Serial.print(inches);

Serial.print("in, ");

Serial.print(cm);

Serial.print("cm");

Serial.println();

delay(100);

}

long microsecondsToInches(long microseconds) {

return microseconds / 74 / 2;

}

long microsecondsToCentimeters(long microseconds) {

return microseconds / 29 / 2;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!