Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

How to check LED Blinking then write data 6 Bits ? [mikro C]

Status
Not open for further replies.

boyguitar1

Member level 1
Joined
Nov 8, 2010
Messages
33
Helped
12
Reputation
24
Reaction score
12
Trophy points
1,288
Activity points
1,486
Hi Everybody

Can anyone help this case ? Now I have LED Blinking freq 1.2 Hz and
I need to check status during LED Blinking…. Is it blink or not ?
then let mikroC send data 6 bits to my VB.

Now I have wrote some code below by use PIC16F877.
But still not work....:sad:

Code:
void  Check_Blinking_LED()
{
      for(i=0;i<6;i++)      
      {
  analog_val = Adc_Read(1);      // Read analog from CH1
  Delay_ms(10);
  analog_val = ((analog_val *2000)/ 2046);

      Delay_ms (417); 			
    // 417 come from Time 830/2 ms = 415 ms
    // But use more 415 ms to check High and Low pulse.

      if (analog_val_LED_GREEN > 500)         
      Usart_Write('H');
      else
      {Usart_Write('L');}
      }
}
Form my code it will write H to VB ,write L to VB , …… (until 6 Bits)
So this my problem VB cannot detect.

My target:

If LED Blinking : mikro C must send HLHLHL or LHLHLH to my VB.
If LED Light : mikro C must send HHHHHH to my VB.
If LED Off : mikro C must send LLLLLL to my VB.
----------------------------------------------------------------

Or do u have other good idea ? please help..



Please help...
Thank in advance
BGT.
 
Last edited:

pmar_kpj

Member level 3
Joined
Feb 5, 2006
Messages
57
Helped
11
Reputation
22
Reaction score
10
Trophy points
1,288
Location
Romania
Activity points
1,616
hi !

you read the analog value but procesing this signal after ~500ms.

try this:

void Check_Blinking_LED()
{
for(i=0;i<6;i++)
{
analog_val = Adc_Read(1); // Read analog from CH1
Delay_ms(10);
analog_val = ((analog_val *2000)/ 2046);

if (analog_val_LED_GREEN > 500)
Usart_Write('H');
else
{Usart_Write('L');}
}

Delay_ms (417);
// 417 come from Time 830/2 ms = 415 ms
// But use more 415 ms to check High and Low pulse.

}
 

boyguitar1

Member level 1
Joined
Nov 8, 2010
Messages
33
Helped
12
Reputation
24
Reaction score
12
Trophy points
1,288
Activity points
1,486
hi pmar_kpj

Thanks 4 ur suggestion.
but after testing Yeah!...it already can sent data 6 bits LLLLLL or HHHHHH /1 time.
it seem that cannot detect pulse signal high and low .....which what I want is HLHLHL or LHLHLH .

Can anyone help me please...or advice me to other idea you have.
Thanks..
BGT
 

pmar_kpj

Member level 3
Joined
Feb 5, 2006
Messages
57
Helped
11
Reputation
22
Reaction score
10
Trophy points
1,288
Location
Romania
Activity points
1,616
hi!

try this:

void Check_Blinking_LED()
{
for(i=0;i<6;i++)
{
analog_val = Adc_Read(1); // Read analog from CH1
Delay_ms(200);

if (analog_val_LED_GREEN > 750) //>~3.7V
Usart_Write('H');
if (analog_val_LED_GREEN < 250) //>~1.2V
Usart_Write('L');
}
}
if your led blink with 1.2 hz function writed up send to rs232 : LLL HHH LLL HHH ....

or to test if your function work connect the ch1 to 5V and receve HHHH....
connect ch1 to GND and receve LLLL.. (5 char per second)!

but for this you need to replace the 'for' instruction with infinite loop like: do { ...} while (1);
 
Last edited:

hanukaran

Junior Member level 2
Joined
Oct 15, 2010
Messages
24
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,283
Activity points
1,542
hi boyguitar....can you teach me how to use this visual basic to show this led..currently im working on traffic light project....im using ATmega32.....can you teach me how to programme it
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top