Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Can you control LEDs using Visual Basic.

Status
Not open for further replies.

ankitvirdi4

Member level 4
Joined
Mar 13, 2012
Messages
70
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,288
Location
India
Activity points
1,924
Hey guys,
I am working on a project using Visual Basic( Ver. 2010 Express) which basically displays and controls the status of a few devices. There are 5 devices in all, I want to represent a device with a LED.

So, basically I just want to control 5 LEDs using VB. I know it possible using the serial port. I guess there are two ways in which we can do this.

1. Using UART of a microcontroller (I am bad at UART programming)

2. Making a serial to parallel converter and controlling the LEDs directly.


I have a few questions about the 2nd method.
Is that possible?
Which IC do I use in it?
What about the baud rate, will it affect the LEDs?
Has anyone done this before?
 

zeyad.kassaby

Member level 2
Joined
Jun 17, 2007
Messages
43
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,288
Activity points
1,528
Yes,it's possible.
buy usb parallel converter and if your pc has a parallel port it will be much easier
baud rate will not be a problem if you have in your design a hold bit control
.just tell me if you have a parallel port or not
if not check at any computer store if they have a usb multi connection(parallel serial vga) if not all of these then build a usb to parallel or serial to parallel ,plz send feed back to help you more
Zeyad
 

ankitvirdi4

Member level 4
Joined
Mar 13, 2012
Messages
70
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,288
Location
India
Activity points
1,924
Thanks Zeyad.
I am working on my laptop which has just serial ports (USBs). Can you provide the circuit diagram for a USB to parallel conversion?

And by hold bit control what do you mean? should that be in my VB code or in the circuit?
 

zeyad.kassaby

Member level 2
Joined
Jun 17, 2007
Messages
43
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,288
Activity points
1,528
software in C included you can customize it for any microchip controller
www.mikro.com




Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 * Project name:
     Uart1_Test (Usage of mikroC for dsPIC30/33 and PIC24 UART libraries)
 * Target Platform:
     dsPIC;
 * Copyright:
     (c) mikroElektronika, 2006.
 * Revision History:
     20060510:
       - Initial release;
 * Description:
     This simple example demonstrates usage of mikroC's UARTx libraries, through
     a 'loopback' interface. The data being sent to dsPIC through UART
     and sent back.
 * Test configuration:
     MCU:             dsPIC30F4013
     Dev.Board:       EASYdsPIC4
     Oscillator:      XT-PLL4, 10.000MHz
     Ext. Modules:    None.
     SW:              mikroC for dsPIC30/33 and PIC24 v4.0.0.0
 * NOTES:
     - You can use the same example for UART2 module, just change the '1's in
       library function names to '2', e.g. Uart1_Init() -> Uart2_Init();
 */
 
 
unsigned rx1;
 
void main() {
  //--- turn off A/D inputs
  ADPCFG = 0xFFFF;
  LATB = 0;
  TRISB = 0;
  LATC = 0;
  TRISC = 0;
  LATD = 0;
  TRISD = 0;
  LATF = 0xFFFF;
  TRISF = 0;
  
  Uart1_Init(9600);                 // initialize USART module
 
 
  //--- un-comment the following lines to have Rx and Tx pins on their alternate
  //    locations. This is used to free the pins for other module, namely the SPI.
    U1MODEbits.ALTIO = 1;
    Delay_ms(10);                     // pause for usart lines stabilization
    rx1 = Uart1_Read_Char();          // perform dummy read to clear the register
 
  Uart1_Write_Char('s');            // signal start
 
  while(1) {
    if (Uart1_Data_Ready())  {     // check if there is data in the buffer
     rx1 = Uart1_Read_Char();      // receive data
     Uart1_Write_Char(rx1);           // send data back
     if (rx1='R') {
        LATB = 1;
        Delay_ms(1000);
     }
     if (rx1='r') {
     LATB = 0;
     Delay_ms(1000);
     }
     if (rx1='R') {
     }
    }
  }
}//~!

 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top