Notifications
Clear all

Potentiometer with Arduino

9 Posts
4 Users
0 Likes
1,813 Views
Sumanta
(@sumanta)
Member
Joined: 3 years ago
Posts: 197
Topic starter  
Screenshot 20210111 113413~2

Recently, I made an Arduino project to dim and brighten a LED with a potentiometer. I used the above code. Please explain the significance of potValue/4 in the analogRead() function.

Thanks in advance 🙂 


   
Quote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

@sumanta

The analog input is 0 to 1023 whereas the analog output is 0 to 255.

https://www.instructables.com/Controlling-LED-by-Potentiometer-With-Arduino-Uno-/

 


   
ReplyQuote
Sumanta
(@sumanta)
Member
Joined: 3 years ago
Posts: 197
Topic starter  

@robotbuilder Thank you for the link and the explanation. 😀 


   
ReplyQuote
butch
(@butch)
SLOTCARS
Joined: 3 years ago
Posts: 12
 

instead of a resistor can a use a rotary encoder to ramp the voltage of 12 volts dc from 0 to 12 volts but only use 45 to 60 degrees of rotation? i was thinking i saw you make a car and it had a pwm and used a analog of 0 to 1023 or you coverted it to 0 to 255 in the program.

i could do this and put in the program for every step in the encoder the program would be 1/2 volt. depending on how far i would want the rotary encoder to turn. so if the encoder steped 24 times @ 1/2 volt i would get 12 volts out put from let say 40 degrees depends on the rotary encoder and how many steps it has, and if i wanted less of more could i change the voltage per step or the steps per voltage?

i think i am starting to get the pwm encoder part i need to learn the code to make it work.

then i would need to figure out how to use a mosfet for high amp out put.

is there a mosfet that opperates on a 0 to 12 volts to have the voltage rise and fall for 12 volts?

it would be best if i had 60 steps or more to control the voltage. is there a way to control the voltage by rotary encoder of 1tenth volt per space? i just do not know how to adjust the rotation of the rotary encoder.

the reason i want to use a encoder is that it will last for ever and it would rotate so much smoother with no contacts.

i hope some knows how to do this opperation.


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@sumanta

Posted by: @sumanta
Screenshot 20210111 113413~2

Recently, I made an Arduino project to dim and brighten a LED with a potentiometer. I used the above code. Please explain the significance of potValue/4 in the analogRead() function.

Thanks in advance 🙂 

Analog input provides 10 bit resolution (2^10) == 1024 values (0-1023)

Digital output provides 8 bits of resolution (2^8) == 256 values (0-255)

= (2^10) / (2^8) == 1024 / 256 = 4

So in essence it's just another way to map values from analog to digital.


   
ReplyQuote
Sumanta
(@sumanta)
Member
Joined: 3 years ago
Posts: 197
Topic starter  

@frogandtoad Okay. I have understood that. Thanks for it. 😀 


   
ReplyQuote
Sumanta
(@sumanta)
Member
Joined: 3 years ago
Posts: 197
Topic starter  

Anyone has any idea how to use this in a breadboard? (I don't know how to solder)

220px Electronic Component Potentiometer

   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

Nope.  You have to solder some leads onto it.  Or maybe use wires with alligator clips on each end and clip onto the end of one of the wires you are using to to connect up your breadboard .  Soldering is an important part of an electronic hobby. Can you get this type from your supplier?

POT

 

 


   
ReplyQuote
Sumanta
(@sumanta)
Member
Joined: 3 years ago
Posts: 197
Topic starter  

@robotbuilder Yeah. I will try to get this type. 

Thanks for the idea of alligator clips. 😀 


   
ReplyQuote