Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

i need simple experiment arduino+hc05

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-ARDUINO
View previous topic :: View next topic  
Author Message
MIKRO_MAN

Bascom Member



Joined: 22 Jan 2015
Posts: 38

PostPosted: Tue Sep 15, 2015 11:04 pm    Post subject: i need simple experiment arduino+hc05 Reply with quote

i need simple experiment connect arduino + hc05 to led on/off

pin connection
i need just simple bascom code ?
Back to top
View user's profile
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 282
Location: D.F.

mexico.gif
PostPosted: Wed Sep 16, 2015 12:12 am    Post subject: Reply with quote

Code:
Do
   '>[Turn Led1 on ]
   Set Led1 : Waitms 500
   '>[Turn Led1 off ]
   Reset Led1 : Waitms 500
Loop
End
Back to top
View user's profile
MIKRO_MAN

Bascom Member



Joined: 22 Jan 2015
Posts: 38

PostPosted: Wed Sep 16, 2015 12:47 am    Post subject: Reply with quote

Printpix52 wrote:
Code:
Do
   '>[Turn Led1 on ]
   Set Led1 : Waitms 500
   '>[Turn Led1 off ]
   Reset Led1 : Waitms 500
Loop
End


thanks for help
but i wont full code --> config pins and serial received & send ??
Back to top
View user's profile
MIKRO_MAN

Bascom Member



Joined: 22 Jan 2015
Posts: 38

PostPosted: Wed Sep 16, 2015 9:26 pm    Post subject: Reply with quote

i find this code [lcd+hc05]
i need to comments to explained how to tx and rx hc05

Code:

$lib "LCD-pcf8833BR2.LBX"
$regfile = "m8def.dat"
$crystal = 11059200
Config Graphlcd = Color , Controlport = Portb , Cs = 3 , Rs = 0 , Scl = 2 , Sda = 1
Const Blue = &B00000011
Const Yellow = &B11111100
Const Red = &B11100000
Const Green = &B00011100
Const Black = &B00000000
Const White = &B11111111
Const Brightgreen = &B00111110
Const Darkgreen = &B00010100
Const Darkred = &B10100000
Const Darkblue = &B00000010
Const Brightblue = &B00011111
Const Orange = &B11111000

'lcdat y,x (satr bayad 10 ta 10 ta ziad shavad, pixel ra mibinad na satr)

Ddrb.5 = 1                                                  ' pb.5 = out
Portb.5 = 0

Open "comb.4:38400,8,n,1" For Input As #1

Dim A As Byte
Dim Ch As String * 1

Cls
Setfont Color8x8
Lcdat 0 , 0 , "Ready..." , Black , White

