input problem [solved]

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi i've some problem in a bascom code it should work.

$regfile = "m32dat,def"
$hwstack = 64
$swstack = 64
$framesize = 64
$baud

config porta = input
dim x as byte

do
porta = x
print x
loop
end

it does only print zero even if a press some buttons on the stk500.[/code]

Last Edited: Fri. Jan 22, 2010 - 08:06 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gurra95 wrote:
hi i've some problem in a bascom code it should work.

No it shouldn't.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It appears that the variable x is undefined, and this undefined variable is being assigned to an input port. The Bascom compiler assigns the value 0 to an undefined variable and the print statement is sending value 0.

Try "x = porta". This statement will read the input port and assign its value to the variable x. Then, as logic levels are changed on the input port a, these changes will be sent out by the print x statement.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Try "x = porta". This statement will read the input port and assign its value to the variable x.

In BASCOM is it PORTA or PINA?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:

In BASCOM is it PORTA or PINA?

Or is it PITA :lol: (Sorry, couldn't resist...)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

in bascom it is always port input or output is defiend config portx = I/O and x is defined in "dim x as byte"
i'm gonna try simonetta:s code change tommorow it's late her in sweden.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

problem solved
like this it should be

$regfile = "m16def.dat"
$crystal = 8000000
$baud = 9600
$hwstack = 32
$swstack = 8
$framesize = 24

Dim X As Byte            ;define x
Config Porta = Input     ;define output

Do
 Porta = 0               ;set portb to 0
 Print Pina              ;print input signal
 Wait 1
Loop                     ;start over again

End                      ;end

now it works.
i should have lissend on you earlier theusch :oops: