0Pricing
Arduino & IoT Academy · Lekcja

Linie, prostokąty i okręgi

Rysować kształty, aby zbudować prosty interfejs użytkownika.

Linie, prostokąty i okręgi to bezpłatna lekcja Arduino & IoT Academy na CoddyKit. To lekcja 3 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.

Beyond Text

Text alone gets dull. The GFX library also draws shapes, so you can frame data, build meters, and design a real little interface. 🎨

The Pixel Grid

Every shape lives on a coordinate grid. Point (0,0) is top-left; x runs right and y runs down, just like the text cursor you already used.

Draw a Single Pixel

The smallest mark is one dot. drawPixel takes an x, a y, and a color, lighting exactly one point on the screen.

display.drawPixel(10, 10, WHITE);

Draw a Line

drawLine connects two points. Give a start x and y, an end x and y, and a color to stroke a straight line between them.

display.drawLine(0, 0, 127, 63, WHITE);

Outline a Rectangle

drawRect needs a top-left x and y, then a width and height. It strokes just the border, perfect for framing a value or a section.

display.drawRect(0, 0, 60, 30, WHITE);

Fill a Rectangle

Swap to fillRect with the same arguments to paint the whole box solid. Filled bars are the heart of meters and progress displays.

display.fillRect(0, 0, 60, 30, WHITE);

Outline a Circle

drawCircle takes a center x and y plus a radius. It strokes a ring, handy for dials, status dots, or rounded icons.

display.drawCircle(64, 32, 20, WHITE);

Fill a Circle

Use fillCircle for a solid disc. A small filled circle makes a clear on/off indicator that is easy to read at a glance.

display.fillCircle(64, 32, 5, WHITE);

Rounded Rectangles

For a softer look, drawRoundRect adds a corner radius after width and height. Rounded boxes make buttons and cards feel friendlier.

display.drawRoundRect(0, 0, 60, 30, 8, WHITE);

Layer Shapes and Text

Order matters: shapes drawn later sit on top. Draw a filled box first, then print text over it for a labeled badge effect.

display.fillRect(0, 0, 50, 16, WHITE);
display.setTextColor(BLACK);

Then Push to Screen

As always, all drawing fills the buffer. End your shape work with display.display() so the whole composed image appears at once.

display.display();

Quick Check

You want a solid bar to show how full a tank is.

Recap

You can now draw pixels, lines, rectangles, and circles, and layer shapes with text. These primitives are all you need to compose a real UI.

Często zadawane pytania

Czy lekcja „Linie, prostokąty i okręgi” jest bezpłatna?

Tak — pełny tekst „Linie, prostokąty i okręgi” 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 „Linie, prostokąty i okręgi”?

Rysować kształty, aby zbudować prosty interfejs użytkownika. Ć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 3 z 4.

Ile czasu zajmuje lekcja „Linie, prostokąty i okręgi”?

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