Do
   A = Inkey(#1)
   If A > 0 Then
      Ch = Chr(a)
      Lcdat 10 , 0 , Ch
      If Lcase(ch) = "a" Then Portb.5 = 0
      If Lcase(ch) = "b" Then Portb.5 = 1

   End If
Loop
End

$include "color8x8.font"

'end of file
 


what is function of code
Code:

Open "comb.4:38400,8,n,1" For Input As #1
 
Back to top
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1161
Location: France

france.gif
PostPosted: Thu Sep 17, 2015 5:22 pm    Post subject: Reply with quote

hello,
Quote:
what is function of code
Code:

Open "comb.4:38400,8,n,1" For Input As #1

see the help for "open"
"So that is why the OPEN statement must be used. It tells the compiler about the pin you use for the serial input or output and the baud rate you want to use.

COMB.0:9600,8,N,2 will use PORT B.0 at 9600 baud with 2 stop bits."
JP Wink
Back to top
View user's profile Visit poster's website
MIKRO_MAN

Bascom Member



Joined: 22 Jan 2015
Posts: 38

PostPosted: Thu Sep 17, 2015 5:46 pm    Post subject: Reply with quote

Duval JP wrote:
hello,
Quote:
what is function of code
Code:

Open "comb.4:38400,8,n,1" For Input As #1

see the help for "open"
"So that is why the OPEN statement must be used. It tells the compiler about the pin you use for the serial input or output and the baud rate you want to use.

COMB.0:9600,8,N,2 will use PORT B.0 at 9600 baud with 2 stop bits."
JP Wink


thanks a lot
i need to connect hc05 to arduino i search in forum not find simple tutorial ??
Back to top
View user's profile
MIKRO_MAN

Bascom Member



Joined: 22 Jan 2015
Posts: 38

PostPosted: Fri Sep 18, 2015 1:33 pm    Post subject: Reply with quote

i find simple code and working good
but i need to update code to send data from arduino to hc05 to android app
Code:


$programmer = 23

$regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack = 80
$swstack = 80
$framesize = 80
$baud = 9600
Dim A As String * 2
Dim B As Word
Config Portb.5 = Output
Do
If Ischarwaiting() = 1 Then
A = Inkey()
End If
If A = "A" Then
Portb.5 = 1
End If
If A = "B" Then
Portb.5 = 0
End If
Loop

 
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Fri Sep 18, 2015 2:36 pm    Post subject: Search for Android2Arduino Reply with quote

Do a search on Android2Arduino in this forum.

On the Arduino side a Bascom-Avr program
On the Android side a Basic4Android program

Connection between both platforms with a OTG USB connection.

It can be done...

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
MIKRO_MAN

Bascom Member



Joined: 22 Jan 2015
Posts: 38

PostPosted: Fri Sep 18, 2015 10:43 pm    Post subject: Re: Search for Android2Arduino Reply with quote

bzijlstra wrote:
Do a search on Android2Arduino in this forum.

On the Arduino side a Bascom-Avr program
On the Android side a Basic4Android program

Connection between both platforms with a OTG USB connection.

It can be done...

Have fun
Ben Zijlstra

Code:

$regfile = "m2560def.dat"
$crystal = 16000000
$hwstack = 64
$swstack = 64
$framesize = 64
$baud = 9600
Open "Com1:" For Binary As #1
Dim A As Byte , S As String * 2
Do
  A = Ischarwaiting(#1)
  If A = 1 Then                                             'we got something
     A = Waitkey(#1)
     Select Case A
            Case 49 : Print #1 , "A";
            Case 50 : Print #1 , "B";
            Case 51 : Print #1 , "C";
            Case 52 : Print #1 , "D";
     End Select
  End If
Loop
End
 

Code:
Open "Com1:" For Binary As #1

i wont to ask about this code
1- this code to make any pin tx or rx ?
i understand that from help index
Code:
COMB.0:9600,8,N,2 will use PORT B.0 at 9600 baud with 2 stop bits.


Code:
Dim A As Byte , S As String * 2

2- why s string * 2

Code:
Case 49 : Print #1 , "A";

this code will send tx binary value for what ??

i wont to correct for above commends about code
thanks for helping
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Fri Sep 18, 2015 11:40 pm    Post subject: Some info Reply with quote

Oke. No problem.

With opening the COM1 the hardware UART is used.
With opening b.0 a software UART is created.

Perhaps you can check the help for the difference between a hardware and a software UART.

With a software UART check the help for the tx and rx pin.

==

While checking the help have a look at the ASCII chart. 49 is the ASCII value for 1. So the Android app is sending a 1, 2, 3 and 4 for the four buttons in the app. And the Arduino is printing A, B, C and D.

==

The communication port that was opened got a number, in this case #1. When we want to send someting to this port we can use print #1. There are microcontrollers with more then 1 hardware UART.

==

And about the DIM of S as string, I see this variabele is not used anymore so the DIM for S can be deleted.

About non-used variables: when you do a compile you can check in the report of the compile if there are variables dimmed that are not used.

Oke, have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
MIKRO_MAN

Bascom Member



Joined: 22 Jan 2015
Posts: 38

PostPosted: Sat Sep 19, 2015 1:32 am    Post subject: Re: Some info Reply with quote

bzijlstra wrote:
Oke. No problem.

With opening the COM1 the hardware UART is used.
With opening b.0 a software UART is created.

Perhaps you can check the help for the difference between a hardware and a software UART.

With a software UART check the help for the tx and rx pin.

==

While checking the help have a look at the ASCII chart. 49 is the ASCII value for 1. So the Android app is sending a 1, 2, 3 and 4 for the four buttons in the app. And the Arduino is printing A, B, C and D.

==

The communication port that was opened got a number, in this case #1. When we want to send someting to this port we can use print #1. There are microcontrollers with more then 1 hardware UART.

==

And about the DIM of S as string, I see this variabele is not used anymore so the DIM for S can be deleted.

About non-used variables: when you do a compile you can check in the report of the compile if there are variables dimmed that are not used.

Oke, have fun
Ben Zijlstra



thank you for helping
i will more search [difference between a hardware and a software UART]
and how to make any pin rx or tx


final the simple ex- rx and tx between phone && arduino
Code:

$programmer = 23
$regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack = 80
$swstack = 80
$framesize = 80
$baud = 9600
Dim A As String * 2
Dim B As Word
Config Portb.5 = Output
Do
If Ischarwaiting() = 1 Then  
A = Inkey()
End If
If A = "A" Then
Portb.5 = 1
Print "led on" //send data to phone
End If
If A = "B" Then
Portb.5 = 0
Print "led off"  //send data to phone
End If
Loop
 


i used this code
Code:
Dim A As String * 2

but i cant understand why product A * 2
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Sat Sep 19, 2015 3:00 am    Post subject: Hold text in string Reply with quote

A string is used to hold text

In this case it holds the incoming character and can hold 2 characters.

Read the Bascom language fundamentals.

The dim a as string * 2 reserves two bytes in ram named A and can hold 2 characters.

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-ARDUINO All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum