Web Development Tools

I’ve been a web developer for well over 20 years now and I figured it is about time I started a page with links to all of the best web development tools that I’ve created over the years. Here it is! I will add links to various tools I’ve made as I find them or create them. These are all tools I’ve made to assist web developers with a wide range of tasks including server administration, troubleshooting and automation tools.

PHP Developer

I am an expert PHP Developer with going on 20 years of experience programming with PHP for the web. I have my own unique style and prefer the procedural programming method rather than object oriented programming when it comes to most web development projects. I perform a very wide range of PHP tasks including:

  • PHP websites
  • PHP business applications
  • PHP mobile apps
  • PHP desktop applications
  • WordPress PHP coding
  • Content Management Systems in PHP
  • PHP testing procedures
  • Dynamic PHP website integrations
  • HTML to PHP conversions
  • Anything else done in PHP, just ask!

Object Oriented PHP vs. Procedural PHP

Unless a project requires object oriented PHP code, I normally don’t use it because, in my opinion, procedural code is simpler and easier to work with when it comes to websites. Object oriented PHP is great when it is needed, but often times it is more than what is needed and causes code bloat which is not good for any website because it slows it down and makes it more difficult to work with. In short, unless specified otherwise, I will use procedural PHP code.

 

My Personal PHP Programming Style

Everyone has their own style when it comes to programming. My style is unique because I was not taught in a formal education setting. I am completely self-taught. I believe that allows me to think outside of the box and enables me to get many projects done that others simply couldn’t complete. In fact, in some circles, I am known as the go-to guy to use when someone else tells them that something can’t be done.

I am a minimalist. I believe in getting a job done with the least amount of code possible. This style makes a website easier to work on and allows the site to run faster in most cases.

Keep it simple. I like to keep my code as simple as possible without including extra features and unwanted add-ons because not only were they not asked for by my client, the client would have to pay for them as well, so no surprises working for me, you get what you pay for and don’t pay for things you didn’t want.

Complete WordPress Services

If you need anything done in WordPress and are looking for an expert in everything related to WordPress, look no further! You’ve found me. I especially enjoy a challenging WordPress project. I love doing things with WordPress that have never been done before or things others say can’t be done with WordPress. Instead of making an exhaustive list of everything I can do with WordPress, I’d like to assure you that I can do anything with WordPress and provide you with a short list of my WordPress specialties:

  • WordPress Theme Development
  • WordPress Plugin Development
  • Custom WordPress Design
  • WordPress Core Alterations
  • WooCommerce integration with WordPress
  • Complete WordPress Blogs
  • eCommerce WordPress Websites
  • WordPress Multi-site Networks/WordPress MU
  • Anything else related to WordPress

While I do specialize in working closely with WordPress clients, I also do a lot of work using PHP, HTML, JavaScript, MySQL databases and many other web-based technologies and business applications. I also do Mobile apps for both iPhone and Android devices.

For a quick, free estimate, email me now at linian11@yahoo.com or use the contact link in the main navigation bar of this webpage for more ways to get in touch with Ian, L., the lead developer of Jafty Interactive Web Development.

Basic Stamp 2 voltage Detector

This is part of my Smart Home series available exclusively on Jafty.com, Jafty Interactive Web Development’s service site. It is part of a series I am writing while building my own smart home out of a home I purchased in Akron, Ohio. The premise is that I have used a micro-controller(Basic Stamp 2) device to link a laptop PC to several electrical objects around my home. I now have it so there are battery powered LED lights in every room of the house and they can be turned on and off using a computer which the Basic Stamp 2 micro-controller is plugged into. The lights and battery also link to the micro-controller. The micro-controller serves as a medium between the PC, battery, lights, etc.

The system works good, but I thought for the home to be truly “smart”, it should also know the voltage of the battery banks used throughout the home to power different objects(batteries are currently charged using a small 900 watt gasoline generator). This article is about how to build a voltage monitoring device that uses a Basic Stamp 2 micro-controller to check the voltage of a battery and report it on the computer screen it is connected to.

