how to Simulate readadc

Mejlby

Member
Hello everyone

how can i simulate readadc C.1,b0 in editor ver 6.1 ?????

For example, I would like to enter the value >80 and see if the program goes to led2

( I remember that in the old version 5. I could enter values and test the program )

Program:

main:
readadc C.1,b0 ; read value into b0

let dirsB = %11111111 ‘ switch pins 0 and 1 to outputs

if b0 < 5 then led0 ' if bigger than 5 jump
if b0 < 45 then led1 ' if bigger than 30 jump
if b0 < 80 then led2 ' if bigger than 60 jump
if b0 < 120 then led3 ' if bigger than 90 jump
if b0 < 170 then led4 ' if bigger than 120 jump
if b0 < 220 then led5 ' if bigger than 150 jump
if b0 < 255 then led6 ' if bigger than 180 jump


Regards Mejlby
 

Attachments

Last edited:

Jack Burns

New Member
Have you tried right clicking on the Pin and entering the value you want using the dial?
You can change the value using the method steliosm described above, however you can also alter the value on the 'values' tab as shown on the simulation panel below.

1630682775531.png

Regards
Jack
 

johnlong

Senior Member
Have a play with this have changed your if statement to a select case and added <= to turn the leds on and off
Code:
#picaxe 28x2


main:
do
'readadc A.1,b0 ; read value into b0

let pinsB = %0000000 ' switch pins 0 and 1 to outputs
    select case b0
case  <= 5  high B.7 ' if bigger than 5 jump
case <= 45  high B.6 ' if bigger than 30 jump
case <= 80  high  B.5 ' if bigger than 60 jump
case  <= 120  high B.4 ' if bigger than 90 jump
case  <= 170  high B.3 ' if bigger than 120 jump
case  <= 220  high B.2 ' if bigger than 150 jump
case  <= 255  high B.1 ' if bigger than 180 jump
end select
if pinC.4 = 1 then 'simulate the values for the adc click on C.4 goes yellow and it add 5 let it over clock will give you diffrent values
    b0=b0+5
endif
sertxd("b0 = ",#b0," pinsB = ",#pinsB,cr,lf)
pause 500
loop
regards john
 

Mejlby

Member
Thanks for everyone's help ..... I did not know I could right click on pin and select value.
Super smart!

(actually it's been 10 years since I last used Picaxe and had forgotten several things. Now I'm retired and have time to enjoy electronics projects)

Regards
Mejlby - Denmark
 
Top