Section Use an interface for interactive control of your Basic Stamp module

The !READ instruction may be used to send data BACK to the BASIC Stamp module where the it would accept and use the value. Treating their name like a macro math value references object values. For example, a slider control named 'Setpoint' could have its value sent to the BASIC Stamp using: !READ (Setpoint)

We will have the BASIC Stamp module create and read this interface with a slider with a range from 0 to 255 and adjust a value to match the slider's.

' Interactive control with a StampPlot slider PAUSE 1000



DEBUG "!PPER 100,80",CR

' create slider on StampPlot named Setpoint

DEBUG "!POBJ oHSlider.Setpoint=3 8,15/2 9/7/0/2 55,78"/CR

Actual VAR Byte Setp VAR Byte

' Request value from StampPlot DEBUG "!READ (Setpoint)",CR ' Accept value from StampPlot DEBUGIN DEC Setp ' Compare and adjust actual

IF Actual < Setp THEN Actual = Actual + ((Setp-Actual)/5) IF Actual > Setp THEN Actual = Actual - ((Actual - Setp)/5) ' Plot setpoint and actual DEBUG DEC Setp, ",", DEC Actual,CR PAUSE 250 LOOP

Note: It is recommended to use the PBASIC command serin with a timeout instead of debugin instruction. With debugin, if a response is not received (StampPlot not connected) the controller will 'hang' waiting for a return.

SERIN 16, 84,500,Timeout, [DEC Setp] Timeout:

Another fun use is image buttons that display of one of 2 graphics when clicked and return a 1 or 0 when read and can be used as virtual switches. See the help files!

DIY Battery Repair

DIY Battery Repair

You can now recondition your old batteries at home and bring them back to 100 percent of their working condition. This guide will enable you to revive All NiCd batteries regardless of brand and battery volt. It will give you the required information on how to re-energize and revive your NiCd batteries through the RVD process, charging method and charging guidelines.

Get My Free Ebook

Post a comment