Untitled
unknown
plain_text
a year ago
1.1 kB
31
Indexable
#include <TM1638plus.h> TM1638plus display(2, 3, 4); // Pin configuration: DIO, CLK, STB const int potPin = A0; const int minValue = 0; const int maxValue = 1023; const int minOutput = 1; const int maxOutput = 80; void setup() { display.displayBegin(); // Initialize the TM1638plus display Serial.begin(9600); } void loop() { int potValue = analogRead(potPin); // Read potentiometer value int scaledValue = map(potValue, 0, 1023, 1, 80); // Map the value to the range 1-10 displayNumber(scaledValue); // Display scaled value on TM1638 Serial.println(scaledValue); delay(100); } void displayNumber(int number) { // Clear the display /// Display the number on the 8-digit 7-segment display, moving from right to left for (int i = 0; i < 8; ++i) { int digit = number % 10; display.displayASCII(6, '.'); display.displayHex(7 - i, digit); // Use displayHex instead of display, and invert the index number /= 10; } // Update the display (if the library has an update method) // display.update(); }
Editor is loading...
Leave a Comment