Skip to main content
Editing Step 3 —

Step Type:

Drag to rearrange

At the tippity top of the code before the set-up or Serial.begin(9600) is where variables are defined. They need to be defined so when they are in a function, the computer will know what the variables means. The variables necessary for this sensor are...

const int trigPin=11;

const int echoPin=12;

long duration;

int distance1;

float oldvalue=0;

float newvalue=0;

Your contributions are licensed under the open source Creative Commons license.