SQL RESTian example in PHP

Here’s a PHP script that reads and writes from a SQL database. This example assumes you’ve got a SQL database account on the same machine that the script is running on. It also assumes you’re using a .htaccess file that looks something like this:

RewriteEngine On
RewriteBase /directoryname/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ sqlRestDatalog.php

Continue reading “SQL RESTian example in PHP”

Mr. Data Converter

Mr. Data Converter is your friend. It’s a conversion tool to take tab or comma delimited data and convert it to a variety of formats: XML, JSON, ActionScript, PHP, you name it. Mighty handy if you have to take stuff from one place and move it to another.

Thanks to James Tu for the link.

Simple PWM in PicBasic Pro

This is an example of pulsewidth modulation for the PIC. The value received from an analog input is used to dim an LED, using the PWM command. The LED is on RD2, and the analog in is on RA0.

The PWM command has three parameters: the pin, the duty cycle (a byte), and the number of times to pulse the pin (a word). The duty cycle is how long the pin is on for each cycle. If the duty cycle is 100% (255), then the pin is on all the time. A duty cycle of 50% turns the pin on for half of each cycle, and so forth.

At 4MHz, one on-off cycle is about 5 milliseconds. A higher number of cycles makes for smoother PWMing, but less interactivity, because the PIC does nothing else until it’s finished all the cycles for each PWM command.

Continue reading “Simple PWM in PicBasic Pro”