i need some suggestions
kbamp
Posts: 4
i have just started on using basic stamp 2.
i would like to make a program such that when the sensor detects signal, it will do a count down and this countdown would display on the LCD display.
any one could give me suggestions on { } portion ?
Main:
OUT2 = 1
PAUSE 100
OUT2 = 0
result = 0
FOR temp = 0 TO 12
IF temp = 15 THEN next_line
out:
READ temp,char
GOSUB Sendtext
NEXT
PAUSE 500
Inst = %00000001 'Clears LCD
GOSUB Sendinst
PAUSE 100
FOR temp = 13 TO 27
READ temp,char
GOSUB Sendtext
NEXT
Inst = 128+64 'Send cursor to line 2
GOSUB Sendinst
Measure:
HIGH sensorPin2
HIGH sensorPin ' Discharge the capacitor
PAUSE 2
RCTIME sensorPin,1,rawForce ' Measure RC charge time
RCTIME sensorPin2,1,rawForce2
DEBUG HOME, "Flexiforce raw output = ", DEC rawForce,CR, "Flexiforce2 raw output = ", DEC rawForce2,CR
IF (rawForce > 1) THEN·· 'If sensor detects pressure
·{···················}···· 'write the value of counting to LCD
counting =·result + 1·'counting increment
PAUSE 1000···················· '1s delay
GOTO Measure
·
i would like to make a program such that when the sensor detects signal, it will do a count down and this countdown would display on the LCD display.
any one could give me suggestions on { } portion ?
Main:
OUT2 = 1
PAUSE 100
OUT2 = 0
result = 0
FOR temp = 0 TO 12
IF temp = 15 THEN next_line
out:
READ temp,char
GOSUB Sendtext
NEXT
PAUSE 500
Inst = %00000001 'Clears LCD
GOSUB Sendinst
PAUSE 100
FOR temp = 13 TO 27
READ temp,char
GOSUB Sendtext
NEXT
Inst = 128+64 'Send cursor to line 2
GOSUB Sendinst
Measure:
HIGH sensorPin2
HIGH sensorPin ' Discharge the capacitor
PAUSE 2
RCTIME sensorPin,1,rawForce ' Measure RC charge time
RCTIME sensorPin2,1,rawForce2
DEBUG HOME, "Flexiforce raw output = ", DEC rawForce,CR, "Flexiforce2 raw output = ", DEC rawForce2,CR
IF (rawForce > 1) THEN·· 'If sensor detects pressure
·{···················}···· 'write the value of counting to LCD
counting =·result + 1·'counting increment
PAUSE 1000···················· '1s delay
GOTO Measure
·
Comments
Do you understand the sample code? Is the problem that you need to convert a number into a series
of decimal digits for display? If so, how do you want the result to look? Have you looked at the DIG operator?
This will give you "nth" decimal digit of a numeric value. You can add "0" to that to get a character for
display. For example: