PulseIn and PulseInLong in Arduino

Yash Sanghvi
Updated on 30-Jul-2021 12:50:29

3K+ Views

If there is an incoming pulse on a pin, and you need to measure the duration of the pulse then the pulseIn() function comes in handy.SyntaxThe syntax is −pulseIn(pin, value)Where pin is the number of the pin on which you wish to measure the pulse. The value is the level of the pulse. It can be HIGH or LOW.For example, if you set the value to HIGH, it means that as soon as the voltage on the pin goes from LOW to HIGH, the measurement of the time will start. It will stop when the voltage on the pin goes ... Read More

Tone and NoTone in Arduino

Yash Sanghvi
Updated on 30-Jul-2021 12:45:59

6K+ Views

The tone function can be used to generate a square wave (50% duty cycle) of a specific frequency on a pin.SyntaxThe syntax is −tone(pin, frequency)pin is the pin number on which to generate the tone. The frequency is specified in Hz.This function can also take in a third optional argument − the millisecond duration for which the tone should be generated on the pin.tone(pin, frequency, duration)If you don’t specify the duration, the tone will continue till the noTone() function is called on the same pin. The syntax of the noTone() function is −noTone(pin)where pin is the pin number on which ... Read More

Read Contents of a File in Golang

Rishikesh Kumar Rishi
Updated on 30-Jul-2021 09:44:00

1K+ Views

pre.prettyprint{width:99%!important;} a.demo{top:12px!important; float:right!important;}To read the contents of a file, we can take following steps −We can create a file called test.txt.Clean-up using defer statement.Write the contents of string.Call ReadFile() method to read the file.ReadFile reads the file named by filename and returns the contents.Print the content of the file.Example Live Demopackage main import (    "fmt"    "io/ioutil"    "log"    "os" ) func CreateFile() {    file, err := os.Create("test.txt")    if err != nil {       log.Fatalf("failed creating file: %s", err)    }    defer file.Close()    _, err = file.WriteString("Welcome to Tutorials Point")    if err ... Read More

Set LD_LIBRARY_PATH Environmental Variable in Linux

Mukul Latiyan
Updated on 30-Jul-2021 09:18:06

6K+ Views

There are plenty of ways in which we can set an environment variable in Linux and then make use of it later. Some ways provide us access to that variable in a particular window, in other cases, we can get access to those variables in every terminal window and in a permanent manner.Let’s explore setting a new environment variable on an Ubuntu machine and then we can talk about setting the LD_LIBRARY_PATH.In order to set a new environment variable, follow the commands shown below in sequence.Command 1Open your bash-profile with the command shown below −vi ~/.bashrcCommand 2Make use of the ... Read More

Set a Proxy for Wget on Linux

Mukul Latiyan
Updated on 30-Jul-2021 09:17:16

769 Views

Wget is a Linux command line utility that is used to retrieve files from World Wide Web(WWW) and makes use of protocols like HTTPS and FTP. It is a freely available package and can be downloaded and installed on any Linux supporting architecture.One of the key features of wget is its ability to automatically start downloading where it was left off in case there is a network issue. It should also be noted that it deletes files recursively and it will keep trying to download all the files until it has been retrieved completely.Installing wgetFor Ubuntu/Fedorasudo apt-get install wgetFor Mac ... Read More

Top Processes Sorted by Actual Memory Usage on Linux

Mukul Latiyan
Updated on 30-Jul-2021 09:16:08

446 Views

Linux provides the famous top command utility that provides us with all the information about the processes, their time, their respective IDs, how much CPU chunk they are consuming and much more. The only issue with that is the processes are not sorted in any order and the order changes frequently.There are certain cases where we would like the output to be in a sorted manner somehow, like sorted in the sense that the process which is using the most memory will be at the top.The most basic approach is to make use of the ps command that Linux provides ... Read More

Search Contents of Multiple PDF Files on Linux

Mukul Latiyan
Updated on 30-Jul-2021 09:12:58

2K+ Views

The pdfgrep command in Linux is used to filter searches for a particular pattern of characters in a PDF or multiple PDFs. It is one of the most used Linux utility commands to display the lines that contain the pattern that we are trying to search.Normally, the pattern that we are trying to search in the file is referred to as the regular expression.Installing Pdf grepFor Ubuntu/Fedorasudo apt-get update -ysudo apt-get install -y pdfgrepFor CentOSyum install pdfgrepSyntaxpdfgrep [options...] pattern [files] While there are plenty of different options available to us, some of the most used are −-c : counts the ... Read More

Run Crontab Job Every Week on Sunday

Mukul Latiyan
Updated on 30-Jul-2021 09:11:47

893 Views

In order to create a crontab job to run every Sunday, we first need to explore and understand what a crontab job is.A crontab is nothing but a list of commands that we can run during a cron job. A cron job is a utility that schedules automatic execution of commands at specific times.We can start a cron job with the help of bash script by following the commands shown below −crontab -eThis will open a file which you can edit, insert the cron job shell script in the above file and then close that file.Just insert the code shown ... Read More

Resume Partially Transferred File Over SSH on Linux

Mukul Latiyan
Updated on 30-Jul-2021 09:10:50

892 Views

There is always a scenario where we sometimes encounter the transfer of files to be broken because of some reason. The reasons could be different, unless it is not that you explicitly closed the particular connection or process, it can be recovered.It should also be noted that the scp command doesn’t have a resume option, and the only option is to simply start copying the files from the beginning and overwrite the existing files. The process of doing this again and again because of the ssh disconnection can be very annoying and time consuming.Linux does provide us with a command ... Read More

Replace Spaces in File Names Using Bash Script on Linux

Mukul Latiyan
Updated on 30-Jul-2021 09:09:51

605 Views

Consider a case in which one directory on my local machine looks something like this −immukul@192 dir1 % ls -ltr total 0 -rw-r--r-- 1 immukul staff 0 Jul 3 20:44 sample code.txt -rw-r--r-- 1 immukul staff 0 Jul 3 20:44 sample code with love.txtIn the above directory named dir1, there are two .txt files present and both these files have spaces in between the words in their name, and we need to replace these spaces using a bash script on Linux.In order to achieve what we want, we must first be aware of the fact that we can traverse the ... Read More

Advertisements