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.

[SOLVED] Why this code not working as expected?

Status
Not open for further replies.
Advanced Member level 6
Joined
Dec 4, 2012
Messages
4,280
Helped
822
Reputation
1,654
Reaction score
791
Trophy points
1,393
Location
Bangalore, India
Visit site
Activity points
0
Why this code not working as expected?

According to code, If + button is pressed the adc variable value should go upto 255 and stop. If decrement button is pressed it should go to min 0 and stop. adc variable is multiplied by 2 and written to POT. So, for 255 steps I should get 510 max adc value from channel 3. It is incrementing beyond range.
 

Attachments

  • AC.rar
    60.4 KB · Views: 74

In your code, you have the variables adc and adcval? A mistake?

You read the a/d and stored the result to adcval, but used another variable adc in other sections in your code. :!:
 

adc variable is used for incrementing and decrementingc POT value. The POT o/p is fed to ADC input. ADC is read and assigned to adcval variable.


Problem solved. I had to use int type for adc variable.
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top