Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Ultrasound sensor HC-SR04 Convert this Energia code for EK-TM4C123GXL launchpad to Code Composer #define echoPin PD_0 #define trigPin PC_4 #define BUTTON_PIN PF_0 void setup() {

Ultrasound sensor HC-SR04

Convert this Energia code for EK-TM4C123GXL launchpad to Code Composer

#define echoPin PD_0 #define trigPin PC_4 #define BUTTON_PIN PF_0

void setup() { // put your setup code here, to run once: Serial.begin(115200); pinMode(BUTTON_PIN, INPUT_PULLUP);

while (digitalRead(2));

pinMode(echoPin, INPUT); pinMode(trigPin, OUTPUT);

}

void loop() { // put your main code here, to run repeatedly: long duration, distance; digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = duration/50; if (distance > 255) { distance = 255; } //Serial.write(distance); Serial.println(distance); delay(50); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

Students also viewed these Databases questions

Question

Determine the roles of spatial layout and functionality.

Answered: 1 week ago

Question

Be familiar with the basic ways to manage capacity.

Answered: 1 week ago