14. Interface and Application Programming
Task of Interface and Application Programming
Group assignment:
- Compare as many tool options as possible.
- Document your work on the group work page and reflect on your individual page what you learned.
Individual assignment
- Write an application for the embedded board that you made. that interfaces a user with an input and/or output device(s)
Summary

#define LED_PIN D0
#define TRIG D1
#define ECHO D2
void setup() {
Serial.begin(115200);
pinMode(TRIG, OUTPUT);
pinMode(ECHO, INPUT);
pinMode(LED_PIN, OUTPUT);
Serial.println("READY");
}
void loop() {
if (Serial.available()) {
String command = Serial.readStringUntil('\n');
command.trim();
if (command == "ON") {
digitalWrite(LED_PIN, HIGH);
Serial.println("LED ON");
} else if (command == "OFF") {
digitalWrite(LED_PIN, LOW);
Serial.println("LED OFF");
} else if (command == "SCAN") {
digitalWrite(TRIG, LOW);
delayMicroseconds(2);
digitalWrite(TRIG, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG, LOW);
long duration = pulseIn(ECHO, HIGH);
int distance = duration * 0.0343 / 2;
Serial.print("DISTANCE:");
Serial.println(distance);
}
}
}




Download files
Here are source code files for Ultrasonic and PIR Sensors
HTML, CSS and java code Arduino code