pBasic (Basic stamp)

DC Motor Control with a TIP120 Transistor

This example assumes you’re using a DC motor that runs on low voltage DC, in the 5-15V range. Connect leads to its terminals, and run if from a benchtop power supply if you have one. Try changing the voltage on it, and seeing what effect it has. Don’t go over the motor’s rated voltage. Connect a switch in series with the motor and use it to turn on the motor.

Continue Reading »

BX-24
PicBasic Pro
pBasic (Basic stamp)

Permalink

Random Numbers and Physical Computing

Most microcontrollers don’t have a random function. Random functions are not truly random, they’re actually a complex mathematical formula that results in a number that “seems” random. That can take up lots of processing time, so it’s usually the first function to go when writing a microprocessor language.

In fact, most of what you do in programming physical computing projects is to figure out how to deal with the world’s natural randomness and make it look smooth. A photoresistor read through an analog-to-digital converter, for example, will never give you a nice steady number, it always fluctuates with tiny changes in lighting that your eye can’t see. Your consciousness is a great leveller for the sensors that are your eyes, ears, skin, nose, and taste buds When you move a photoresistor from one room to another, your readings will be totally different, and all of a sudden, you have to re-calculate what is “average” and what constitutes the lighting change that you want. And that’s just one of many examples. The fact is, data from sensors is filled with the noise of the real world. Plan for it in advance.

Technorati Tags: , ,


Continue Reading »


AVR
BX-24
PIC
PicBasic Pro
XBee
arduino/wiring
pBasic (Basic stamp)

Permalink

Branch

BRANCH allows branching to one of multiple subroutines depending on the value of a specified variable. It’s the equivalent of a case statement. PicBasic Pro also has a BRANCH statement, as does mBasic. It looks like this:

BRANCH value, [label1, label2, label3...]

If value = 0, the program goes to label1. If value = 1, the program goes to label2. If value = 2, it goes to label3, and so forth.

 

Here’s a BS2 program illustrating BRANCH:

 

Continue Reading »

pBasic (Basic stamp)

Permalink