joeyko10642
Joined: 17 Oct 2016 Posts: 1
|
Posted: Mon Oct 17, 2016 8:40 am Post subject: Display value on LCD without new values rewriting first valu |
|
|
Hi guys, im fairly new to this forum so maybe this might not be the right place to post this? but i am having trouble on displaying a value from a variable on the lcd without it being rewritten by the next value. Is there a way to keep the same value displayed without needing to use a stop command for the program?
Im currently trying to display the first distance value from a rotating ultrasonic sensor, but as it moves new distances are detected and it rewrites the first value with the new distance values.
$crystal = 1000000
$regfile = "m16adef.dat"
Config Pina.1 = Input 'Config PinA.1 as input, ECHO of HC-SR04 ultrasonic sensor
Config Porta = Output 'Config rest of PORTA as output, including TRIGGER of HC-SR04 ultrasonic sensor
Set Portd.5 'Turn on backlight of LED
Dim Ontime As Word 'Delay time of BYJ48 stepper motor
Dim I As Word 'Variable for the amount of steps stepper motor BYJ48 will rotate
Dim Ii As Byte 'the number of phases of the stepper motor BYJ48
Dim S(4) As Byte
Dim Distance As Single 'Distance that the ultrasonic reads
Dim W As Dword 'Same as distance
Dim A As Word
Ontime = 800
Config Lcdbus = 4
Config Lcdpin = Pin Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.2 , Rs = Portb.0 'LCD Configuration
Config Lcd = 20 * 4
Cursor Off
Do
Gosub Ultrasonic
loop
end
Ultrasonic:
Pulseout Porta , 2 , 20 'Min. 10us pulse 'send out ultrasonic waves
Pulsein W , Pina , 1 , 1 'read distance 'receive ultrasonic waves
Incr I 'increase steps after one reading
If Err = 0 Then 'when error is 0
W = W * 26 'calcul ate to 'calculations to convert wave signals to cm
W = W / 58.3090379009 ' centimeters
Distance = W
A = I * 35
A = A / 100
Print #1 , W ; " , " ; I ; " , " ; A 'print onto terminal emulator using rs232
'For Index = 1 To 10
'Spoint(index) = Distance
'Next
End If
(BASCOM-AVR version : 2.0.7.8 ) |
|