How to build a Voltmeter Circuit for Basic Stamp 2

 

Here is a schematic of the voltage meter circuit for the Basic Stamp 2 I drew using Open Office Draw:

Voltmeter-circuit

The above  schematic contains a small modification I made to the resistance. Adjusting the resistance of the 690k ohm resistor adjusts the voltage value. Adding more resistance lessens the value of the voltage read, so you can add or subtract to it as needed to fit your requirements.  Basically what we have is a 470 ohm resistor(r1) coming off of one of the io pins on the Basic Stamp 2(BS2-io-pin). The other end of the resistor(r1) attaches to the positive leg of a 0.02 uf film capacitor(c1). Then attached to the same positive leg is a 600k ohm resistor(r2) and this is the positive lead used for checking voltage on the positive side of the battery to be tested. Coming off of the other, negative lead of the capacitor(c1), is a wire going to the vss ground on the Basic Stamp 2 micro-controller. Finally another wire lead comes off of the Basic Stamp 2 vss ground to go to the negative terminal of the battery or device to be tested for voltage. Here are the values of the required components summarized:

  • r1 = 470 ohm
  • r2 = 690k ohm
  • c1 = 0.02 uf micro film capacitor(the green ones)

As you can see, the circuit for testing voltage is very simple and we all know that testing voltage is not quite considered simple. There can be analog to digital conversion integrated circuits used and many other more complex components, but this is a very simple circuit made possible due to the use of the Basic Stamp 2 micro-controller and it’s rc time ability. Therefore, the program we need to run is not quite as simple as the circuit, but is still very easy and this is by far the easiest way I could find to accurately check DC voltage and report the results on my PC. Next, we’ll cover how to write a program in pbasic to put onto the Basic Stamp 2 in order to check voltage with the circuit outlined above.

PBasic Code to Check Voltage Using Basic Stamp 2

‘ {$STAMP BS2}
‘ {$PBASIC 2.5}

rct VAR Word  ‘RCtime value
Vx VAR Word  ‘calculated voltage (this will = applied voltage Vx)
Cn1 CON 48576  ‘first constant, see below
Cn2 CON 8  ‘second constant used below
‘ circuit attached to Pin 0
LOW 0
TheLOOP:
RCTIME 0,0,rct
LOW 0
Vx=Cn1 / rct + Cn2
DEBUG HOME,DEC? rct,”Vx= “, DEC Vx/10,”.”,DEC1 Vx
PAUSE 500
GOTO TheLOOP

As you can see, the above code may look a little complicated, but it is as short and sweet as you will find when it comes to code to check voltage using a micro-controller. I promise you, this is the simplest way to check DC voltage using a Basic Stamp 2 micro-controller. Also we need to report that voltage to a computer running Windows 7 or 8. This turned out to be a challenge that took me several hours to overcome, but not to worry, I’ll share my ultimate solution with you next.

How to send Data from Basic Stamp 2 to a Windows 7 or 8 PC and Present to Screen

The basic challenge for me was: How do I get the voltage value from the Basic Stamp 2 to a web page running on my Windows 7 PC using XAMPP for Windows? The main issue seemed to be that Windows computers running either windows 7 or above don’t allow a scripting language such as PHP to read data from serial ports. I found that I was very easily able to write data to the Basic Stamp 2 micro-controller from Windows 7 using PHP and the fopen/fput commands and similar methods. However, while I was able to open a connection using PHP’s fopen command, I was not able to read data from the serial port using PHP at all. I tried almost every possible method I could find and nothing worked. That was very aggravating to say the least! I ended up finding a method that worked if you first wrote something to the serial port and then read it after a 1 second pause. This is the only way that would allow me to read data from a serial port using Windows 7 and PHP. Below is the function I used. It writes a “v” to the stamp micro-controller first which is used to ask for a voltage reading. Then it reads and parses the response from the serial port.

