Found 989 Articles for Software & Coding

Cyclic Redundancy Check (CRC) in Arduino

Yash Sanghvi
Updated on 24-Jul-2021 12:37:57

4K+ Views

CRC stands for Cyclic Redundancy Check (CRC). It is, in simple words, an algorithm used to detect errors in received messages. The idea is similar to parity, but this is much more robust.If a transmitter is sending a packet to a receiver, the transmitter will calculate a CRC code based on some polynomial calculations on the packet, and append it to the packet. The receiver will perform the same calculations on the packet, and check if the generated CRC matches the CRC that came in with the packet. If the two match, there were no errors introduced in the transmission, ... Read More

AVR libraries in Arduino – Introduction

Yash Sanghvi
Updated on 24-Jul-2021 12:18:20

687 Views

AVR libraries are developed by Atmel. You might be knowing that the microcontrollers used in most Arduino boards are Atmel microcontrollers (ATmega328P, ATmega2560, etc.). AVR libraries for several specific operations (sleep, time, etc.) already exist, and therefore, we may greatly benefit if we are able to import AVR libraries within Arduino. The good news is that we can!As per Arduino's website, "AVR libraries have the potential to greatly extend the Arduino language. The Arduino system is based on the avr-gcc compiler and makes use of the standard AVR libc libraries, which are open-source C libraries, specifically written for Atmel hardware, ... Read More

Watchdog timer in Arduino

Yash Sanghvi
Updated on 24-Jul-2021 12:14:23

6K+ Views

A watchdog timer is an essential part of any microcontroller. It resets the program if the program gets stuck anywhere. Very briefly, this is how the watchdog timer works −The timer keeps incrementing.The program has to ensure that it keeps resetting the timer, i.e. does not allow it to overflow.If the timer overflows, it means that the program was stuck somewhere and therefore was unable to reset the timer. An interrupt is generated on timer overflow which resets the microcontroller.To implement watchdog timer in Arduino, we use the avr wdt library.The code is given below −#include void setup() {   ... Read More

tone() and noTone() in Arduino

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

5K+ 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

How to get the file extension using PowerShell?

Chirag Nagrekar
Updated on 17-May-2021 13:12:57

8K+ Views

We can retrieve the file extension using multiple ways. First, using the [System.IO.Path] class.PS C:\> [System.IO.Path]::GetExtension("C:\temp\25Aug2020.txt") .txt PS C:\> [System.IO.Path]::GetExtension("C:\temp\azcopy.zip") .zipThis is the easiest way to get the file extension. Otherways, Using programmatically, PS C:\> ((Split-Path "C:\Temp\azcopy.zip" -Leaf).Split('.'))[1] zip PS C:\> ((Split-Path "C:\Temp\25Aug2020.txt" -Leaf).Split('.'))[1] txtUsing Get-ChildItem, PS C:\> (Get-ChildItem C:\Temp\azcopy.zip).Extension .zip PS C:\> (Get-ChildItem C:\Temp\25Aug2020.txt).Extension .txtUsing Get-Item, PS C:\> (Get-Item C:\Temp\azcopy.zip).Extension .zipRead More

How to copy files of the specific extension using PowerShell?

Chirag Nagrekar
Updated on 17-May-2021 12:38:39

1K+ Views

To copy the files using the specific files extension using PowerShell, we can use the Copy-Item command.The below command will copy only the .ps1 files from the source to the destination.For example, PS C:\> Copy-Item -Path C:\Temp -Recurse -Filter *.ps1 -Destination C:\Temp1\ -VerboseIf the C:\Temp1 doesn't exist, it will create the destination folder and then copy the content of the file but the problem with this command is it copies the subfolders as well which doesn’t have the .ps1 file.So to copy the with the same folder structure without empty directories and the specific file extension we can write the ... Read More

How to get the disabled local user accounts using PowerShell?

Chirag Nagrekar
Updated on 17-May-2021 12:37:12

1K+ Views

To get the disabled local user accounts using PowerShell on the local and the remote system, we can use the WMI or the CIM instance method with the Win32_UserAccount class and the Disabled property to filter the result.PS C:\> gwmi win32_useraccount | where{$_.Disabled -eq $true}You can filter out the properties using the specific properties use the Select-Object pipeline command.PS C:\> gwmi win32_useraccount | where{$_.Disabled -eq $true} | Select Name, FullName, CaptionYou can also use the CIM instance method alternatively, PS C:\> Get-CimInstance win32_useraccount | where{$_.Disabled -eq $true}To get the disabled accounts on the remote systems, use the -ComputerName parameter in ... Read More

How to find the locked local user accounts using PowerShell?

Chirag Nagrekar
Updated on 17-May-2021 12:48:43

1K+ Views

To get the locked user accounts on the local or the remote machines using PowerShell, we can use the wmi method.PS C:\> gwmi win32_useraccount | where{$_.Lockout -eq $true}You can also use the CIM instance method alternatively.PS C:\> Get-CimInstance Win32_Useraccount | where{$_.Lockout -eq $true}To get the locked local user accounts on the remote computer, you can use the -ComputerName parameter in the WMI class or the CIM instance. For example,PS C:\> gwmi win32_useraccount -ComputerName TestMachine1, TestMachine2 | where{$_.Lockout -eq $true}

How to set the local user account settings using PowerShell?

Chirag Nagrekar
Updated on 17-May-2021 12:51:03

2K+ Views

To set the local user account settings related to the account or the password expiration, we can use the Set-LocalUser command.The below command will change the local user Testuser account and password set to never expire.Set-LocalUser -Name Testuser -AccountNeverExpires -PasswordNeverExpires $true -VerboseThe below command will set the account expiry,Set-LocalUser -Name Testuser -AccountExpires 05/11/2022 -VerboseTo run the above commands on the remote computers, use the Invoke-Command.Invoke-Command -ComputerName Computer1, computer2 -ScriptBlock{ Set-LocalUser -Name Testuser -AccountNeverExpires -PasswordNeverExpires $true -Verbose } Invoke-Command -ComputerName Computer1, computer2 -ScriptBlock{ Set-LocalUser -Name Testuser -AccountExpires 05/11/2022 -Verbose }

How to change the local user account password using PowerShell?

Chirag Nagrekar
Updated on 17-May-2021 13:39:09

10K+ Views

To change the local user account password using PowerShell, we can use the Set-LocalUser command with the Password parameter. This password parameter should be in the secure string. So we need to ask the user to input the password as a secure string or need to explicitly convert the plain text password to the secure string. For example, $localuser = Read-Host "Enter Local UserName" $password = Read-Host "Enter local user account password " -AsSecureString Set-LocalUser -Name $localuser -Password $password -VerboseIf you need to set the password without asking the user prompt then you need to convert the plain text password ... Read More

Advertisements