2020. 1. 24. 15:08ㆍ카테고리 없음
I will share my experience about how to turn on and off 8 leds through the widget made using visual basic 6. I am using visual basic 6 because the file is not large and light program execution. How its work?8 pieces led Arduino connected to a digital channel from D2. Each LED in series with a resistor about 120Ohm is connected to GND. Thus each led will turn of in a logic 1. Arduino programOn the Arduino board, was created a program to accept the character as a command to turn off and turn on each LED. Command of the character of 1,2,3,4,5,6,7,8, used to turn on or turn off each LED on arduino board as toggle function. Other characters as command of “.” character serves to turn on all LED.
Cara Menghubungkan Arduino Ke Visual Basic
Feb 15, 2014 Program java dibawah ini menggunakan library RxTx untuk membaca data dari arduino. Pertama kita import terlebih dahulu library RXTX. Untuk menggunakan library RxTx, setelah import library jangan lupa copykan file rxtxSerial.dll ke folder C:/Windows/System32. Langsung saja dibawah ini adalah program java untuk membaca data dari arduino. Oke langsung saja, hari ini saya memberikan Tutorial Arduino. Yaitu komunikasi serial antara Arduino dengan Visual basic, sama saja seperti komunikasi serial antara Arduino dan Android di postingan saya sebelumnya, perbedaan hanya terletak pada cara berkomunikasinya. Alat dan Bahan yang dibutuhkan: 1x Arduino UNO; 1x LED ( Warna Bebas ). Cara Menghubungkan Program VB dengan Proteus menggunakan VSPE 1. Buka Program VSPE. Klik New Device. Buka program Arduino Buat script seperti ini Klik Tombol Verifikasi Copy File.hex dari verifikasi program arduino tersebut. Berbagi ke Twitter Berbagi ke Facebook Bagikan ke Pinterest. Tidak ada komentar: Posting Komentar.
The character “-” to order all led to turn off.Each character as commands are sent serially to the Arduino board. Thus, the Arduino will send back all conditions of leds in string form., for example, “10101010″. The character “0″ means the condition of the LED is die and vice versa “1″ is alive.
Variable and serial eventAs a global variable is “charCmd” defined as byte to hold a character as a command that sent from the PC. Variable of ccmdOk defined as boolean is a flag to mark that character just received from PC. The special variable is stateLED defined as char. This is for holding the state of 8 LEDs in bit for each LED.The serialEvent function is event interrupt of microcontroler. This function by default on arduino will call automatically if just completely receive a char from RX pin. If the character has been received from PC, the result will be stored in the variable of “charCmd”, then flag of “cmdOk” is set to “true”.
FunctionsTwo functions are made to treat the LED on the Arduino board are:. setLEDServes to turn on or turn off each LED corresponding to logic of each bit in the variable conditions of stateLED. Line 28, is looping to get each bit of stateLED variable. Every bit of stateLED variable, is tested using bitRead function. Thus, written to digital channel of arduino. The status of each led is sent to serial and received by PC as hanshaking or display status. invertLEDThis function serve to invert the logic of each bit on stateLED variable, indexed by n variable.
This function have one passing parameter to point each bit on stateLED variable.Setup functionThis initialization are open serial using 115200baud and making D2 to D9 as output, also all LEDs turn off. For shortened codes, i used loop of for statement and variable of d is used as index of digital channels that to be connected to LEDs. Loop functionThe loop functio checks if there are characters that is sent by the PC. If the variable cmdOk = true, then there are characters received from the PC is stored in the variable of charCmd. Next tested whether the character is ’1′ to ”8′, ‘.’ or ‘-’. If the character are ’1 ‘to ’8′, will call the function of invertLED, means reversing the logic of each bit on variable of stateLED. If the character is ‘.’, stateLED will be assigned to 255 (all LEDs will be turned on), ‘-’ stateLED will be assigned to 0 (all LEDs will be turned off).Source code of arduino program can be.Widget of visual basic 6I made this widget by using Visual Basic 6. You can install directly to a computer to download the setup program by. Or you can download the source program.
Do not forget to include the name of program creator, and web link on your project. DemoLast updated by at October 3, 2012.