⚡
usefultools.dev
INO

Arduino-Syntax-Highlighter (Code zu HTML)

NEU

Arduino-Syntax-Highlighter, der .ino- und C++-Code in farbiges HTML mit Zeilennummern, hellen oder dunklen Themes sowie Inline-Styles oder CSS-Klassen umwandelt.

Läuft zu 100 % in deinem Browser — deine Eingaben werden nie hochgeladen oder auf unseren Servern gespeichert.

Vorschau

1#include <Wire.h>
2#define BUTTON_PIN 2
3
4volatile bool pressed = false;   // set in the ISR
5const unsigned long DEBOUNCE_MS = 50UL;
6
7void onPress() {
8  pressed = true;
9}
10
11void setup() {
12  Serial.begin(115200);
13  pinMode(LED_BUILTIN, OUTPUT);
14  pinMode(BUTTON_PIN, INPUT_PULLUP);
15  attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), onPress, FALLING);
16}
17
18void loop() {
19  if (pressed) {
20    pressed = false;
21    int raw = analogRead(A0);
22    float volts = raw * (5.0 / 1023.0);
23    Serial.print(F("A0 = "));
24    Serial.println(volts, 2);
25    digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
26    delay(DEBOUNCE_MS);
27  }
28}
  • Schlüsselwort (3)
  • Typ (8)
  • Konstante (10)
  • Arduino-Funktion (14)
  • Arduino-Objekt (3)
  • Funktionsaufruf (1)
  • String / Zeichen (2)
  • Zahl (6)
  • Kommentar (1)
  • Präprozessor (2)
  • Operator (12)

Eigenständig: Füge es in einen Blog-Editor, einen Forenbeitrag, eine E-Mail oder ein CMS ein, das <style>-Tags entfernt.

<pre style="margin:0;padding:12px 16px;background:#ffffff;color:#434f54;font-family:ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;font-size:14px;line-height:1.5;tab-size:2;overflow-x:auto;border-radius:6px"><code><span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">1</span><span style="color:#728e00;font-weight:600">#include</span> <span style="color:#005c5f">&lt;Wire.h&gt;</span>
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">2</span><span style="color:#728e00;font-weight:600">#define</span> BUTTON_PIN <span style="color:#8a7b52">2</span>
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">3</span>
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">4</span><span style="color:#728e00;font-weight:600">volatile</span> <span style="color:#00979c">bool</span> pressed <span style="color:#434f54">=</span> <span style="color:#00979c">false</span>;   <span style="color:#95a5a6;font-style:italic">// set in the ISR</span>
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">5</span><span style="color:#728e00;font-weight:600">const</span> <span style="color:#00979c">unsigned</span> <span style="color:#00979c">long</span> DEBOUNCE_MS <span style="color:#434f54">=</span> <span style="color:#8a7b52">50UL</span>;
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">6</span>
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">7</span><span style="color:#00979c">void</span> <span style="color:#434f54">onPress</span>() {
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">8</span>  pressed <span style="color:#434f54">=</span> <span style="color:#00979c">true</span>;
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">9</span>}
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">10</span>
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">11</span><span style="color:#00979c">void</span> <span style="color:#d35400">setup</span>() {
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">12</span>  <span style="color:#d35400">Serial</span><span style="color:#434f54">.</span><span style="color:#d35400">begin</span>(<span style="color:#8a7b52">115200</span>);
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">13</span>  <span style="color:#d35400">pinMode</span>(<span style="color:#00979c">LED_BUILTIN</span>, <span style="color:#00979c">OUTPUT</span>);
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">14</span>  <span style="color:#d35400">pinMode</span>(BUTTON_PIN, <span style="color:#00979c">INPUT_PULLUP</span>);
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">15</span>  <span style="color:#d35400">attachInterrupt</span>(<span style="color:#d35400">digitalPinToInterrupt</span>(BUTTON_PIN), onPress, <span style="color:#00979c">FALLING</span>);
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">16</span>}
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">17</span>
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">18</span><span style="color:#00979c">void</span> <span style="color:#d35400">loop</span>() {
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">19</span>  <span style="color:#728e00;font-weight:600">if</span> (pressed) {
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">20</span>    pressed <span style="color:#434f54">=</span> <span style="color:#00979c">false</span>;
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">21</span>    <span style="color:#00979c">int</span> raw <span style="color:#434f54">=</span> <span style="color:#d35400">analogRead</span>(<span style="color:#00979c">A0</span>);
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">22</span>    <span style="color:#00979c">float</span> volts <span style="color:#434f54">=</span> raw <span style="color:#434f54">*</span> (<span style="color:#8a7b52">5.0</span> <span style="color:#434f54">/</span> <span style="color:#8a7b52">1023.0</span>);
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">23</span>    <span style="color:#d35400">Serial</span><span style="color:#434f54">.</span><span style="color:#d35400">print</span>(<span style="color:#d35400">F</span>(<span style="color:#005c5f">&quot;A0 = &quot;</span>));
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">24</span>    <span style="color:#d35400">Serial</span><span style="color:#434f54">.</span><span style="color:#d35400">println</span>(volts, <span style="color:#8a7b52">2</span>);
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">25</span>    <span style="color:#d35400">digitalWrite</span>(<span style="color:#00979c">LED_BUILTIN</span>, <span style="color:#434f54">!</span><span style="color:#d35400">digitalRead</span>(<span style="color:#00979c">LED_BUILTIN</span>));
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">26</span>    <span style="color:#d35400">delay</span>(DEBOUNCE_MS);
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">27</span>  }
<span style="display:inline-block;min-width:2ch;margin-right:16px;text-align:right;color:#95a5a6;user-select:none">28</span>}</code></pre>
⚡

