Stupid trick
Idea explanation: Since the knob has a range from 0 to 1023, I was thinking about creating 3 sets of button-LED mismatch within a certain range (0~340, 340~680, 680~1023). However, the result turns out to be that I am controlling the LED with the knob instead of the button(??
Class notes
Image: https://content.arduino.cc/assets/Pinout-NANO33IoT_latest.png
Digital I/O
Analog
— measure something that has a range (range of values, true for both input and output)
analogWrite( ) only mimics variable voltage output using values 0 – 255
Often times we need to use the map( ) function to convert our input range of 0-1023, to our output range of 0-255
the sensor itself is a resistor
A potentiometer is a manually adjustable variable resistor with 3 terminals.
If you want to change the brightness of the LED, have to use the pin with “~”
change the brightness of the LED:
other ways:
- using constrain function
- use map function — in this way when you can hit the 2 ends of the potentiometer [subtle but helpful]
light sensor: (first figure out the range of the sensor, then map the range)
Leave a Reply