0Pricing
Arduino & IoT Academy · Lekcja

Animowanie wykresu słupkowego

Wizualizować zmieniające się wskazania czujnika za pomocą ruchomego słupka.

Animowanie wykresu słupkowego to bezpłatna lekcja Arduino & IoT Academy na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Arduino & IoT Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Arduino & IoT Academy zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

Why a Bar Graph

Numbers are precise, but a bar tells the story instantly. A growing bar shows a rising sensor value far faster than reading digits. 📊

Start From a Reading

Animation begins with fresh data. Each loop you grab a new sensor value, for example an analogRead that lands between 0 and 1023.

int value = analogRead(A0);

Map to Bar Width

The raw range rarely matches the screen. Use map to rescale 0-1023 into 0-128 pixels so the value fits your display width.

int barWidth = map(value, 0, 1023, 0, 128);

Clamp the Result

A noisy reading can overshoot. Wrap it in constrain so the bar never draws past the screen edge and corrupt the layout.

barWidth = constrain(barWidth, 0, 128);

Clear Each Frame

Animation is just redrawing fast. Every frame starts with clearDisplay so the old bar vanishes before the new length is drawn.

display.clearDisplay();

Draw the Bar

Now paint the bar with fillRect, using your mapped width. A fixed x, y, and height keep it steady while the width breathes with the data.

display.fillRect(0, 28, barWidth, 8, WHITE);

Add a Frame

Outline the full track with drawRect so users see the maximum. The fill grows inside this border, giving the bar clear context.

display.drawRect(0, 28, 128, 8, WHITE);

Label the Value

Pair the bar with the exact number. Set the cursor above it and print the reading so users get both the shape and the precise figure.

display.setCursor(0, 0);
display.print(value);

Push the Frame

Send the finished frame with display.display(). Because the whole buffer updates at once, the bar moves cleanly with no half-drawn flicker.

display.display();

Pace the Animation

Redrawing as fast as possible looks jittery. A small delay of 50 milliseconds smooths motion and steadies a twitchy sensor reading.

delay(50);

The Full Loop

Put it together: read, map, clear, draw, display, pause. That cycle in loop() is the engine behind every live OLED animation you build.

Quick Check

Your bar shows ghost trails from previous frames.

Recap

You turned readings into a live bar graph: read, map, constrain, clear, fill, frame, label, and display in a paced loop. That is real-time visualization.

Często zadawane pytania

Czy lekcja „Animowanie wykresu słupkowego” jest bezpłatna?

Tak — pełny tekst „Animowanie wykresu słupkowego” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Arduino & IoT Academy, przejdź na CoddyKit PRO. Kurs Arduino & IoT Academy zawiera 4 lekcji w sumie.

Co nauczysz się w „Animowanie wykresu słupkowego”?

Wizualizować zmieniające się wskazania czujnika za pomocą ruchomego słupka. Ćwiczysz Arduino & IoT Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Arduino & IoT Academy?

Nie wymagamy żadnego doświadczenia. Arduino & IoT Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.

Ile czasu zajmuje lekcja „Animowanie wykresu słupkowego”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Arduino & IoT Academy?

Tak. Każda lekcja Arduino & IoT Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Podłączanie i inicjalizacja OLED SSD1306
  2. Rysowanie tekstu w wielu rozmiarach
  3. Linie, prostokąty i okręgi
  4. Animowanie wykresu słupkowego
← Powrót do Arduino & IoT Academy