Schnelle Beispiele

Typische Eingaben und die Ergebnisse, die dieses Tool liefert.

Arduino-API
pinMode(13, OUTPUT);
API · Zahl · Konstante
Serial
Serial.println("Hi");
Objekt · API · String
Makro
#define LED 13
Präprozessor · Zahl
Typen
uint8_t v = analogRead(A0);
Typ · API · Konstante
Bibliothek
myServo.write(90);
Funktionsaufruf · Zahl
📖

Überblick

Dieser Arduino-Syntax-Highlighter wandelt einen Sketch in farbiges HTML um, das du in einen Blogbeitrag, eine Projektdokumentation, eine Kursseite oder ein Forum einfügen kannst, das HTML akzeptiert. Er erkennt C++-Schlüsselwörter und -Typen, Arduino-Typen wie byte und uint8_t, Kernfunktionen wie pinMode, digitalWrite, analogRead und millis, Objekte wie Serial und Wire mit ihren Methoden, Konstanten wie HIGH, OUTPUT und A0, Präprozessorzeilen, Strings, Zahlen und Kommentare.

Wähle ein helles Theme im Arduino-Stil oder ein dunkles, schalte Zeilennummern ein oder aus und exportiere entweder eigenständiges HTML mit Inline-Styles oder schlankes Markup mit ino-*-Klassen samt passendem Stylesheet. Der Code wird von einem echten C/C++-Tokenizer gelesen, sodass Raw-Strings, maskierte Anführungszeichen und Blockkommentare korrekt eingefärbt werden, und jedes Zeichen wird HTML-maskiert. Nichts verlässt deinen Browser. Schlüsselwörter und Namen der Arduino-API werden so erkannt, wie sie auf Englisch geschrieben werden.

Warum dieses Tool?

  • Lesbare Sketches in Blogs und Dokumentation teilen
  • Arduino-Funktionen und -Konstanten erhalten eigene Farben
  • Inline-Styles überstehen Editoren, die CSS entfernen
  • Helle und dunkle Themes mit optionalen Zeilennummern
  • Privat: Das Hervorheben läuft lokal
⭐

Funktionen

🎨

Vier Themes

Arduino-style Light, GitHub Light, One Dark und Monokai mit Live-Vorschau.

🔌

Arduino-bewusst

Eigene Farben für Funktionen der Kern-API, Serial-/Wire-/SPI-Objekte und Konstanten wie HIGH, INPUT_PULLUP und A0.

✉️

HTML mit Inline-Styles

Jede Farbe steht direkt im Markup, sodass es in CMS-Editoren und E-Mails dargestellt wird.

🧾

Klassen + CSS

Kleineres Markup mit den Klassen ino-kw, ino-api, ino-str … und einem kopierbaren Stylesheet.

🔢

Zeilennummern

Optional, rechtsbündig und beim Kopieren des Codes nicht mit ausgewählt.

🔒

Maskierte Ausgabe

<, > und & in deinem Code werden maskiert, sodass #include <Wire.h> die Seite nicht zerstören kann.

🛠️

So funktioniert’s

1

Sketch einfügen

Füge Arduino- oder C++-Code ein oder drücke Beispiel.

2

Theme und Optionen wählen

Wähle ein Theme, die Tab-Breite und ob Zeilennummern angezeigt werden sollen.

3

HTML-Format wählen

Inline-Styles für Editoren und E-Mail oder Klassen + CSS für deine eigene Website.

4

Kopieren

Nutze HTML kopieren (und CSS kopieren beim Klassenformat) und füge es in deine Seite ein.

🤔

Häufig gestellte Fragen