<?php

//this file is included in ControlLights.php to show voltage
function getSerialData($port){
‘mode $port: BAUD=9600 PARITY=N data=8 stop=1 xon=off’;
$fp = fopen ($port.”:”, “r+”);
if (!$fp) {
echo “ERROR! COM3 Port failed to open.“;
} else {
//send command to get voltage from stamp(cannot read data from serial without using fputs first for some reason!)
fputs ($fp, “v”);
sleep(1);
//get serial data:
$response = fread($fp,19);
//echo “response: $response”;//NOTE: this produced text before voltage, so I parsed it out below:
$resparr = explode(“volts:”,$response);
$voltage = $resparr[1];
echo “$voltage Volts“;
fclose ($fp);
}
}//end function.
getSerialData(“COM3”);
?>

I included the above PHP file within the web page that I wanted to show the voltage on and it worked perfect! To view the whole thing, see my tutorial on controlling lights which includes the above script in the ControlLights.php file to show the battery voltage on screen in the app I use to turn lights and appliances in my home on and off.

 

Bleach, Sulfuric Acid or Hydrogen Peroxide for Battery Electrolyte

In my ongoing quest to build the perfect home made battery, today I am testing to find the best electrolyte. To-date I have tried water, salt water, bleach and combinations of the three. So far, with only testing bleach, water and salt, pure bleach has proven to be the best electolyte, but I have a feeling that’s going to change as soon as I do this test with Sulfuric acid. Sulfuric acid is what car batteries, lead-acid batteries, are made with. In fact the sulfuric acid I am using to test with was purchased for about $30USD from Napa Auto Parts as “Battery Fluid, Acid”. That’s what it says on the 5 gallon box I purchased today.

Test Specifications

Here are the standards used during this test:

  • Electrodes – one copper and one aluminum. I used 1/2 copper pipe about 2 inches long and an aluminum strip that was about 2 inches long by 1 inch wide.
  • container – 1.5 ounce plastic reservoirs. I used 8 compartment plastic Popsicle trays bought from Dollar General for a buck.

Test Results

Using bleach as an electrolyte:

  • Voltage – 1.14 volts after about ten minutes.
  • Amperage – 12.00 ma roughly using the ma setting and 20m(not the 10amp setting) after about ten minutes. Note that I’m not sure that when not on the 10amp setting that a reading of 12.00 is actually 12 ma.

Using Sulfuric Acid as an electrolyte:

  • Voltage – 0.45 volts right away and ten minutes later I got 0.65 volts.
  • Amperage – 14.01 right away and ten minutes later amps were reading over what could be read using the red lead on the ma setting, so moved it over to the 10am setting and set the meter dial to 10 amp also getting a reading of 0.02amps which is approximately 3 times more than the bleach produced.

Using Hydrogen Peroxide as an electrolyte:

  • Voltage – 0.45 right away and ten minutes later I got 0.62 volts.
  • Amperage – right away I had to go to the normal 10amp setting on the dial and the red lead and got a reading of 0.02amps which was the same as using acid after ten minutes. After ten minutes time I got a reading of 18.02 ma using the ma setting for the read lead and the dial turned to 20m.

The Test of Time

The next thing that is important to me is that the electrolyte lasts a good amount of time. So far, I’ve tested a pure bleach battery and it ran for 3-5 days before crapping out because of too much corrosion on the terminals and there was from 1/4 inch to 1/2 inch of sediment in the bottom of the 1.5 ounce containers used for ea. cell.

I will have to report back regarding the Sulfuric Acid and Peroxide results. Coming soon!

 

Conclusion

The bad news is that I spent $30 on Sulfuric Acid when bleach seems to work better so far. With eight cells in a series, I was only getting up to 4 volts about an hour after wiring the battery. Using the same battery with bleach, I was getting 10-12 volts DC, so bleach is the clear winner here thus far. I’m still waiting for the results of time on the Acid battery and peroxide battery cells.

