Continue to Site

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.

need help for sensor code

Status
Not open for further replies.

kidd

Newbie level 2
Joined
Jun 18, 2010
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,293
right now , i am doing C programming for my board.
the task is write a code of " XYZ sensor that tilt either way, the program must let the LED light up , and it will tilt back to be constant."
please help .
thanks alot.
 

Is the sensor analog or digital?

I find analog easier to write for. In a loop, start ADC and get a sample of each XYZ. IF statement to compare sample to greater / less than constant number threshold which turns on LED, ELSE turns off LED.
 

my sensor reading is analog.
can you give me example of how to write the code to compare the reading to allow the led light up else light off.
 

If you just want to operate LED with accordance to Sensor.
then Just use Opam and a Transistor to generate low and high signals.

Then you can connect the output of the Transistor to the Interrupt pin and program accordingly.
or
U can use polling method to check the status of the sensor output on the PIN.

Op Amp Intro
Operational Amplifier Switches

Thanks & Regards,
Vasu
No SIGNATURE LINKS ALLOWED
 

Which microcontroller are you using?

By using microcontroller with small C coding you can read than analog voltage through internal ADC of microcontroller and then compare that analog value to your C program constant value to Turn ON or OFF the LED.

Regards
Chanchal
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top