Let's Make Robots!

Any explanation for this "weird" thing?!

 

 

Hi,

long time ago when i started learning electronics and while i was playing with microcontroller programming, i found out this strange behavior, i do not remember what exactly i was trying to do :D, anyway, i waill be glad if someone explains what is going on.

as you can see when i get my hand close to PORTB.3, the led switches on "see the code below".

 

Notes:

*this works only if you are using DC power supply.

*this will not work if your home suffers from power outage!!!

 

The code "ProtonBaisc":

Device = 16F628A

Config INTRC_OSC_NOCLKOUT, WDT_OFF, PWRTE_ON, BODEN_OFF, LVP_OFF, CP_OFF, MCLRE_ON, DATA_CP_OFF

Xtal = 4

Dim led As PORTB.4

Dim var1 As Word

 

Main:

PulsIn PORTB.3,1,var1

If var1 = 0 Then

Low led

GoTo Main

EndIf

 

High led 

GoTo Main

End

 

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Khalid Fawzy's picture

thank you so much, this explains everything :)

OddBot's picture

It's just electrical noise. CMOS inputs are very sensitive to electrical noise. Your body is acting as an antenna and picking up the 50Hz/60Hz hum of your mains.

This effect is sometimes used on purpose to make a close range proximity detector. A Thermin synthesizer uses a similar technique.