How to test a 9 volt Battery with a Multimeter

I took some quick lessons in volts, amps and resistance of common battery types over the past few months in order to be properly educated for building many components for my smart home project. I am sharing some of the more important lessons on battery testing here for my own reference and others to learn by.

How to test a 9 Volt Battery

Here I describe how to test a regular 9 volt square type battery typically used in smoke detectors and small transistor radios. Yes, the typical battery most of us think about when we hear the term “9 volt battery”

Testing volts.

To test the output voltage of a typical 9 volt battery, simply set your volt meter to DC current and set the voltage at 20 volts or the closest setting to it. Applying the red lead to the positive or smaller round terminal of the battery and the black lead to the negative larger round lead of the battery should get you a reading of between 8 and 9.5 volts on a decent 9 volt battery with some life in it. THIS IS NOT GOOD ENOUGH to tell if the battery is really good however! If it is below 7 volts, you can be pretty sure that the battery is not much good anymore.

If the 9 volt battery measured 7 volts or above, then you should do a very quick short circuit amperage test to see that the short circuit current is sufficient as well. This is a true test to determine that the battery has life left in it. It is possible that a battery could give you a strong 9 volt reading using the simple voltage test just described, but still be dead for all practical purposes. If the battery is old or has bad resistance, it could still be bad and show a high voltage reading of 7 to 9 volts. To eliminate this possibility, follow these steps carefully and only if your multimeter has a 10amp setting.

Steps to testing the short circuit current of a battery

  1. Make sure the black lead is plugged into the com port of the multimeter as usual.
  2. Plug the red lead into the 10amp port that is the opposite port used for testing voltage as described above.
  3. Set the dial to the 10 amp position.
  4. hold the red lead to the positive terminal of the battery and then quickly touch the black wire to the negative lead just long enough to take a reading and that reading will be your short circuit reading. If your reading while the multimeter is in the 10amp position is between 0.05 and 0.50 amps, then your battery has some life in it. Obviously, if it’s closer to 0.05 or less, then it doesn’t have much life. When I tested a brand new cheap 9 volt battery, it had 0.5 amps, so a good brand name battery would probably be much higher, but this range gives you a pretty good idea of the working range of a nine volt battery because even the battery that held only 0.05 amps would still power a 12 volt rated bank of of 3 LED lights. Probably not for long, but it did work.

Note: while a more accurate reading can be achieved by holding the two leads onto the battery for a longer period of time, it is counter-productive because you will also be destroying the battery and in some cases even endangering yourself and others near by, so be careful and do any of the exercises on my blog 100% at your own risk! I claim no liability what-so-ever! If you don’t want to risk it, don’t.

How to Make Batteries at Home

This is intended to be the beginning of a series of posts about making batteries from home. It is going to include a series of test in order to determine the best types of home made batteries to use to power my home. The basic objective is to make a battery bank large enough to power several 12 volt lights and appliances throughout my home. I don’t intend to power any large appliances yet, however that may be a goal for the future. For now, my intention is to be able to power at least  enough lights for up to 5 rooms, two internet routers(a cable modem and a wireless router), a 12 volt cooler for food, a PC and a TV. For me, those are the bare necessities and I can live quite comfortably with just those things. Others may require more, but this is my house, not theirs lol.

General experiments

I have already performed some general experiments with different sized containers, different types of container materials, different metals and various electrolytes. Below are my basic discoveries to get us started.

How to make a basic home made battery

To make a general purpose home made battery you generally need to make several cells. For this demonstration, we will use one 12 oz pop cans for each cell in our battery and we will probably use 6-8 cells depending on how much power is needed.

