Arduino Functions with Variable DigitalWrite

I feel like I’ve been looking for a couple of years for this solution and could never find it. Well I worked it out for myself so I thought I should post it so the answer can be found for others as it really does seem to be complete undocumented online.

int redLed = 13; // assigning redLed with the onboard LED
int blueLed = 12; // assigning blueLed with offboard LED with resister

void setup(){
pinMode(redLed , OUTPUT); // set these pin as outputs for digital writes
pinMode(blueLed , OUTPUT); // set these pin as outputs for digital writes

void loop(){
ledBlinking(redLed, 6, 500, 100); // run function targeting the red LED
ledBlinking(blueLed, 12, 100, 100); // run function targeting the blue LED

void ledBlinking(word led, int amount, int timeOn, int timeOff){ // set the variables used between loop and function
for ( int i=1; i<=amount; i=i+1 ) { // for each i in amount run the below digitalWrite(led, HIGH); // bring the chosen pin high delay(timeOn); // wait the LED time on digitalWrite(led, LOW); // bring the chosen pin low delay(timeOff); // wait the LED time off } // loop back to i counter until over }

So hopefully you see what I'm doing here. I'm telling the function in void loop to use the pin redLed and blueLed with a word (not a string) variable. The rest are simple integers holding the amount of flashes, and how long to hold them on and off for.

Simple when you know how, now on to the bigger project.

ncftp & ghettovcb Working Together

I’m a bit chuffed with my scripting efforts in ESXi, so I thought I would share, I hope someone else might find this useful.

To give a bit of background, I run a VMWare Hypervisor ESXi server, it’s only a free license version single host, so most of the backup software doesn’t work that you can buy. But I have found an awesome script called ghettovcb that utilizes the snapshot and VM console commands to make VM running (and off) backups of my guest VMs. But obviously I want to get this data off the host, this is where ncftp comes in.

Now I found the code I needed to write to get all my machines backed up and transferred was crazy, and to get these two to work together.

Writing this, I’ve just thought I should code up all the commands into a single script file, maybe that’ll be next. But the below allows you to state a single VM’s backup folder, or a list with the “-f textfilewithvmsperline” command, which I’ve been able to use the same list from ghettovcb, so I know, if it’s backed up, it’ll be uploaded also.

Well, shout out if this has helped you.


#Where are a few things in your file structure
#The rest below shouldn't need changing

#Turn the firewall off, got this permanently set though it's hand to keep it in mind
#esxcli network firewall set --enabled false

#Check a VM name has been given, and advise if not.
if [ "$1" == "" ]; then
echo "Please enter the name of the VM you wish to upload..."
exit 1
# Check if a -f command has been issued, for a file list upload
if [ "$1" == "-f" ]; then
echo "Flag issued for VMs file list to upload, load these and process.."
UPLOAD=`cat $2`
#echo "$UPLOAD" && exit 0 #Debugging line to see the list before it is run, this is normally commented out
echo "Single named VM listed to upload, processing.."

#Okay lets get down to business and process this list or single VM
for I in $UPLOAD; do
#Identify the most recent backup files for the listed VM
echo "You've stated $I, looking up the most recent backup."
LASTBACKUP=`ls -Art $BACKUPS/$I | tail -n 1`

#Check if a location has been found.
if [ "$LASTBACKUP" == "" ]; then
echo "Results of the search have failed, please check the listed name and try again."
echo "The last backup location is $SHORTNAMEFORECHO/$I/$LASTBACKUP"
# Use this location and upload it to Icharus NAS
echo "Beginning upload of folder"

#Should be all done, suggesting so...
echo "Complete"

#Turn the Firewall back on
#esxcli network firewall set --enable true

Squeezing A Automanaged Drive

So I run MythTV, and when I rebuild/transferred all my recordings to my new server I gave it an extra 0.3TB space, giving it a total of 1.3TB. Well a few months on I’m regretting my decision.

So looking into deleting recordings, and then freeing the space seemed like a massive job, so instead I’ve written some code to consume hard drive space at a 1GB per 6 hours (4GB per day) to force the inbuilt recording management to delete the old recording faster for me.

Yeah okay it’ll take 3 months to make the space, but it only took me an hour to write this, compared to fighting for weeks with new recordings taking space that I’ve freed.

Hopefully it can help you too somewhere, if you’ve found and will use it shout out, be interesting to hear how it helped.


# This script is running daily to squeeze the myth storage group
# smaller so I can get it to fit on a 1TB HDD again.
# I really don't feel like myth really needs that much storage for recordings

CURRENTSIZE=$(ls -lt /mnt/storage/increasingfile | awk '{print $5}')
MAXSIZEGB=$(($MAXSIZE / 1073741824))
INCREMENTGB=$(($INCREMENT / 1073741824))



if [ "$CURRENTSIZE" -le "$MAXSIZE" ]
INCREASEGB=$(($INCREASE / 1073741824))
echo Increasing a further $INCREMENTGB GB totalling $INCREASEGB GB
fallocate /mnt/storage/increasingfile -l $INCREASE
echo "Script has hit $MAXSIZE ($MAXSIZEGB GB) maximium, stopping."

Windows 10 Connections Menu (too many VPN’s hiding Wifi’s)

Working in IT I have a lot of VPN’s and it’s been driving me crazy the way Windows 10 handles the connection menu. The reason I went to the menu was to connect my laptop to the internet, not select a VPN that wouldn’t even work.

The below isn’t quite as I wanted, but the Windows 8 menu brings purpose to the menu having the VPN’s in again, and being full hieght gives me that bit more space to see the Wifi APN’s again, so it’ll do.

Open regedit (WIN+R and type regedit.exe)
Navigate to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Control Panel\Settings\Network
Take ownership of the “Network” key/folder (right click, Permissions)
Select “Advanced” in the Permissions window
In the Advanced window, select “Change” where the owner field is (at the top of the window)
Type in your username and save your changes.
Close the advanced window
Now select “Administrators” in the security tab
Make sure “Full control” is selected, then apply changes
Now that’s done, double click “ReplaceVan”
Change it’s value to 2