Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

LCDOUT - to display single bit?

Status
Not open for further replies.

SwingeyP

Member
Hello.

How can I display a single bit with LCDOUT?

This code will explain better what I am trying to do (hopefully)

Code:
Function rtty_txtbyte(chr As Byte) As Byte
Lcdcmdout LcdLine1Pos(1)
Lcdout "Char = " chr

Call rtty_txbit(0)  'start Bit

'send bits For For char lsb first

For j = 0 To 7  'change this here 7 Or 8 For ascii-7 / ascii-8
	Lcdcmdout LcdLine3Pos(1)
	Lcdout "Bit = " chr(j)
	If chr.0 Then
		Call rtty_txbit(1)
	Else
		Call rtty_txbit(0)
	Endif
chr = ShiftRight(chr, 1)
Next j

Call rtty_txbit(1)  'stop Bit
Call rtty_txbit(1)  'stop Bit

End Function

I am displaying the letter as it arrives from the lookup on line 1 and then I want to display th eindividual bits of the letter on line 3 from the j loop.

Regards - Paul
 
Write a function

Code:
Function pow(x1 As Byte, t As Byte) As Byte
Dim x2 As Byte
   t = LookUp(1, 2, 4, 8, 16, 32, 64, 128), t
   x2 = x1 And t
   pow = 0x31
   If x2 = 0 Then pow = 0x30
End Function


Then

Code:
Lcdout "bit = " pow(chr,j)
 
High thanks for that - couldn't get it to work properly so decided to do this ...

Code:
Function convert_char(chr As Byte) As Byte
Lcdcmdout LcdLine1Pos(pos)
Lcdout chr

Call rtty_txbit(0)  'start Bit

For j = 0 To 7  'ascii-7 / ascii-8
	'Lcdcmdout LcdLine3Pos(1)
	'Lcdout "Bit ", #j,
	If chr.0 Then
		'Lcdcmdout LcdLine3Pos(8)
		'Lcdout "= HIGH" ' -- Use the scope to see this is true!
		Call rtty_txbit(1)
	Else
		'Lcdcmdout LcdLine3Pos(8)
		'Lcdout "= LOW "
		Call rtty_txbit(0)
	Endif
chr = ShiftRight(chr, 1)
Next j

Call rtty_txbit(1)  'stop Bit
Call rtty_txbit(1)  'stop Bit

End Function

tracing it on the built in scope I can then confirm that R = 01010010 which is correct so I know at least i'm send the characters correctly. A bit heath robinson but it worked :)

Thanks - Paul
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top