Materials

  1. 6-8 12 oz pop cans(preferably generic and not Coke cans) I find that generic soda cans are less likely to have a coating on the inside that prevents effective corrosion which is needed for the battery to work. If you have to use cans with this coating, you’ll need to remove the coating with sandpaper somehow first. I’ve heard of using hydrochloric acid, but I cannot safely recommend that here, so don’t do that unless you know what you’re doing and understand that it is strictly at your own risk!
  2. roughly a 6 feed length of 1/2 to 1 inch in diameter copper tubing or another equally substantial amount of copper with similar or greater surface area.
  3. approximately 4 feet of medium gauge wire that is between 10 and 20 gauge.
  4. Either solder or aligator clips can be used to fasten your wires to the battery’s electrodes
  5. A decent pair of wire cutters and strippers.
  6. Water. Good old H2O or Plain tap water works fine.
  7. Bleach. Any kind will work, but I use the concentrated type for better results. I’ve heard using Clorox brand works better too, but I refused to buy a name brand bleach for testing.
  8. Salt. Regular table salt. You’ll need several tablespoons or about 2 tablespoons for each cell at the most.

Those are the things I”ll be using for my first experiments and these items were selected based on my preliminary testing.

Putting it all together:

It’s not really hard to build home made batteries, but it is time consuming because you have to produce several cells and run some parallel and some in a series until you get the voltage and amps required. Here are the basic steps:

  1. Take 1 of your 12 oz soda cans(you could use larger or smaller ones too) and clean it out.
  2. Measure your can from top to bottom and cut a lengh of copper tubing(or other copper material) to approximately 1 inch longer than the can.
  3. Wrap one end of the copper tubing with electrical tape so that when you stick it down in the pop can, it doesn’t ground out to the bottom of the can(or make sure it just doesn’t touch the bottom if you don’t want to take it. Then place a mark on the copper tube where it meets with the top of the pop can.
  4. Fill the can with plain tap water from your sink.
  5. Using the mark you made on the copper tube from step 3, wrap enough electrical tape around the copper so that you can fit it firmly in the mouth of the pop can. It should be a little snug at least with the tape around the mark keeping the copper from touching the can at any point. It is important the the two metals never touch or your battery will never work!
  6. After inserting the copper tube into the can, solder or clip a 2 inch length of wire to the portion of the copper tubing that sticks out above the top of the can.
  7. Solder or clip another length of wire 2 inches or longer to the rim of the alluminum can. This will be your negative lead and the one on the copper will be positive.
  8. Hook your leads to a multimeter and record the voltage and amperage from the single cell bettery you have just completet. You should get about 1/2 volt and very little amperage.
  9. Continue to make a total of at least 6 cells by repeating all the above steps. Label each cell you have made from 1 to 6 or 1 to 8 etc., depending on how many you made.
  10. Connect the positive lead(from the copper tube) of cell one to the negative lead of cell 2. Then the pos lead from cell 2 to neg lead on cell 3……continue until all cells are wired together in a series.
  11. Measure the voltage from the negative terminal on cell one and the positive terminal of the last cell and you should have between 6 and 16 volts so far.

That’s basically all there is to it, but now you will know if you need more cells in series or in parallel depending on if you need more voltage or amperage. Add more cells in series to increase voltage and in parallel to increase amps. Also increase the amount of bleach and/or salt in each cell to increase voltage, but remember that the stronger the solution is, the faster the battery terminals will corrode and eventually need maintenance and/or cleaning to keep them producing the optimal voltage and amperage needed.

Size of container

I’ve tried everything from Popsicle trays(like larger ice cube trays), aluminum cans and 5 gallon buckets. What is the difference in the size of the battery you ask? Surprisingly very little. Whether using a 5 gallon bucket with large electrodes and 5 gallons of electrolyte or using a pop can, both batteries produced roughly the same amount of voltage ranging from 0.4 to 1 volt depending on the strength of the electrolyte solution.

Increasing Voltage

Electrolytes is the key to more volts within a single cell I discovered. While other factors can alter the amount of voltage only slightly, the strength of the electrolyte was the main factor that effected the amount of voltage the batteries Ive made so far produced.

To increase the overall voltage produced by your home made batteries, you need to increase the number of cells in the battery. A battery is often a series of several cells unless it is a single cell battery, but usually when I refer to “battery”, I am speaking of the entire group of cells making up a single batter. A home made battery will often consist of 6 or more pop cans or other containers wired in a series or in parallel. To increase voltage we would run them in a series which means to attache the positive lead from the first cell to the negative lead of the second cell then continue until you reach the last cell. At that point the negative lead on cell one and the positive lead on the last cell will be open and those will be the two terminals used to power your device.

Increasing Amperage

The key to more amps seems to be in the general size of the battery. I was able to product significant;y more amps using a five gallon bucket as opposed to a 12 oz soda can.

To increase overall amperage a battery produces, several cells are required just as with increasing voltage. To increase amperage however, we have to wire the cells in parallel instead of in a series because batteries wired in parallel will cause the amperage to increase and the voltage to remain the same. Often times batters consist of a combination of cells ran in a series and cells ran in parallel to product the desired volts and amps. The general idea we are using will be to wire enough cells in a series to get 12 volts  in a single battery and after that we will increase the amperage by making several of these multi-cell/12 volt batteries and connecting them in parallel.

How to Control House Lights From Anywhere

In this article, How to Control House Lights From Anywhere, I am going to give a solution for the basic problem; How do you turn a light in your home on or off using your computer, phone or other online device? Also, I aim to control my home’s lights by voice commands from within the home.

The problem:

In a nutshell, the basic problem is, how do you control a light from a webpage? It could be either a webpage or an online app, but the concepts are similar. Also there is the voice control to think about. Voice operation is secondary because once I figure out how to turn the light on and off from my PC, then I can work in a voice control module from that point.

Since I want to control a light from a computer and through the internet, I think my best solution lies withing PHP as a starting point. So, basically I need to figure out how to control a light in my house with PHP. Once that is achieved, I can expand on that solution to do it from my PC, phone, the internet and via voice commands inside my home.

The next thing I did was asked myself: How can I get PHP to interact with the physical world? I had to think outside of the box and came up with using a PC or laptop based in my home as a controlling device. So then my problem becomes a little more focused. I had to find a solution to: “How do you control a light from a PC” Once that’s accomplished, you can communicate with that home-based PC via a network to control your home’s lights from anywhere with any device you like that can get online.

The Solution:

So, knowing that PHP is, for the most part, a web based language and a server-side language, I figured I would need another method of communicating with a hardware device to switch my house lights on and off. However, I thought that I could figure out what languages and technologies to use to control my lights from a PC and later find a way to communicate with the language/technologies I used from PHP.

Long story short, I decided upon using a micro-controller peripheral device known as the BASIC STAMP 2 as the light switch. Therein lies the first coding challenge.  The Basic Stamp 2 is basically a very small computer that was given the name “Stamp” because of it being the approximate size of a U.S. postage stamp. The Basic Stamp 2 uses a coding language named PBasic that is, as the name suggests, a very basic-like programming language. Being unfamiliar with PBasic, I spent the good part of a day learning how to do the basic coding necessary to turn a light on and off from the Stamp 2 Device. Next, I spent the majority of another whole day learning to communicate with the device through a USB port or serial cable from PHP. That’s why I am posting my findings online. If someone else ever has to do something similar or if I have to do it again in the future, they or I can simply reference this post on my website to figure it all out saving many hours of research and testing.

In summary, the solution I am using to control lights(and later other things) in my home, is a combination of PHP, PBasic, PC and the Basic Stamp 2. Here is the workflow:

Workflow for Creating a web-based Light Switch for your Home:

Basically there are three high-level steps to achieving my goal of controlling my home’s lights remotely. They are:

1) Create a circuit using the Basic Stamp 2 micro-controller that can turn a light on and off.

