Browse our Blog. You will find multiple applications, solutions, code examples. Navigate using the tag cloud or search using specific criteria

Function to calculate a square root of a number


Introduction

The function to calculate a square root of a number is sqrt().


Requirements

Ethernet or 20 I/Os PLC:      Ethernet PLC     20 I/Os PLC    

Industrial Shields boards:   Industrial Shields Boards


Function

sqrt(x);


Parameter

x: could be any data type 


Example

Next it is showed a simple example of how to print a square root of an analog value every second.

long number = 0;

void setup() {
  Serial.begin(9600L);
}

void loop() {
  number = sqrt(analogRead(I0_7));
  Serial.println(number);
  delay(1000);
}

Do you want more information?

Open Source technology allows you to develop your installations.

Just fill the form and we will contact you as soon as we can.

Send