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.

[AVR] C Language Code Logic

Status
Not open for further replies.

Titus Manoj Kumar

Junior Member level 2
Joined
Oct 18, 2013
Messages
24
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
Sriperumpudur, Tamil Nadu
Activity points
178
Hi all,

I ve a question..

I've two int values (0 to 9) in two variables h_i and h_j

based on that values am going to switch On/Off any device.(ex.led)

ex: if the value is 22 ; led should blink 22 times.

What's the logic should we use in the code?

Thanks.
 

Hi.,

Thanks for the reply.
But what if suppose the value (22) in which 1st 2 is in h_i and second 2 is in h_j.?

Plz do see this image

https://obrazki.elektroda.pl/4758763400_1390814113.jpg

The value will be entered in the LCD using the switches.
Depending on the values the relays should be switched ON/OFF.

Pls do help.
Thank you.
 

If one is the tens digit and the other the units digit you can either do a units loop inside a tens loop or combine them into a single number.
For example "NewVariable = (h_i * 10) + h_j;" which makes NewVariable equal to 22 using your numbers as an example.

Incidentally, you should NEVER drive relay coils directly from a microcontroller! It almost certainly can't provide enough current and in any case would be damaged by back-EMF as the relay turns off.

Brian.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top