2) Write a program in PBasic to install on the Basic Stamp 2 that can control the circuit in the previous step.

3) Write a program in PHP that can send signals to the Basic Stamp 2 PBasic program letting it know to turn the light on or off.

Step by Step Low Level Instructions

The Step by Step Instructions for Building My Soon-to-be Famous Remote Lighting System are a lot more complex. Here are the step-by-step instructions to build the system I am employing in my smart home:

1) Obtain a device to interface with your PC in order to interact with the outside world(toggle a light). I decided to go with a micro-controller called “Basic Stamp 2” by Parallax. If you want to be able to follow this tutorial, I recommend you use the same one. Otherwise, some of the steps in this tutorial will not apply to your situation. I bought the Basic Stamp 2 HomeWork Board. I suppose you could use any implementation that has the same chip, but this tutorial is based upon using the exact version available on Parallax’s website here: https://www.parallax.com/product/555-28188.

2) Set up your Basic Stamp 2. I’m not going to go into too much detail about setting up your Basic Stamp 2 because you can get everything you need from Parallax’s interactive “Getting Started” guide found at http://www.parallax.com/go/BASICStampStartHelp/ and also you could download the PDF or read it online at https://www.parallax.com/sites/default/files/downloads/28125-Getting-Started-from-Help-v2.5.pdf.

