Hier ist ein einfacher Zähler, der mit Bascom GUI-O für Smartphone und Arduino Nano erstellt wurde.
Die Kommunikation zwischen Arduino und Smartphone erfolgt über das Bluetooth-Modul HC06.
Das Display auf der HW ist SSD1306 und auf dem Smartphone.
Anbei ein Screenshot des Telefons, ein Schema des Youtube-Clips und ein Bascom-Code.
www.gui-o.com
play.google.com/store/apps/details?id=com.guio.guioapp
youtu.be/FNoWI_SyMOg
Alles anzeigen
mcselec.com/index2.php?option=…59&page=viewtopic&t=14869
Die Kommunikation zwischen Arduino und Smartphone erfolgt über das Bluetooth-Modul HC06.
Das Display auf der HW ist SSD1306 und auf dem Smartphone.
Anbei ein Screenshot des Telefons, ein Schema des Youtube-Clips und ein Bascom-Code.
www.gui-o.com
play.google.com/store/apps/details?id=com.guio.guioapp
youtu.be/FNoWI_SyMOg
BASCOM-Quellcode
- ' _____ _
- ' / ____| | |
- ' | | ___ _ _ _ __ | |_ ___ _ __
- ' | | / _ \| | | | '_ \| __/ _ \ '__|
- ' | |___| (_) | |_| | | | | || __/ |
- ' \_____\___/ \__,_|_| |_|\__\___|_|
- '------------------------------------------------------------------------------
- ' GUI-O V0.11.16 2021-11 www.gui-o.com
- '------------------------------------------------------------------------------
- ' .-----------------------.
- ' |ATMEGA328 Arduino nano |
- ' | |
- ' |Clock 16.000000 Hz |
- ' |GLCD SSD1306 |
- ' |gammda 2021-11-09 |
- ' '-----------------------'
- '-Hardware connection----------------------------------------------------------
- '********************************************************************
- '* Bluetooth Arduino Nano SSD1306 *
- '* .-------. .-----------. .-----------. *
- '* | HC06 | | Mega 328 | | | *
- '* | | | | | | *
- '* | | | | | | *
- '* | | | | | I2C | *
- '* | | TX PortC.1 | | '------|----' *
- '* | |--------------| | | *
- '* | | RX PortC.0 | | SCL-PortC.5 | *
- '* '-------' | |---------------| *
- '* | | SCL-PortC.4 *
- '* | | *
- '* Input | | *
- '* o------------| | *
- '* D3 PinD3 | | *
- '* '-----------' *
- '********************************************************************
- '$sim
- $regfile = "m328pdef.dat"
- $crystal = 16000000
- $baud = 9600
- $hwstack = 60
- $swstack = 60
- $framesize = 60
- Config Serialin = Buffered , Size = 120
- Open "comc.1:9600,8,n,1" For Output As #1 'software serial port Bluetooth
- Open "comc.0:9600,8,n,1" For Input As #2
- '===============================================================================
- ' ST1306 LCD I2c 128x64 test example
- '===============================================================================
- Config Scl = Portc.5 ' used i2c pins
- Config Sda = Portc.4
- Config Twi = 400000 ' i2c speed
- I2cinit
- $lib "i2c_twi.lbx" ' we do not use software emulated I2C but the TWI
- $lib "glcdSSD1306-I2C_V2.lib" ' override the default lib with this special one
- Dim _contrast As Byte ' Contrast value of OLED. [0-255]
- 'Const Ssd1306_rotate = 0 ' Display rotation. [connection cable is lower side = 0, upper side = 1] rotate display 180 degrees.
- Config Graphlcd = Custom , Cols = 128 , Rows = 64 , Lcdname = "SSD1306"
- Cls
- 'Gettoken LIB declaration (parsing text)----------------------------------------
- Dim Sep As Byte
- Dim Pozicija As Byte
- $lib "GetToken.Lib"
- $external Gettoken
- Declare Function Gettoken(strinput As String , Byval Bseparator As Byte , Byval Bcount As Byte ) As String
- '-Declaration port--------------------------------------------------------------
- Config Pind.3 = Input
- Set Portd.3
- Inp_ Alias Pind.3
- '-Logotip picture---------------------------------------------------------------
- Cls
- Setfont Font8x8
- Showpic 0 , 0 , Logoms
- Wait 4
- '-Define external interrupt INT1------------------------------------------------
- Config Int1 = Low Level 'Interruption on Falling
- On Int1 Count Nosave
- Disable Interrupts
- '-Variables---------------------------------------------------------------------
- Dim Ii As Dword
- Dim Iis As Single
- Dim Iist As String * 20
- Dim Iisf As String * 20
- Dim Bt_key As Byte
- Dim Znak As String * 15
- Dim Bdata As String * 60
- Cls
- '-Start definition-------------------------------------------------------------
- Setfont Font5x12
- Lcdat 1 , 1 , "COUNTER"
- Gosub Init_gui ' GUI-O initialization
- Iisf = Format(iist , "00000000") 'Counter Zero screen LCD
- Setfont Digital14x24
- Lcdat 3 , 1 , Iisf
- Print#1 , "@lbd TXT:'" ; Iisf ; "'" 'Counter Zero smart phone definition
- Enable Interrupts
- Enable Int1
- '-Main Loop--------------------------------------------------------------------
- Main:
- Do
- Disable Interrupts
- Gosub Read_data ' Read information from software seral port
- Enable Interrupts
- Loop
- End 'End application
- '--Init GUI-o -----------------------------------------------------------------
- '=Initialization objects on Smartphone=========================================
- Init_gui:
- Disable Int1
- Print #1 , "@sls 500"
- Print #1 , "@cls"
- Print #1 , "@clh"
- Print #1 , "@clo"
- Print #1 , "@gse COD:0 TSC:39"
- Print #1 , "@guis BGC:#696969 ASR:0.449671"
- Print #1 , "|SORI UID:sori1 HID:sori ORI:2 SEN:0"
- Print #1 , "|BSR UID:bsr2 X:50 Y:50 W:90 H:85 VIS:1 ROT:0 RAD:1.5 BGC:#d3d3d3 SBGC:#d3d3d3 FGC:#d3d3d3 SHE:1 BTH:0.5" 'background rectangle
- Print #1 , "|BSR UID:bsr3 X:55 Y:40 W:60 H:40 VIS:1 ROT:0 RAD:2 BGC:#000000 SBGC:#000000 FGC:#000000 SHE:1 BTH:0.5" ' backgroun display
- Print #1 , "|LB UID:lbd X:55 Y:40 ALP:0 SHE:1 ROT:0 FGC:#a22200 FSZ:20 FFA:'font2' TXT:'" ; Iisf ; "'" ' counter digital noumber
- Print #1 , "|LB UID:lb0 X:15 Y:15 ALP:0 SHE:1 ROT:0 FGC:#000000 FSZ:10 FFA:'font7' TXT:'Counter'" ' name of device
- Print #1 , "|LB UID:lbt1 X:9 Y:28 ALP:1 SHE:1 ROT:0 FGC:#0350a2 FSZ:7 FFA:'font0' TXT:'Power'" 'Text power
- Print #1 , "|LB UID:lbt2 X:9 Y:40.5 ALP:1 SHE:1 ROT:0 FGC:#0350a2 FSZ:7 FFA:'font0' TXT:'Pulse'" 'text pulse
- Print #1 , "|LB UID:lblog X:80 Y:88 ALP:1 SHE:1 ROT:0 URL:1 FGC:#0350a2 FSZ:4 FFA:'font0' TXT:'www.gui-o.com'" 'Text GUI-O home page
- Print #1 , "|SI UID:si1 X:21 Y:28 W:2.5 VIS:1 ROT:0 BGC:#B0C4DE FGC:#711700 SHE:1 EN:1" ' LED Power
- Print #1 , "|SI UID:si2 X:21 Y:40.5 W:2.5 VIS:1 ROT:0 BGC:#B0C4DE FGC:#711700 SHE:1 EN:0" 'LED Pulse
- Print #1 , "|BT UID:bt5 X:80 Y:75 W:8 H:16 SHE:1 ROT:0 RAD:0.5 BGC:#711700 SBGC:#711700 FGC:#FFFFFF FSZ:4 BTH:0 TXT:'RESET' SVAL:'reset'" 'Button reset
- Print #1 , "|BT UID:btqt X:13 Y:28 W:10 H:10 SHE:1 ROT:0 RAD:0.5 BGC:#00711700 SBGC:#00711700 FGC:#00FFFFFF FSZ:4 BTH:0 TXT:'Quit app' SVAL:'reset'" 'Button Quit- hidden on text "Counter"
- Print #1 , "@hls 200"
- Enable Int1
- Return
- '==============================================================================
- 'Reading data from serial port - from GUI-O keys (UID names)
- Read_data:
- Bt_key = Inkey(#2)
- If Bt_key = "@" Then Input #2 , Bdata Noecho
- Sep = &H20
- Pozicija = 1
- Znak = Gettoken(bdata , Sep , Pozicija)
- If Znak = "bt5" Then 'Key Reset counter
- Ii = 0
- Iis = Ii
- Iist = Str(ii)
- Iisf = Format(iist , "00000000")
- Setfont Digital14x24
- Lcdat 3 , 1 , Iisf
- Print#1 , "@lbd TXT:'" ; Iisf ; "'"
- Znak = " "
- End If
- If Znak = "btqt" Then
- Print #1 , "@quitapp" 'Quit application
- Znak = " "
- End If
- If Znak = "init" Then 'Start key Initialization
- Gosub Init_gui
- Znak = ""
- End If
- Znak = ""
- Bdata = ""
- Enable Int1
- Return
- '-Procedure for interrupt INT1--------------------------------------------------
- Count:
- Disable Interrupts
- Print #1 , "@si2 EN:1"
- If Inp_ = 0 Then
- Ii = Ii + 1
- While Inp_ = 0
- Wend
- End If
- Iist = Str(ii)
- Iisf = Format(iist , "00000000")
- Setfont Digital14x24
- Lcdat 3 , 1 , Iisf
- Print#1 , "@lbd TXT:'" ; Iisf ; "'"
- Print #1 , "@si2 EN:0"
- Enable Interrupts
- Return
- '-EEprom-----------------------------------------------------------------------
- R_eep:
- ' Readeeprom Ii , &H10 'In case saving data to EEPROM
- Return
- '-GLCD fonts / Logo picture----------------------------------------------------
- $include "Digital14x24.font"
- $include "font5x12.font"
- $include "font8x8.font"
- Logoms:
- $bgf "Logoh2o.bgf"
- '------------------------------------------------------------------------------