A better mapping with map()

It should be easy, right? map(x, 0, 1023, 0, 10) and any analog input reading becomes a digit from 0..10. Yes, but not like you'd think.

Jan 10, 2021

19835 views

1 respects

Components and supplies

1

Breadboard (generic)

1

Rotary potentiometer (generic)

1

Arduino UNO

1

Hook Up Wire Kit, 22 AWG

10

Through Hole Resistor, 330 ohm

1

10 LEDs Bar Array, Green

Project description

Code

Demo code for map() function

arduino

This is the code used to debug the flickering 9th LED.

Bargraph Voltmeter

arduino

Read analog input voltage and light one of ten LEDs on a bargraph, or none if the voltage is below the lowest threshold.

Bargraph Voltmeter

arduino

Read analog input voltage and light one of ten LEDs on a bargraph, or none if the voltage is below the lowest threshold.

Demo code for map() function

arduino

This is the code used to debug the flickering 9th LED.

Downloadable files

Bargraph Voltmeter (schematic)

Screenshot image of KiCAD schematic.

Bargraph Voltmeter (schematic)

Bargraph Voltmeter (KiCAD schematic)

Indicate potentiometer voltage on LED bargraph display.

Bargraph Voltmeter (KiCAD schematic)

Bargraph Voltmeter (KiCAD schematic)

Indicate potentiometer voltage on LED bargraph display.

Bargraph Voltmeter (KiCAD schematic)

Comments

Only logged in users can leave comments