3) Once you have the Basic Stamp 2 up and running and after you have tested it by writing a simple test program to make sure it works, you can create your light switch circuit. You will need a NPN transistor, a relay to trigger a high voltage (110 AC) light, a basic 470 Ω resistor and some wire leads in addition to a light of course. Here is a very basic switch circuit I got to work, but I must warn you that it doesn’t include the recommended NPN transistor that should go between the no. 14 pin and the relay or the 470 ohm resistor just mentioned. These could be important because most relays in general will throw back power surges to your micro-controller and fry it! I am the dangerous type, so I risked it. Just kidding, I found a reed relay that was considered safe, but it is definitely NOT recommended that you do the same and if you do, it is at your own risk… Here’s the circuit I used none-the-less. Just add the resistor and NPN transistor before the relay to be safe if you’re not sure about the risks:

OLYMPUS DIGITAL CAMERA

In the above image, you can see that pin 14 connects to the relay’s positive while the negative connects to the Vss or ground.  The two pins on the reed relay the are in the center on either end are the pins that the higher voltage, 110 vac travels through. Those two pins make a connection when current is applied to the two pins on either side of the relay that are connected to pin 14 and the Vss ground. In the above image, the white and green alligator clips lead to the 110 volt ac power supply and the golden wires lead to a 110 volt light fixture.  Also, in the above image you see a nine pin connector and the one I used has a USB connection. The wiring is the same though.

4) Write the PBasic code. Now that you have the circuit, it’s time to write the PBasic program to control it and test it. Here is the code I used to control a single light. Note that the code requires input which will eventually come from a PHP script over a USB cord, but for now you can test it by typing 1 or 2 on your keyboard as long as you keep your debug terminal running while using the editing software for the Basic Stamp 2. Type the following PBasic code into your Basic Stamp editor file and save it as a .bs2 file before downloading it to the device:

‘ {$STAMP BS2}
‘ {$PBASIC 2.5}

‘ This program accepts the numbers 1 & 2 as commands to turn light on off.
‘ Other values produce an error msg in debug term.

‘ ——– Pin Assignments ——–
INPUT_PIN CON 16

‘ ——– Constant Assignments ——–
BAUDMODE CON 16468

‘ ——– Variable Assignments ——–
Command VAR Byte
Counter VAR Nib

GOSUB Task3

Main:
DO
GOSUB GetInput
LOOP
END

‘ Receives input from some external source
GetInput:
SERIN INPUT_PIN, BAUDMODE, [Command]
GOSUB TakeAction
RETURN

TakeAction: ‘ Determines what to do based on result of GetInput
SELECT Command
CASE “1”
GOSUB Task1
RETURN
CASE “2”
GOSUB Task2
RETURN
CASE ELSE
GOSUB Task3
RETURN
ENDSELECT

Task1:
DEBUG CR, “Turning on light one.”
HIGH 12
PAUSE 50
RETURN

Task2:
DEBUG CR, “Turning off light one.”
LOW 12
PAUSE 50
RETURN

Task3:
DEBUG CR, “Please select one or two to turn the light on or off!”
PAUSE 50
RETURN

That’s it, now test the code by clicking the run icon in the editor then typing 1 or 2 on your PC’s keyboard to turn the light on or off that is connected to your circuit from the previous step. If it doesn’t work, check to be sure that your computer is using the same com port and baud rate that is set in the program and if not, change the settings in the above file accordingly.

5) Write the PHP code. Next is time to write the PHP code that will interact with the serial port, handing down information to the Basic Stamp 2 device and telling it to turn the 110 volt AC light on and off. Here’s the code I wrote for my first test case that worked great because it is as simple as it gets. You can expand on this later as needed, but here is the basic working PHP code:

 <?php
if(isset($_POST[“sbdrm”])){
exec(“mode com3: BAUD=9600 PARITY=n DATA=8 STOP=1”);// to=off dtr=off rts=off
$fp =fopen(“com3”, “w”);
//$fp = fopen(‘/dev/ttyUSB0′,’r+’); //use this for Linux
//value of bedroom light
$onoff = $_POST[‘bdrm’];
if($onoff == “off”) fwrite($fp, “2”); //write string to serial
if($onoff == “on”) fwrite($fp, “1”); //write string to serial
fclose($fp);
echo “Light toggled!<br />”;
}//end if sbdrm is hit
?>

Finally, we have the simple version of the HTML code:

<h1>Light Controls</h1>

<h2>Bedroom Light</h2>
<form method=”post” action=””>
<input type=”radio” id=”bdrm” name=”bdrm” value=”on”> On<br />
<input type=”radio” id=”bdrm” name=”bdrm” value=”off”> Off<br />
<input type=”submit” id=”sbdrm” name=”sbdrm” value=”GO!” />
</form>

 

 

 

New 3D Services!

That’s correct, we now offer 3D design services for the web! While 3D art for websites is nothing really new, until recently, it wasn’t efficient or attractive enough for me to take seriously as a web developer. Recent developments in WebGL  and  Three.js.

To show off some of the recent developments in Three.js and WebGL, I will be adding several 3D components to this site and the Jafty Blog site as well which can be seen at jafty.com/blog. I have already added some 3D text to the header of this page/site. See where it says “Now In 3D!”? That is a small taste of what can be done with text in 3D, but that’s nothing compared to the image rendering capabilities and 3D models that can now be used much easier and efficiently in any web site! I’ll be adding pages in 3D and a new 3D gallery to the site very soon, so you’ll see then.

WebGL is a JavaScript API for rendering interactive 3D graphics and 2D graphics within any compatible web browser without the use of plug-ins. WebGL is integrated completely into all web standards for browsers allowing GPU accelerated usage of physics and image processing and effects as part of the web page.

Three.js is a JavaScript 3D Library which makes WebGL simpler. Three.js is a lightweight cross-browser JavaScript library/API used to create and display animated 3D computer graphics on a Web browser.. The source code is hosted in a repository on GitHub.

http://maurizzzio.github.io/PojoViz/public/images/threejs.png

Services

Jafty Interactive Web Development concentrates on a few web technologies that strongly complement one another such as:

  • PHP
  • HTML
  • CSS
  • JavaScript
  • Jquery
  • WordPress

It is my belief that specializing very well in a few technologies that compliment one another is preferable to knowing far less of many technologies. This is why Jafty Interactive specializes in first and foremost in PHP and WordPress development. HTML, CSS and JavaScript all go hand & hand with both WordPress and PHP. As many of you may know, WordPress is developed using PHP mostly but also has HTML, CSS and JavaScript technologies, so knowing all these makes one a truly professional WordPress developer. Any true WordPress developer must also be a master of PHP and vice versa. Hire Jafty for all your WordPress and/or PHP needs and you won’t be disappointed.