.chip.json` definiert. Der Buffer nutzt 32 Bit pro Pixel. Pixel werden im RGBA Format gespeichert. Die Gesamtgröße des Buffers ist `pixel_width * pixel_height * 4` bytes.
9 |
10 | ### buffer_t framebuffer_init(uint32_t *pixel_width, uint32_t *pixel_height)
11 |
12 | Gibt den Framebuffer für den Chip und die Maße des Displays zurück.
13 |
14 | :::warning
15 |
16 | Info: `framebuffer_init` kann nur von der `chip_init()` Methonde aufgerufen werden. Bitte rufe es nicht zu einem späteren Zeitpunk auf.
17 |
18 | :::
19 |
20 | ### void buffer_write(buffer_t buffer, uint32_t offset, void \*data, uint32_t data_len)
21 |
22 | Kopiert `data_len` bytes von `data` am gegebenen `offset` in den Buffer.
23 |
24 | ### void buffer_read(buffer_t buffer, uint32_t offset, void \*data, uint32_t data_len)
25 |
26 | Kopiert `data_len` bytes am gegebenen `offset` vom Buffer nach `data`.
27 |
28 | ## Beispiele
29 |
30 | - [Basic Framebuffer Chip Example](https://wokwi.com/projects/330503863007183442)
31 | - [SSD1306 I2C OLED Display](https://wokwi.com/projects/371050937178768385)
32 | - [IL9163 128x128 Color LCD Display Driver](https://wokwi.com/projects/333332561949360723)
33 |
--------------------------------------------------------------------------------
/i18n/de-DE/docusaurus-theme-classic/footer.json:
--------------------------------------------------------------------------------
1 | {
2 | "link.title.Docs": {
3 | "message": "Dokumentation",
4 | "description": "The title of the footer links column with title=Docs in the footer"
5 | },
6 | "link.title.Community": {
7 | "message": "Community",
8 | "description": "The title of the footer links column with title=Community in the footer"
9 | },
10 | "link.title.More": {
11 | "message": "Mehr",
12 | "description": "The title of the footer links column with title=More in the footer"
13 | },
14 | "link.item.label.Welcome": {
15 | "message": "Willkommen",
16 | "description": "The label of footer link with label=Welcome linking to /"
17 | },
18 | "link.item.label.diagram.json": {
19 | "message": "diagram.json",
20 | "description": "The label of footer link with label=diagram.json linking to /diagram-format"
21 | },
22 | "link.item.label.Discord": {
23 | "message": "Discord",
24 | "description": "The label of footer link with label=Discord linking to https://wokwi.com/discord"
25 | },
26 | "link.item.label.Twitter": {
27 | "message": "Twitter",
28 | "description": "The label of footer link with label=Twitter linking to https://twitter.com/WokwiMakes"
29 | },
30 | "link.item.label.Blog": {
31 | "message": "Blog",
32 | "description": "The label of footer link with label=Blog linking to https://blog.wokwi.com"
33 | },
34 | "link.item.label.GitHub": {
35 | "message": "GitHub",
36 | "description": "The label of footer link with label=GitHub linking to https://github.com/wokwi/wokwi-docs"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/i18n/de-DE/docusaurus-theme-classic/navbar.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": {
3 | "message": "Wokwi",
4 | "description": "The title in the navbar"
5 | },
6 | "item.label.Docs": {
7 | "message": "Dokumentation",
8 | "description": "Navbar item with label Docs"
9 | },
10 | "item.label.Blog": {
11 | "message": "Blog",
12 | "description": "Navbar item with label Blog"
13 | },
14 | "item.label.Simulator": {
15 | "message": "Simulator",
16 | "description": "Navbar item with label Simulator"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/i18n/en/docusaurus-plugin-content-docs/current.json:
--------------------------------------------------------------------------------
1 | {
2 | "version.label": {
3 | "message": "Next",
4 | "description": "The label for version current"
5 | },
6 | "sidebar.main.category.Getting Started": {
7 | "message": "Getting Started",
8 | "description": "The label for category Getting Started in sidebar main"
9 | },
10 | "sidebar.main.category.Guides": {
11 | "message": "Guides",
12 | "description": "The label for category Guides in sidebar main"
13 | },
14 | "sidebar.main.category.Diagram Reference": {
15 | "message": "Diagram Reference",
16 | "description": "The label for category Diagram Reference in sidebar main"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/i18n/en/docusaurus-theme-classic/footer.json:
--------------------------------------------------------------------------------
1 | {
2 | "link.title.Docs": {
3 | "message": "Docs",
4 | "description": "The title of the footer links column with title=Docs in the footer"
5 | },
6 | "link.title.Community": {
7 | "message": "Community",
8 | "description": "The title of the footer links column with title=Community in the footer"
9 | },
10 | "link.title.More": {
11 | "message": "More",
12 | "description": "The title of the footer links column with title=More in the footer"
13 | },
14 | "link.item.label.Welcome": {
15 | "message": "Welcome",
16 | "description": "The label of footer link with label=Welcome linking to /"
17 | },
18 | "link.item.label.diagram.json": {
19 | "message": "diagram.json",
20 | "description": "The label of footer link with label=diagram.json linking to /diagram-format"
21 | },
22 | "link.item.label.Discord": {
23 | "message": "Discord",
24 | "description": "The label of footer link with label=Discord linking to https://wokwi.com/discord"
25 | },
26 | "link.item.label.Twitter": {
27 | "message": "Twitter",
28 | "description": "The label of footer link with label=Twitter linking to https://twitter.com/WokwiMakes"
29 | },
30 | "link.item.label.Blog": {
31 | "message": "Blog",
32 | "description": "The label of footer link with label=Blog linking to https://blog.wokwi.com"
33 | },
34 | "link.item.label.GitHub": {
35 | "message": "GitHub",
36 | "description": "The label of footer link with label=GitHub linking to https://github.com/wokwi/wokwi-docs"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/i18n/en/docusaurus-theme-classic/navbar.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": {
3 | "message": "Wokwi",
4 | "description": "The title in the navbar"
5 | },
6 | "item.label.Docs": {
7 | "message": "Docs",
8 | "description": "Navbar item with label Docs"
9 | },
10 | "item.label.Blog": {
11 | "message": "Blog",
12 | "description": "Navbar item with label Blog"
13 | },
14 | "item.label.Simulator": {
15 | "message": "Simulator",
16 | "description": "Navbar item with label Simulator"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current.json:
--------------------------------------------------------------------------------
1 | {
2 | "version.label": {
3 | "message": "Próximo",
4 | "description": "O rótulo para a versão atual"
5 | },
6 | "sidebar.main.category.Getting Started": {
7 | "message": "Começando",
8 | "description": "O rótulo da categoria Introdução na barra lateral principal"
9 | },
10 | "sidebar.main.category.Guides": {
11 | "message": "Guias",
12 | "description": "O rótulo para a categoria Guias na barra lateral principal"
13 | },
14 | "sidebar.main.category.Diagram Reference": {
15 | "message": "Referência do Diagrama",
16 | "description": "O rótulo para a categoria Referência de Diagrama na barra lateral principal"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/chips-api/analog.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: API Analógica
3 | sidebar_label: API Analógica
4 | ---
5 |
6 | # API Analógica
7 |
8 | ### float pin_adc_read(pin_t pin)
9 |
10 | Mede a tensão atual no pino fornecido e a retorna. O pino deve ser definido para o modo `ANALOG`, caso contrário, o valor de retorno desta função é indefinido. Observe que o Wokwi é um simulador digital com suporte analógico básico, portanto, atualmente, a simulação analógica é muito limitada. Algumas peças que suportam saída analógica incluem o [potenciômetro](../parts/wokwi-slide-potentiometer), [sensor de temperatura NTC](../parts/wokwi-ntc-temperature-sensor), [fotoresistor](../parts/wokwi-photoresistor-sensor) e [joystick analógico](../parts/wokwi-analog-joystick).
11 |
12 | ### void pin_dac_write(pin_t pin, float voltage)
13 |
14 | Define a tensão analógica no pino fornecido. Atualmente, a tensão de referência para todos os ADCs virtuais é de 5 volts (independentemente do MCU), portanto, definir a tensão como 0 retornará o valor mínimo e definir a tensão como 5 retornará o valor máximo (que é 1023 no Arduino). Isso pode mudar no futuro.
15 |
16 | Este método pode ser chamado antes de definir o pino para o modo `ANALOG`, mas a tensão só será atualizada quando o modo do pino for definido para `ANALOG`.
17 |
18 | ## Exemplos no simulator
19 |
20 | - [Exemplo da API Analógica](https://wokwi.com/projects/330112801381024338)
21 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/chips-api/attributes.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Atributos
3 | sidebar_label: Atributos
4 | ---
5 |
6 | # Atributos
7 |
8 | Atributos são parâmetros de entrada que o usuário pode definir em `diagram.json`. Você também pode definir uma seção `controls` no arquivo `.chip.json` para permitir que o usuário edite esses parâmetros interativamente durante a simulação. Isso é particularmente útil para entradas de sensores (por exemplo, temperatura, umidade, etc.).
9 |
10 | ### Nomenclatura
11 |
12 | Ao nomear seus atributos, siga as seguintes convenções:
13 |
14 | - Use `camelCase` para nomes de atributos
15 | - Use a ortografia do Inglês Americano (por exemplo, `color` e não `colour`)
16 |
17 | ### uint32_t attr_init(const char \*name, uint32_t default_value)
18 |
19 | Define um novo atributo inteiro com o nome fornecido. O `default_value` será usado quando o usuário não definir um valor para o atributo em `diagram.json` (na seção `attrs` da `parte` do chip personalizado).
20 |
21 | A função retorna um identificador para o atributo, que pode ser acessado usando `attr_read()`.
22 |
23 | :::warning AVISO
24 |
25 | Nota: `attr_init` só pode ser chamado através de `chip_init()`. Não chame isso mais tarde.
26 |
27 | :::
28 |
29 | ### uint32_t attr_init_float(const char \*name, float default_value)
30 |
31 | Define um novo atributo de ponto flutuante com o nome fornecido. Veja `attr_init()` para mais informações.
32 |
33 | :::warning AVISO
34 |
35 | Nota: `attr_init_float` só pode ser chamado de `chip_init()`. Não chame isso mais tarde.
36 |
37 | :::
38 |
39 | ### uint32_t attr_read(uint32_t attr)
40 |
41 | Retorna o valor atual do atributo. `attr` deve ser um identificador de atributo válido, previamente retornado por `attr_init()`.
42 |
43 | ### float attr_read_float(uint32_t attr)
44 |
45 | Retorna o valor atual do atributo. `attr` deve ser um identificador de atributo válido, previamente retornado por `attr_init_float()`.
46 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/chips-api/chip-debug.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wokwi/wokwi-docs/de857df2b8ecd29420541f37b90a0746e48ff014/i18n/pt-BR/docusaurus-plugin-content-docs/current/chips-api/chip-debug.png
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/chips-api/framebuffer.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: API Framebuffer
3 | sidebar_label: API Framebuffer
4 | ---
5 |
6 | # API Framebuffer
7 |
8 | Use a API Framebuffer para implementar displays (LCD, OLED, e-paper, etc.). O tamanho de exibição é definido no arquivo `.chip.json`. O framebuffer usa 32 bits por pixel. Os pixels são armazenados no formato RGBA. O tamanho total do buffer é `pixel_width * pixel_height * 4` bytes.
9 |
10 | ### buffer_t framebuffer_init(uint32_t *pixel_width, uint32_t *pixel_height)
11 |
12 | Retorna o framebuffer para o chip atual e as dimensões em pixel (largura/altura) do frame buffer.
13 |
14 | :::warning AVISO
15 |
16 | Nota: `framebuffer_init` só pode ser chamado de `chip_init()`. Não chame isso mais tarde.
17 |
18 | :::
19 |
20 | ### void buffer_write(buffer_t buffer, uint32_t offset, void \*data, uint32_t data_len)
21 |
22 | Copia os bytes `data_len` de `data` para o frame buffer, no `offset` fornecido.
23 |
24 | ### void buffer_read(buffer_t buffer, uint32_t offset, void \*data, uint32_t data_len)
25 |
26 | Copia os bytes `data_len` no `offset` fornecido do frame buffer em `data`.
27 |
28 | ## Exemplos no simulator
29 |
30 | - [Exemplo Básico de Chip Framebuffer](https://wokwi.com/projects/330503863007183442)
31 | - [Display LCD colorido IL9163 128x128](https://wokwi.com/projects/333332561949360723)
32 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/diagram-format-connections.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wokwi/wokwi-docs/de857df2b8ecd29420541f37b90a0746e48ff014/i18n/pt-BR/docusaurus-plugin-content-docs/current/diagram-format-connections.gif
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/guides/esp32-wifi-wireshark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wokwi/wokwi-docs/de857df2b8ecd29420541f37b90a0746e48ff014/i18n/pt-BR/docusaurus-plugin-content-docs/current/guides/esp32-wifi-wireshark.png
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/guides/logic-analyzer-i2c-decoder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wokwi/wokwi-docs/de857df2b8ecd29420541f37b90a0746e48ff014/i18n/pt-BR/docusaurus-plugin-content-docs/current/guides/logic-analyzer-i2c-decoder.png
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/guides/logic-analyzer-pulseview-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wokwi/wokwi-docs/de857df2b8ecd29420541f37b90a0746e48ff014/i18n/pt-BR/docusaurus-plugin-content-docs/current/guides/logic-analyzer-pulseview-1.png
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/guides/logic-analyzer-pulseview-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wokwi/wokwi-docs/de857df2b8ecd29420541f37b90a0746e48ff014/i18n/pt-BR/docusaurus-plugin-content-docs/current/guides/logic-analyzer-pulseview-2.png
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/guides/micropython.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: MicroPython no Wokwi
3 | sidebar_label: MicroPython
4 | ---
5 |
6 | Você pode criar e executar projetos MicroPython no Wokwi. Comece com o [modelo de projeto Raspberry Pi Pico MicroPython](https://wokwi.com/projects/new/micropython-pi-pico).
7 |
8 | ## Estrutura do projeto
9 |
10 | Todos os projetos MicroPython devem incluir um arquivo `main.py`. MicroPython irá carregar e executar automaticamente o código de `main.py` quando você iniciar a simulação.
11 |
12 | Wokwi copia todos os arquivos do projeto para o sistema de arquivos flash do Pico. Isso significa que seu projeto
13 | pode incluir módulos Python adicionais e você pode importá-los no `main.py` ou do modo interativo
14 | REPL. Seu projeto também pode incluir dados personalizados dentro de arquivos de texto.
15 |
16 | Você pode obter uma lista de todos os arquivos no sistema de arquivos flash executando:
17 |
18 | ```python
19 | import os
20 | print(os.listdir('/'))
21 | ```
22 |
23 | # MicroPython REPL
24 |
25 | Quando o código em `main.py` termina (ou você o interrompe com Ctrl+C), você entrará no REPL do MicroPython. O REPL é um prompt interativo onde você pode digitar comandos python e ver os resultados imediatamente. Digite `help()` para exibir a ajuda da API MicroPython. Para colar o código no REPL, digite Ctrl+E para entrar no modo de colagem.
26 |
27 | ## Exemplos de projetos
28 |
29 | - [Blink com MicroPython](https://wokwi.com/projects/300504213470839309)
30 | - [Display de 7-Segmentos com MicroPython](https://wokwi.com/projects/300210834979684872)
31 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/board-franzininho-wifi.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência da board-franzininiho-wifi
3 | sidebar_label: board-franzininiho-wifi
4 | ---
5 |
6 | Placa de desenvolvimento open source ESP32-S2 criada no Brasil. Consulte o [Guia ESP32](../guides/esp32) para maiores informações.
7 |
8 | 
9 |
10 | ## Hardware da placa
11 |
12 | A placa inclui três LEDs embutidos:
13 |
14 | - LED verde de energia
15 | - LED laranja conectado ao pino 33
16 | - LED azul conectado ao pino 21
17 |
18 | ## Exemplos no simulador
19 |
20 | - [Relógio LCD com cliente (NTP)](https://wokwi.com/projects/323796775459619410)
21 | - [Controle de servo motor](https://wokwi.com/projects/327061759288410708)
22 | - [Misturador de LED RGB (usando 3 potenciômetros)](https://wokwi.com/projects/324682033130373716)
23 | - [Exemplo de Blink com CircuitPython](https://wokwi.com/projects/313606939786347074)
24 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/board-ssd1306.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência do board-ssd1306
3 | sidebar_label: board-ssd1306
4 | ---
5 |
6 | Tela OLED monocromática 128x64 com interface I2C
7 |
8 | 
9 |
10 | ## Nome dos Pinos
11 |
12 | | Nome | Descrição | Pino Arduino Uno |
13 | | ---- | --------------------- | ---------------- |
14 | | GND | Terra | GND |
15 | | VCC | Tensão de alimentação | 5V |
16 | | SCL | Sinal de clock I2C | A5 |
17 | | SDA | Sinal de dados I2C | A4 |
18 |
19 | O endereço I2C padrão do módulo SSD1306 é 0x3c (60).
20 |
21 | ## Atributos
22 |
23 | | Nome | Descrição | Valor padrão |
24 | | ---------- | -------------------- | ------------ |
25 | | i2cAddress | Endereço I2C da tela | "0x3c" |
26 |
27 | ## Usando no Arduino
28 |
29 | Você pode escolher entre várias bibliotecas SSD1306 do Arduino:
30 |
31 | - [Adafruit SSD1306](https://wokwi.com/projects/344892392214626898)
32 | - [ssd1306](https://wokwi.com/projects/344894074741850707)
33 | - [lcdgfx](https://github.com/lexus2k/lcdgfx)
34 | - [U8glib](https://github.com/olikraus/u8glib)
35 | - [U8g2](https://github.com/olikraus/u8g2) (também U8x8)
36 | - [SSD1306Ascii](https://github.com/greiman/SSD1306Ascii)
37 | - [Tiny4kOLED](https://www.arduino.cc/reference/en/libraries/tiny4koled/) - para usuários ATtiny85
38 |
39 | Todas as bibliotecas acima estão disponíveis no Wokwi.
40 |
41 | ## Exemplos no simulador
42 |
43 | - [Jogo da Cobrinha no SSD1306](https://wokwi.com/projects/296135008348799496) (usando Adafruit SSD1306)
44 | - [ATtiny85 Digital Temperatura + Umidade no SSD1306](https://wokwi.com/projects/292900020514980360)
45 | - [Barra de progresso com U8glib](https://wokwi.com/projects/300867986768527882)
46 | - [Fontes SSD1306Ascii](https://wokwi.com/projects/291197274604700168)
47 | - [Adafruit SSD1306 Showcase](https://wokwi.com/projects/344892392214626898)
48 | - [U8g2 Menu](https://wokwi.com/projects/291572875238834696)
49 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-74hc165.svg:
--------------------------------------------------------------------------------
1 |
17 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-74hc595.svg:
--------------------------------------------------------------------------------
1 |
17 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-7segment-diagram.svg:
--------------------------------------------------------------------------------
1 |
17 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-7segment-digits.svg:
--------------------------------------------------------------------------------
1 |
14 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-a4988.svg:
--------------------------------------------------------------------------------
1 |
33 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-arduino-nano.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência do wokwi-arduino-nano
3 | sidebar_label: wokwi-arduino-nano
4 | ---
5 |
6 | O Arduino Nano é muito semelhante ao [Arduino Uno](wokwi-arduino-uno), mas em um formato menor. Ele carrega o mesmo chip ATmega328p, que possui 32K bytes de memória de programa Flash, 2k bytes de SRAM e 1K bytes de EEPROM.
7 |
8 |
9 |
10 | Para obter mais informações, consulte a [referência wokwi-arduino-uno](wokwi-arduino-uno).
11 |
12 | ## Diferenças do Arduino Uno
13 |
14 | O Arduino Nano inclui dois pinos analógicos extras: A6 e A7. Esses pinos só podem ser usados para entrada analógica. Eles não podem ser usados como pinos GPIO digitais.
15 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-attiny85.svg:
--------------------------------------------------------------------------------
1 |
20 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-buzzer.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência do wokwi-buzzer
3 | sidebar_label: wokwi-buzzer
4 | ---
5 |
6 | Um buzzer piezoelétrico
7 |
8 |
9 |
10 | ## Nome dos Pinos
11 |
12 | | Nome | Descrição |
13 | | ---- | ------------------------ |
14 | | 1 | Pino negativo (preto) |
15 | | 2 | Pino positivo (vermelho) |
16 |
17 | ## Atributos
18 |
19 | | Nome | Descrição | Valor padrão |
20 | | ------ | -------------------------------------------------- | ------------- |
21 | | mode | Modo de operação do buzzer: "smooth" ou "accurate" | "smooth" |
22 | | volume | Volume (intensidade) do som, entre "0.01" e "1.0" | "1.0" |
23 |
24 | ### Modos de operação
25 |
26 | O buzzer pode operar em dois modos: "smooth" (o padrão) e "accurate".
27 |
28 | "smooth" soa melhor e é adequado para tons simples de frequência única. Use-o
29 | ao tocar uma melodia ou tons com a função `tone()` do Arduino. Sons polifônicos complexos
30 | podem não tocar corretamente (ou nem tocar) no modo "smooth" (suave).
31 |
32 | Uso o modo "accurate" quando você precisar tocar sons complexos. Vai tocar com precisão
33 | o som que você alimenta. No entanto, ele adicionará ruídos de clique audíveis ao seu som. Esses ruídos
34 | são devido a flutuações na velocidade da simulação - nem sempre é capaz de fornecer o
35 | buffer de som em tempo real.
36 |
37 | ## Arduino exemplo
38 |
39 | Conecte o pino 1 da campainha ao pino GND do Arduino e o pino 2 da campainha ao pino 8 do Arduino. Em seguida, use a função `tone()` para reproduzir um som:
40 |
41 | ```cpp
42 | tone(8, 262, 250); // Toca um tom de 262Hz por 0,250 segundos
43 | ```
44 |
45 | ## Exemplos no simulador
46 |
47 | - [Jogo Simon](https://wokwi.com/projects/344891334169985618) - Um jogo de memória com 4 botões de pressão
48 | - [Piano diatônico](https://wokwi.com/projects/291958456169005577) - Um piano de 8 notas, use as teclas 1 a 8 para pressionar os botões e tocar as notas.
49 | - [Despertador](https://wokwi.com/projects/297787059514376717) - Use a campainha para tocar o som do alarme
50 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-dht22.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência do wokwi-dht22
3 | sidebar_label: wokwi-dht22
4 | ---
5 |
6 | Sensor digital de umidade e temperatura.
7 |
8 |
9 |
10 | ## Nome dos Pinos
11 |
12 | | Nome | Descrição |
13 | | ---- | ------------------------------------- |
14 | | VCC | Tensão positiva |
15 | | SDA | Pino digital de dados (entrada/saída) |
16 | | NC | Não conectado |
17 | | GND | Terra |
18 |
19 | ## Atributos
20 |
21 | | Nome | Descrição | Valor padrão |
22 | | ----------- | ----------------------------------------------- | ------------- |
23 | | temperature | Valor da temperatura inicial (celsius) | "24" |
24 | | humidity | Valor de umidade relativa inicial (porcentagem) | "40" |
25 |
26 | ## Controlando a temperatura
27 |
28 | Você pode alterar os valores de temperatura e umidade durante a execução da simulação.
29 | Clique no sensor DHT22 e uma pequena janela pop-up será aberta.
30 | Use os controles deslizantes de temperatura e umidade para alterar os valores.
31 | Clique em "Ocultar" para fechar a janela pop-up.
32 |
33 | :::warning::ATENÇÃO
34 | Se você estiver tentando ler este sensor do ESP32, use a biblioteca "DHT sensor library for ESPx". Outras bibliotecas DHT22 podem não funcionar de forma confiável no ESP32. Você pode usar este [projeto de exemplo](https://wokwi.com/projects/322410731508073042) como ponto de partida.
35 | :::
36 |
37 | ## Exemplos no simulador
38 |
39 | - [Teste DHTlib DHT22](https://wokwi.com/projects/344892337559700051)
40 | - [Exemplos de código da biblioteca DHT](https://wokwi.com/projects/344892587898831442)
41 | - [DHT22 no ESP32](https://wokwi.com/projects/322410731508073042)
42 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-dip-switch-8.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência do wokwi-dip-switch-8
3 | sidebar_label: wokwi-dip-switch-8
4 | ---
5 |
6 | Conjunto de 8 interruptores elétricos em um único encapsulamento
7 |
8 |
9 |
10 | ## Nome dos Pinos
11 |
12 | | Nome | Descrição |
13 | | ---- | --------------------------------- |
14 | | 1a | Primeiro contato do interruptor 1 |
15 | | 1b | Segundo contato do interruptor 1 |
16 | | 2a | Primeiro contato do interruptor 2 |
17 | | 2b | Segundo contato do interruptor 2 |
18 | | … | … |
19 | | 8a | Primeiro contato do interruptor 8 |
20 | | 8b | Segundo contato do interruptor 8 |
21 |
22 | ## Operação do teclado
23 |
24 | Você pode usar o teclado para alternar os interruptores enquanto a simulação está em execução. Clique no interruptor DIP para selecioná-lo e, em seguida, alterne os interruptores pressionando as teclas "1" a "8".
25 |
26 | Usuários do Firefox: se os atalhos do teclado não funcionarem para você, certifique-se de que a configuração "Pesquisar texto ao começar a digitar" esteja desativada.
27 |
28 | ## Exemplos no simulador
29 |
30 | - [Exemplo do interruptor DIP + barra de LED](https://wokwi.com/projects/314167394611233344)
31 | - [Exemplo do registrador PIND do Arduino](https://wokwi.com/projects/314168546236039745)
32 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-ds1307.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência do wokwi-ds1307
3 | sidebar_label: wokwi-ds1307
4 | ---
5 |
6 | Módulo RTC (Real Time Clock) com interface I2C e 56 bytes de NV SRAM.
7 |
8 |
9 |
10 | ## Nome dos Pinos
11 |
12 | | Nome | Descrição |
13 | | ---- | ---------------------------------------------------- |
14 | | GND | Terra |
15 | | 5V | Tensão positiva (5V) |
16 | | SDA | Linha de dados I2C |
17 | | SCL | Linha de clock I2C |
18 | | SQW | Saída de onda quadrada. Não disponível na simulação. |
19 |
20 | O endereço I2C do DS1307 é 0x68.
21 |
22 | ## Comportamento da Simulação
23 |
24 | O simulador do DS1307 é inicializado automaticamente com a hora atual do sistema ao iniciar a simulação. Após isso
25 | continua contando o tempo.
26 |
27 | O código em execução na simulação pode atualizar a data/hora do DS1307 e o DS1307 manterá o controle
28 | do tempo da atualização.
29 |
30 | ## Exemplos no simulador
31 |
32 | - [Lendo data/hora usando RTClib](https://wokwi.com/projects/305979285237137984)
33 | - [Despertador](https://wokwi.com/projects/297787059514376717)
34 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-ir-receiver.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência do wokwi-ir-receiver
3 | sidebar_label: wokwi-ir-receiver
4 | ---
5 |
6 | Receptor infravermelho 38KHz
7 |
8 |
9 |
10 | ## Nome dos Pinos
11 |
12 | | Nome | Descrição |
13 | | ---- | ---------------- |
14 | | GND | Terra |
15 | | VCC | Tensão positiva |
16 | | DAT | Saída digital |
17 |
18 | ## Usando o receptor
19 |
20 | O receptor pode ser usado de duas maneiras:
21 |
22 | 1. Use o [Controle Remoto IR](wokwi-ir-remote) para enviar comandos infravermelhos.
23 | 2. Clique no receptor (enquanto a simulação está em execução) para enviar arbitrariamente [sinais IR codificados por NEC](https://exploreembedded.com/wiki/NEC_IR_Remote_Control_Interface_with_8051#NEC_Protocol). A interface do usuário permite especificar o endereço e os campos de comando na mensagem NEC.
24 |
25 | Para ler os comandos no seu código Arduino, você pode usar a biblioteca [IRRemote](https://github.com/Arduino-IRremote/Arduino-IRremote) ou [IRMP](https://github.com/ukw100/IRMP).
26 |
27 | ## Exemplos no simulador
28 |
29 | - [IRRemote + Display LCD](https://wokwi.com/projects/298934082074575369)
30 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-ks2e-m-dc5.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência do Relé ks2e-m-dc5
3 | sidebar_label: wokwi-ks2e-m-dc5
4 | ---
5 |
6 | Relé de duas chaves de duas posições (DPDT)
7 |
8 |
9 |
10 | ## Nome dos Pinos
11 |
12 | | Nome | Descrição |
13 | | ----- | --------------------------------------------------------------------- |
14 | | COIL1 | Primeiro terminal da bobina |
15 | | COIL2 | Segundo terminal da bobina |
16 | | P1 | Primeiro pólo |
17 | | NC1 | Normalmente fechado - conectado a P1 quando a bobina não é alimentada |
18 | | NO1 | Normalmente aberto - conectado a P1 quando alimentado pela bobina |
19 | | P2 | Segundo pólo |
20 | | NC2 | Normalmente fechado - conectado a P2 quando a bobina não é alimentada |
21 | | NO2 | Normalmente aberto - conectado a P2 quando alimentado por bobina |
22 |
23 | ## Operação
24 |
25 | O relé é um interruptor eletrônico com dois estados: bobina sem alimentação e bobina com alimentação. Por padrão, a bobina não é alimentada. Você pode alimentar a bobina aplicando tensão entre os pinos COIL1 e COIL2.
26 |
27 | Quando a bobina está desenergizada, P1 é conectado a NC1 e P2 é conectado a NC2 (NC significa normalmente fechado/conectado).
28 |
29 | Quando a bobina é alimentada, P1 é conectado a NO1 e P2 é conectado a NO2 (NO significa normalmente aberto/desconectado).
30 |
31 | O diagrama a seguir resume os estados do relé:
32 |
33 | 
34 |
35 | ## Exemplos no simulador
36 |
37 | - [Um Relé controlando dois LEDs](https://wokwi.com/projects/322846360729551444)
38 | - [Flip-flop com Relé](https://wokwi.com/projects/322802227591774802) - Elemento de memória de bit único usando três relés
39 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-ky-040-timing.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wokwi/wokwi-docs/de857df2b8ecd29420541f37b90a0746e48ff014/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-ky-040-timing.png
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-lcd2004.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência do wokwi-lcd2004
3 | sidebar_label: wokwi-lcd2004
4 | ---
5 |
6 | Um display LCD com 4 linhas, 20 caracteres por linha.
7 |
8 |
9 |
10 | Este componente tem os mesmos pinos e atributos do wokwi-lcd1602.
11 |
12 | Para **informações completas e exemplos de código**, consulte a [Referência do wokwi-lcd1602](wokwi-lcd1602).
13 |
14 | ### Exemplos
15 |
16 | | Resultado | Attrs |
17 | | ------------------------------------------------------------------- | -------------------------------------------- |
18 | | | `{ }` |
19 | | | `{ "pins": "i2c" }` |
20 | | | `{ "background": "blue", "color": "white" }` |
21 |
22 | ## Exemplos no simulador
23 |
24 | - [LCD2004 Tiny Pacman on Wokwi](https://wokwi.com/projects/294590769009787402)
25 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-led-bar-graph.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência do wokwi-led-bar-graph
3 | sidebar_label: wokwi-led-bar-graph
4 | ---
5 |
6 | Barra Gráfica de LEDs de 10 segmentos.
7 |
8 |
9 |
10 | ## Nome dos Pinos
11 |
12 | | Nome | Descrição |
13 | | ------ | ---------------------------------------------- |
14 | | A**n** | Ânodo (pino positivo) do LED **n** (n = 1…10) |
15 | | C**n** | Cátodo (pino negativo) do LED **n** (n = 1…10) |
16 |
17 | ex. A1 é o ânodo do LED superior e C1 é o cátodo do LED superior.
18 |
19 | ## Atributos
20 |
21 | | Nome | Descrição | Valor padrão |
22 | | ----- | ------------------------------------------------------------------------ | ------------- |
23 | | color | A cor do corpo do LED ou um dos valores especiais "GYR" / "BCYR"\* | "red" |
24 |
25 | \* GYR significa Verde-Amarelo-Vermelho. BCYR significa Azul-Ciano-Amarelo-Vermelho
26 |
27 | ### Exemplos
28 |
29 | | Resultado | Attrs |
30 | | ----------------------------------------------------------------------- | ------------------------ |
31 | | | `{ "color": "yellow" }` |
32 | | | `{ "color": "#9EFF3C" }` |
33 | | | `{ "color": "GYR"}` |
34 | | | `{ "color": "BCYR"}` |
35 |
36 | ## Exemplos no simulador
37 |
38 | - [Arduino LED Graph Bar](https://wokwi.com/projects/309829489359061570) - Mova o botão do potenciômetro para controlar os LEDs
39 | - [Contador Binário com Raspberry Pi Pico](https://wokwi.com/projects/309828467927548481)
40 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-max7219-matrix-chain-4.svg:
--------------------------------------------------------------------------------
1 |
34 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-max7219-matrix.svg:
--------------------------------------------------------------------------------
1 |
48 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-microsd-card-upload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wokwi/wokwi-docs/de857df2b8ecd29420541f37b90a0746e48ff014/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-microsd-card-upload.png
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-nlsf595.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência do wokwi-nlsf595
3 | sidebar_label: wokwi-nlsf595
4 | ---
5 |
6 | Driver de LED tricolor serial (SPI)
7 |
8 | 
9 |
10 | Use o registrador de deslocamento NLSF595 para conectar LEDs RGB que consomem muita energia ao seu microcontrolador. Uma única unidade pode controlar dois LEDs RGB e uma cadeia de duas unidades pode controlar até cinco LEDs RGB.
11 |
12 | ## Nome dos Pinos
13 |
14 | | Pino | Descrição |
15 | | ----- | ------------------------------------------------------------------ |
16 | | SI | Entrada serial |
17 | | SCK | Clock serial |
18 | | RCK | Pino de armazenamento (latch) |
19 | | OE | Saída habilitada, ativo em baixo. Conecte ao GND se não for usado. |
20 | | QA…QH | Saída paralela |
21 | | SQH | Saída serial\* |
22 | | SCLR | Reset (limpa), ativo em baixo. Conecte ao VCC se não for usado |
23 | | GND | Terra |
24 | | VCC | Tensão de alimentação |
25 |
26 | \* Use o Q7S para encadear várias unidades NLSF595 juntas. Conecte o SQH ao pino SI do próximo chip NLSF595 na cadeia.
27 |
28 | ## Usando o NLSF595
29 |
30 | Você precisará conectar pelo menos 3 pinos ao seu microcontrolador: SI, SCK e RCK.
31 |
32 | O pino OE pode ser usado para desabilitar a saída do registrador de deslocamento. Se você precisar dessa funcionalidade,
33 | conecte-o ao seu microcontrolador. Caso contrário, conecte-o ao terra para habilitar permanentemente a saída.
34 |
35 | Os pinos de saída do registrador de deslocamento, QA a QH, são conectados geralmente aos pinos de entrada do ânodo comum dos [LEDs RGB](wokwi-rgb-led).
36 |
37 | ## Exemplos no simulador
38 |
39 | - [Driver NLSF595 com 2 LEDs RGB](https://wokwi.com/projects/315085666329297472)
40 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-nlsf595.svg:
--------------------------------------------------------------------------------
1 |
17 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-ntc-temperature-sensor.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência do wokwi-ntc-temperature-sensor
3 | sidebar_label: wokwi-ntc-temperature-sensor
4 | ---
5 |
6 | Sensor analógico de temperatura: termistor NTC (coeficiente de temperatura negativo).
7 |
8 |
9 |
10 | ## Nome dos Pinos
11 |
12 | | Nome | Descrição |
13 | | ---- | ----------------------------- |
14 | | VCC | Fonte de alimentação positiva |
15 | | OUT | Sinal de saída (analógico) |
16 | | GND | Terra |
17 |
18 | ## Atributos
19 |
20 | | Nome | Descrição | Valor padrão |
21 | | ----------- | -------------------------------------- | ------------- |
22 | | temperature | Valor da temperatura inicial (celsius) | "24" |
23 | | beta | O coeficiente beta do termistor | "3950" |
24 |
25 | ## Lendo a temperatura
26 |
27 | O módulo do sensor de temperatura inclui um termistor NTC de 10K em série com um resistor de 10K.
28 |
29 | Esta configuração produz uma voltagem que depende da temperatura. Você pode ler esta tensão através
30 | da conexão do pino OUT do termistor a um pino de entrada analógica e, em seguida, usar a
31 | função `analogRead()`.
32 |
33 | Use o seguinte código para converter o valor de retorno da função `analogRead()` em um valor de temperatura (em celsius):
34 |
35 | ```cpp
36 | const float BETA = 3950; // Deve corresponder ao coeficiente beta do termistor
37 | int analogValue = analogRead(A0);
38 | float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
39 | ```
40 |
41 | ## Exemplos no simulador
42 |
43 | - [Exemplo básico do termistor NTC](https://wokwi.com/projects/299330254810382858)
44 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-relay-module.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência do wokwi-relay-module
3 | sidebar_label: wokwi-relay-module
4 | ---
5 |
6 | Interruptor eletromecânico
7 |
8 | 
9 |
10 | ## Nome dos Pinos
11 |
12 | | Nome | Descrição |
13 | | ---- | ---------------------------------------------------- |
14 | | VCC | Tensão de alimentação |
15 | | GND | Terra |
16 | | IN | Sinal de controle (por exemplo, do microcontrolador) |
17 | | NC | Normalmente fechado |
18 | | COM | Pino comum |
19 | | NO | Normalmente aberto |
20 |
21 | ## Operação
22 |
23 | O relé é um interruptor eletrônico.
24 |
25 | Quando o pino `IN` está baixo / desconectado, `COM` é conectado a `NC` (NC significa normalmente fechado).
26 |
27 | Quando o pino `IN` é alto, `COM` é conectado a `NO` (NO significa normalmente aberto).
28 |
29 | ## Exemplos no simulador
30 |
31 | - [Um módulo de relé controlando dois LEDs](https://wokwi.com/projects/347308007359513172)
32 |
33 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-resistor.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência do wokwi-resistor
3 | sidebar_label: wokwi-resistor
4 | ---
5 |
6 | Um resistor.
7 |
8 |
9 |
10 | :::warning ALERTA
11 | Wokwi tem apenas uma simulação de circuito analógico muito básica. Você não será capaz de usar resistores junto com
12 | componentes analógicos (por exemplo, potenciômetro ou sensor de temperatura NTC). Você ainda pode usar os resistores como
13 | pull-up/pull-down externos.
14 | :::
15 |
16 | ## Nome dos Pinos
17 |
18 | | Pino | Descrição |
19 | | ---- | ------------- |
20 | | 1 | Primeiro pino |
21 | | 2 | Segundo pino |
22 |
23 | ## Atributos
24 |
25 | | Nome | Descrição | Valor padrão |
26 | | ----- | -------------------- | ------------ |
27 | | value | Resistência, em ohms | "1000" |
28 |
29 | ### Exemplos
30 |
31 | | Resultado | Attrs |
32 | | ----------------------------------- | ------------------------- |
33 | | | `{ "value": "1" }` |
34 | | | `{ "value": "220" }` |
35 | | | `{ "value": "10000000" }` |
36 |
37 | Confira a [demonstração do resistor por Koepel](https://wokwi.com/projects/300936732038136328) para mais exemplos.
38 |
39 | ## Exemplos no simulador
40 |
41 | - [Resistor externo pull-down](https://wokwi.com/projects/302214836102627848) - Como usar um resistor como pull-down para um botão
42 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-rgb-led.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência do wokwi-rgb-led
3 | sidebar_label: wokwi-rgb-led
4 | ---
5 |
6 | LED 5mm vermelho, verde e azul (RGB).
7 |
8 |
9 |
10 | ## Nome dos Pinos
11 |
12 | | Nome | Descrição |
13 | | ---- | ------------ |
14 | | R | LED vermelho |
15 | | G | LED verde |
16 | | B | LED azul |
17 | | COM | Pino comum\* |
18 |
19 | \* Por padrão, o pino comum é o ânodo (positivo). Você pode alterá-lo definindo o atributo "common" para "cathode" (negativo).
20 |
21 | ## Atributos
22 |
23 | | Nome | Descrição | Valor padrão |
24 | | ------ | ------------------------------------------ | ------------ |
25 | | common | O tipo do pino comum: "cathode" ou "anode" | "anode" |
26 |
27 | ## Exemplos no simulador
28 |
29 | - [LED RGB com 3 controles deslizantes lineares](https://wokwi.com/projects/306455554559050306)
30 | - [LED RGB pulsante suave](https://wokwi.com/projects/306461175146611264)
31 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-servo.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência do wokwi-servo
3 | sidebar_label: wokwi-servo
4 | ---
5 |
6 | Um Motor Micro Servo padrão
7 |
8 |
9 |
10 | ## Nome dos Pinos
11 |
12 | | Nome | Descrição |
13 | | ---- | -------------------------- |
14 | | PWM | Sinal de controle do Servo |
15 | | V+ | Tensão positiva (5V) |
16 | | GND | Terra |
17 |
18 | ## Atributos
19 |
20 | | Nome | Descrição | Valor padrão |
21 | | --------- | --------------------------------------------- | ------------- |
22 | | horn | Tipo de hélice: "single", "double" ou "cross" | "single" |
23 | | hornColor | A cor da hélice do servo | "#ccc" |
24 |
25 | ### Exemplos
26 |
27 | | Resultado | Atributos (attrs) |
28 | | -------------------------------- | ---------------------------- |
29 | | | `{ "horn": "single" }` |
30 | | | `{ "hornColor": "#000088" }` |
31 | | | `{ "horn": "double" }` |
32 | | | `{ "horn": "cross" }` |
33 |
34 | ## Exemplos no simulador
35 |
36 | - [Sweep](https://wokwi.com/projects/344891730528567891)
37 | - [ESP32 Servo Sweep](https://wokwi.com/projects/323706614646309460)
38 | - [Knob](https://wokwi.com/projects/344892191015961170)
39 | - [Controlando 1 servo com dois botões no Arduino Nano](https://wokwi.com/projects/328312829780165204)
40 | - [Controlando 5 servos com Arduino Uno](https://wokwi.com/projects/305087394119418434)
41 | - [Animando 32 servos com Arduino Mega](https://wokwi.com/projects/305336312628511297)
42 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-slide-potentiometer.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência do wokwi-slide-potentiometer
3 | sidebar_label: wokwi-slide-potentiometer
4 | ---
5 |
6 | Resistência variável deslizante (potenciômetro linear)
7 |
8 |
9 |
10 | A funcionalidade e pinagem do potenciômetro deslizante são as mesmas do potenciômetro linear. Confira a [documentação do potenciômetro wokwi](wokwi-potentiometer) para maiores informações.
11 |
12 | ## Atributos
13 |
14 | | Nome | Descrição | Valor padrão |
15 | | ------------ | ------------------------------------------------------------------------------------------------------------------------------------ | ------------ |
16 | | value | Valor inicial do potenciômetro, entre 0 e 1023 | "0" |
17 | | travelLength | Comprimento do percurso da ponta (mm). Controla a largura do potenciômetro.
Valores comuns: "15", "20", "30", "45", "60", "100" | "30" |
18 |
19 | ### Exemplos
20 |
21 | | Resultado | Attrs |
22 | | ------------------------------------------------ | --------------------------- |
23 | | | `{ "travelLength": "15" }` |
24 | | | `{ "travelLength": "60" }` |
25 | | | `{ "travelLength": "100" }` |
26 |
27 | ## Exemplos no simulador
28 |
29 | - [Potenciômetro deslizante + Servo](https://wokwi.com/projects/297604176384360973) - Controle um [servo](wokwi-servo) com um potenciômetro deslizante
30 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-ssd1306.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência do wokwi-ssd1306
3 | sidebar_label: wokwi-ssd1306
4 | ---
5 |
6 | Display OLED monocromático 128x64 com interface I2C
7 |
8 |
9 |
10 | Nota: esta parte foi descontinuada. Em vez disso, use [board-ssd1306](./board-ssd1306).
11 |
12 | ## Nome dos Pinos
13 |
14 | | Nome | Descrição | Pino do Arduino Uno |
15 | | ----------- | ------------------------ | ------------------- |
16 | | DATA | Linha de dados I2C (SDA) | A4 |
17 | | CLK | Linha de clock I2C (SCL) | A5 |
18 | | DC, RST, CS | Não utilizado\* | - |
19 | | 3V3 | Saída regulada de 3,3 V | - |
20 | | GND | Terra | GND |
21 | | VIN | Tensão de alimentação | 5V |
22 |
23 | \* DC, RST e CS são para o modo SPI. A simulação do SSD1306 suporta apenas o modo I2C, portanto, esses pinos não são funcionais.
24 |
25 | O endereço I2C padrão do módulo SSD1306 é 0x3c (60).
26 |
27 | ## Atributos
28 |
29 | | Nome | Descrição | Valor padrão |
30 | | ---------- | ----------------------- | ------------ |
31 | | i2cAddress | Endereço I2C do display | "0x3c" |
32 |
33 | ## Exemplos no simulador
34 |
35 | Veja [board-ssd1306](board-ssd1306#simulator-examples).
36 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/parts/wokwi-tm1637-7segment.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Referência do wokwi-tm1637-7segment
3 | sidebar_label: wokwi-tm1637-7segment
4 | ---
5 |
6 | Módulo display de LED sete segmentos com interface TM1637 de 4 fios
7 |
8 | 
9 |
10 | ## Nome dos Pinos
11 |
12 | | Nome | Descrição |
13 | | ---- | --------------------- |
14 | | CLK | Entrada de clock |
15 | | DIO | Entrada de dados \* |
16 | | VCC | Tensão de alimentação |
17 | | GND | Terra |
18 |
19 | \* O pino DIO também é usado para reconhecer os dados recebidos do microcontrolador, colocando-o em nível lógico baixo para um ciclo de clock específico.
20 |
21 | ## Atributos
22 |
23 | | Nome | Descrição | Valor padrão |
24 | | ----- | -------------------------- | ------------ |
25 | | color | A cor dos LEDs do segmento | "red" |
26 |
27 | ## Usando o display de 7 segmentos
28 |
29 | Esta variante do display de sete segmentos usa o chip TM1637. Você só precisará de 2 pinos do microcontrolador para se comunicar com ele.
30 |
31 | O protocolo de comunicação TM1637 não é padrão. Assemelha-se ao protocolo I2C, mas é mais simples e incompatível com o I2C. Felizmente, você pode usar uma biblioteca e não se preocupar com a implementação do protocolo. Aqui estão algumas bibliotecas TM1637 que você pode usar no Arduino: [RT1637_RT](https://github.com/RobTillaart/TM1637_RT), Módulo Display 4 Digitos Grove.
32 |
33 | ## Exemplos no simulador
34 |
35 | - [Contador com TM1637](https://wokwi.com/projects/339227323398095442)
36 | - [Três displays TM1637](https://wokwi.com/projects/356661328560439297)
37 | - [Termômetro com TM1637 (MicroPython no Pi Pico)](https://wokwi.com/projects/339373435833549395)
38 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-plugin-content-docs/current/vscode/debugging.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Depurando seu código
3 | sidebar_label: Depurando
4 | ---
5 |
6 | Você pode depurar seu código enquanto ele está sendo executado na simulação usando o depurador VS Code. Para configurar o depurador, siga estas etapas:
7 |
8 | ## Configure o Wokwi
9 |
10 | Adicione a seguinte linha à seção `[wokwi]` de seu arquivo de configuração `wokwi.toml`:
11 |
12 | ```toml
13 | gdbServerPort=3333
14 | ```
15 |
16 | ## Configure o VS Code
17 |
18 | Crie um arquivo de configuração de inicialização para o VS Code em `.vscode/launch.json`. Aqui está um modelo que você pode usar:
19 |
20 | ```json
21 | {
22 | "version": "0.2.0",
23 | "configurations": [
24 | {
25 | "name": "Wokwi GDB",
26 | "type": "cppdbg",
27 | "request": "launch",
28 | "program": "${workspaceFolder}/build/your-firmware.elf",
29 | "cwd": "${workspaceFolder}",
30 | "MIMode": "gdb",
31 | "miDebuggerPath": "/usr/local/bin/xtensa-esp32-elf-gdb",
32 | "miDebuggerServerAddress": "localhost:3333"
33 | }
34 | ]
35 | }
36 | ```
37 |
38 | Substitua o caminho `program` pelo caminho para o arquivo ELF do seu firmware e o `miDebuggerPath` pelo caminho para um executável GDB que suporte a arquitetura do seu projeto (por exemplo, para projetos AVR, use `avr-gdb`).
39 |
40 | ## Inicie o depurador
41 |
42 | Inicie o simulador Wokwi pressionando **F1** e selecionando a opção "**Wokwi: Start Simulator and Wait for Debugger**". O simulador será carregado, mas o programa ficará em pausa, aguardando a conexão do depurador. Em seguida, pressione **F5** para iniciar o depurador.
43 |
44 | :::warning Aviso
45 | Você precisa iniciar o Wokwi antes de iniciar o depurador. Se você iniciar o depurador primeiro, ele não conseguirá se conectar ao simulador.
46 | :::
47 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-theme-classic/footer.json:
--------------------------------------------------------------------------------
1 | {
2 | "link.title.Docs": {
3 | "message": "Docs",
4 | "description": "O título da coluna de links de rodapé com título=Docs no rodapé"
5 | },
6 | "link.title.Community": {
7 | "message": "Comunidade",
8 | "description": "O título da coluna de links de rodapé com título=Comunidade no rodapé"
9 | },
10 | "link.title.More": {
11 | "message": "Mais",
12 | "description": "O título da coluna de links de rodapé com título=Mais no rodapé"
13 | },
14 | "link.item.label.Welcome": {
15 | "message": "Bem-vindo",
16 | "description": "O rótulo do link do rodapé com rótulo=Bem-vindo com link para /"
17 | },
18 | "link.item.label.diagram.json": {
19 | "message": "diagram.json",
20 | "description": "O rótulo do link do rodapé com rótulo=diagram.json com link para /diagram-format"
21 | },
22 | "link.item.label.Discord": {
23 | "message": "Discord",
24 | "description": "O rótulo do link do rodapé com rótulo=Discord com link para https://wokwi.com/discord"
25 | },
26 | "link.item.label.Twitter": {
27 | "message": "Twitter",
28 | "description": "O rótulo do link do rodapé com rótulo=Twitter com link para https://twitter.com/WokwiMakes"
29 | },
30 | "link.item.label.Blog": {
31 | "message": "Blog",
32 | "description": "O rótulo do link do rodapé com rótulo=Blog com link para https://blog.wokwi.com"
33 | },
34 | "link.item.label.GitHub": {
35 | "message": "GitHub",
36 | "description": "O rótulo do link do rodapé com rótulo=GitHub com link para https://github.com/wokwi/wokwi-docs"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/i18n/pt-BR/docusaurus-theme-classic/navbar.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": {
3 | "message": "Wokwi",
4 | "description": "O título na barra de navegação"
5 | },
6 | "item.label.Docs": {
7 | "message": "Docs",
8 | "description": "Item da barra de navegação com rótulo Documentos"
9 | },
10 | "item.label.Blog": {
11 | "message": "Blog",
12 | "description": "Item da barra de navegação com rótulo Blog"
13 | },
14 | "item.label.Simulator": {
15 | "message": "Simulador",
16 | "description": "Item da barra de navegação com rótulo Simulador"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current.json:
--------------------------------------------------------------------------------
1 | {
2 | "version.label": {
3 | "message": "下一页",
4 | "description": "The label for version current"
5 | },
6 | "sidebar.main.category.Getting Started": {
7 | "message": "开始",
8 | "description": "The label for category Getting Started in sidebar main"
9 | },
10 | "sidebar.main.category.Guides": {
11 | "message": "指南",
12 | "description": "The label for category Guides in sidebar main"
13 | },
14 | "sidebar.main.category.Diagram Reference": {
15 | "message": "Diagram指南",
16 | "description": "The label for category Diagram Reference in sidebar main"
17 | },
18 | "sidebar.main.category.VS Code Extension": {
19 | "message": "VS Code 扩展",
20 | "description": "The label for category VS Code Extension in sidebar main"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/diagram-format-connections.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wokwi/wokwi-docs/de857df2b8ecd29420541f37b90a0746e48ff014/i18n/zh-CN/docusaurus-plugin-content-docs/current/diagram-format-connections.gif
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/faq.md:
--------------------------------------------------------------------------------
1 | ---
2 | slug: /faq
3 | title: 常见问题
4 | ---
5 |
6 | ## Wokwi是什么意思?
7 |
8 | 在为Wokwi选择名字时,我们正在寻找一个易于发音且还没有任何意义的简短单词。我们想出了一份可能的名字清单,并挑选了我们最喜欢的名字,Wokwi。以下是一些没有被选上的名字:Duvav、Hajuu、Chipine、Zeprr。
9 |
10 | ## 我如何找到之前保存的项目?
11 |
12 | 如果你尚未登录Wokwi,请使用保存项目的同一设备和浏览器,并访问[https://wokwi.com/arduino/projects](https://wokwi.com/arduino/projects)。
13 |
14 | 如果你登录了Wokwi后,并且保存了项目,那么上面的URL将显示你在任何设备/浏览器上保存的所有项目。
15 |
16 | 你还可以通过单击个人资料图片并从菜单中选择“我的项目”来找到到保存的项目。
17 |
18 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/gdb-debugging.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: GDB调试工具
3 | sidebar_label: 调试工具
4 | ---
5 |
6 | GDB是一个强大的代码调试工具,你可以用它来调试wokwi中的代码。
7 |
8 | ## 在Wokwi中运行GDB
9 |
10 | 要启动GDB,在代码编辑器中按F1,在弹出的提示框中输入“GDB”,然后选择**"Start Web GDB Session (debug build)"**
11 |
12 | 这会在浏览器中打开一个新tab启动GDB。如果这是你第一次使用这个功能,大概会花30秒的时间加载。
13 |
14 | ## 调试会话示例
15 |
16 | 当GDB加载完成后,你会看到如下提示:
17 |
18 | ```
19 | 0x00000000 in __vectors ()
20 | (gdb)
21 | ```
22 |
23 | 现在你可以输入GDB指令,例如,如果你想从`setup()`开始一行一行运行你的程序,先输入`tbreak setup`和`c`来启动程序,然后运行直到`setup()`的开始:
24 |
25 | ```
26 | (gdb) tbreak setup
27 | Temporary breakpoint 1 at 0x2ca: file sketch.ino, line 28.
28 | (gdb) c
29 | Continuing.
30 |
31 | Temporary breakpoint 1, setup () at sketch.ino:28
32 | 28 pinMode(LED_BUILTIN, OUTPUT);
33 | (gdb)
34 | ```
35 |
36 | 此时,输入`layout src`显示你程序的源代码,然后输入`next`来执行下一行代码,然后重复输入`next`继续执行后面的每一行。
37 |
38 | `print`命令用来打印变量的值。例如使用`print ledIndex`来打印名为`ledIndex`的值。
39 |
40 | ## 了解更多
41 |
42 | 查看[AVR GDB 手册](https://blog.wokwi.com/gdb-avr-arduino-cheatsheet/),了解更多有用的 GDB 命令。学习所有的 GDB 功能并有效地使用它们需要时间,但即便只使用几个基本命令,它也可以非常强大。
43 |
44 | 如果你想了解我们如何让 GDB 在浏览器中工作,请查看[在浏览器中运行 GDB](https://blog.wokwi.com/running-gdb-in-the-browser/)。这不是使用 GDB 所必须了解的 - 只是让你看一下幕后的疯狂操作。
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/guides/circuitpython.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 在Wokwi使用CircuitPython
3 | sidebar_label: 使用CircuitPython
4 | ---
5 |
6 | 你可以使用[Raspberry Pi Pico board](../parts/wokwi-pi-pico),在Wokwi上进行CircuitPython仿真。要开始新的仿真项目,请打开[Raspberry Pi Pico CircuitPython 项目实例](https://wokwi.com/projects/new/circuitpython-pi-pico)。
7 |
8 | ## 项目的工程结构
9 |
10 | CircuitPython项目必须包含一个`code.py` 文件。此文件中的代码将在你开始仿真时执行。
11 |
12 | Wokwi将所有项目文件复制到Pico的falsh文件系统中。这意味着你的项目可以包含额外的Python模块,你可以从`code.py` 或交互式REPL导入它们。你的项目还可以在文本文件中包含自定义数据。
13 |
14 | 你可以通过运行以下方式获得falsh文件系统中所有文件的列表:
15 |
16 | ```python
17 | import os
18 | print(os.listdir('/'))
19 | ```
20 |
21 | ## 库的使用
22 |
23 | 你可以使用 [Adafruit CircuitPython Bundle](https://github.com/adafruit/Adafruit_CircuitPython_Bundle)中的任何库。在项目中创建一个“requirements.txt”文件,并写下你使用的库的名称,每行一个。开头为“#”的行是注释。
24 |
25 | 例如,如果你想同时安装[adafruit_display_text](https://circuitpython.readthedocs.io/projects/display_text/en/latest/) 和 [adafruit_dht](https://circuitpython.readthedocs.io/projects/dht/en/latest/),请创建一个包含以下内容的“requirements.txt”文件:
26 |
27 | ```
28 | # requirements.txt example
29 | adafruit_display_text
30 | adafruit_dht
31 | ```
32 |
33 | 当你开始仿真时,Wokwi会下载所有库及其依赖项。它们会被复制到Flash文件系统中的“lib”文件夹中。你可以调用`os.listdir('/lib')`以获取已安装的所有库的列表。有关完整的代码示例,请参阅[CircuitPython Library List](https://wokwi.com/projects/309475039016649280)。
34 |
35 | # CircuitPython REPL介绍
36 |
37 | 当`code.py` 中的代码终止(或者你用Ctrl+C中断它)时,你将进入CircuitPython REPL。REPL是一个交互式提示符,你可以在其中键入python命令并立即查看结果。要将代码粘贴到REPL,按下Ctrl+E进入粘贴模式。
38 |
39 | ## 项目例子
40 |
41 | - [Blink with CircuitPython](https://wokwi.com/projects/309474946192507458)
42 | - [CircuitPython SSD1306 Example](https://wokwi.com/projects/309427357921313345)
43 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/guides/esp32-wifi-wireshark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wokwi/wokwi-docs/de857df2b8ecd29420541f37b90a0746e48ff014/i18n/zh-CN/docusaurus-plugin-content-docs/current/guides/esp32-wifi-wireshark.png
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/guides/libraries.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Arduino库
3 | sidebar_label: Arduino库
4 |
5 | ---
6 |
7 | 当你想要引用一个库时,请转到代码编辑器,并在空行上键入`#`。你将看到一个自动完成下拉菜单,其中包含针对流行库的`#include`自动补全建议。
8 |
9 | 在默认情况下,Wokwi使用标准内置Arduino库(如Wire.h和SPI.h)编译你的代码。
10 |
11 | ## 添加第三方库
12 |
13 | 要将第三方库添加到项目中,请转到代码编辑器中的“库管理器”选项卡,然后按紫色的“+”按钮。在搜索框中输入一些文本以搜索库(例如“FastLED”),然后单击列表中的一个库名称来添加它。
14 |
15 | 你可以使用此方法从Arduino库管理器安装任何Arduino库。
16 |
17 | ### 上传自定义库
18 |
19 | [俱乐部成员](https://wokwi.com/club?ref=docs_libman) 可以通过从他们的计算机中选择一个文件夹来上传任何Arduino库。要上传自定义库,请单击Arduino库管理器中的紫色“+”按钮,然后单击“上传库”。
20 |
21 | 所选文件夹应包含库的源代码(.h和.c/.cpp文件)。选择文件夹后,Wokwi将压缩其内容并将其上传到Wokwi的构建服务器(build server)。你将会看到这个库以.zip文件出现在库管理器中。
22 |
23 | 任何打开该项目的人都可以从库管理器那里下载该库。任何创建项目副本的用户都可以在复制的项目中使用该库。
24 |
25 | ## libraries.txt文件
26 |
27 | 当你通过内置的“库管理器”添加库时,它将在你的项目中创建一个“libraries.txt”文件。这是一个简单的文本文件,列出了项目中安装的所有库,每行一个库。开头为“#”的行是注释。
28 |
29 | 通常,你不需要自己编辑此文件——“库管理器”会为你编辑此文件。但是,如果你想安装库的特定版本,你就会发现这个文件的用处了。要选择特定版本,请在库名称后添加“@”,然后添加要安装的版本。
30 |
31 | 例如,以下文件将安装最新版本的 Servo 库和 FastLED 库,以及 MySensors 库的 2.3.0 版本:
32 |
33 | ```
34 | # Sample libraries.txt file:
35 | Servo
36 | FastLED
37 |
38 | # Install a specific version of a library:
39 | MySensors@2.3.0
40 | ```
41 |
42 | 自定义库有以下格式:库名称,后跟文本“@wokwi:”,以及Wokwi服务器上库zip文件的唯一标识符。
43 |
44 | 通过将相关行从 libraries.txt 复制到另一个项目中,你可以将自定义库拷贝到另一个项目中。
45 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/guides/logic-analyzer-i2c-decoder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wokwi/wokwi-docs/de857df2b8ecd29420541f37b90a0746e48ff014/i18n/zh-CN/docusaurus-plugin-content-docs/current/guides/logic-analyzer-i2c-decoder.png
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/guides/logic-analyzer-pulseview-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wokwi/wokwi-docs/de857df2b8ecd29420541f37b90a0746e48ff014/i18n/zh-CN/docusaurus-plugin-content-docs/current/guides/logic-analyzer-pulseview-1.png
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/guides/logic-analyzer-pulseview-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wokwi/wokwi-docs/de857df2b8ecd29420541f37b90a0746e48ff014/i18n/zh-CN/docusaurus-plugin-content-docs/current/guides/logic-analyzer-pulseview-2.png
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/guides/micropython.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 在Wokwi使用MicroPython
3 | sidebar_label: 使用MicroPython
4 | ---
5 |
6 | 你可以在Wokwi上创建和运行MicroPython项目。[Raspberry Pi Pico MicroPython 工程样例](https://wokwi.com/projects/new/micropython-pi-pico)帮助你快速开始。
7 |
8 | ## 项目的工程结构
9 |
10 | 所有的MicroPython项目必须包含一个 `main.py` 文件。当你开始仿真时,MicroPython将自动从 `main.py` 加载和执行代码。
11 |
12 | Wokwi将所有项目文件复制到Pico的falsh文件系统中。这意味着你的项目可以包括额外的Python模块,你可以从`main.py`或[交互式REPL(交互式命令,开始仿真后,绘图界面出现的黑色的区域)](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop)导入它们。你的项目还可以在文本文件中包含自定义数据。
13 |
14 | 你可以通过运行以下方式获得falsh文件系统中所有文件的列表:
15 |
16 | ```python
17 | import os
18 | print(os.listdir('/'))
19 | ```
20 |
21 | # MicroPython REPL介绍
22 |
23 | 当`main.py`中的代码终止(或者你用Ctrl+C中断它)时,你将进入MicroPython REPL。REPL是一个交互式提示符,你可以在其中键入python命令并立即查看结果。输入`help()`可查看MicroPython API备忘表。要将代码粘贴到REPL中,按下Ctrl+E后可进入粘贴模式。
24 |
25 | ## 项目例子
26 |
27 | - [Blink with MicroPython](https://wokwi.com/projects/300504213470839309)
28 | - [MicroPython 7-Segment Display](https://wokwi.com/projects/300210834979684872)
29 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/guides/translating.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 翻译Wokwi交互界面
3 | sidebar_label: 交互界面的翻译
4 | ---
5 |
6 | 本页面将介绍如何为Wokwi贡献翻译。
7 |
8 | ## 用户交互界面的翻译
9 |
10 | 要将用户界面翻译成新的语言,请下载当前版本的 [英文字符文件](https://wokwi.com/api/i18n/en.json)。翻译文件是标准JSON格式的文本文件。它可以通过任何文本编辑器以及许多翻译工具进行编辑。
11 |
12 | 如果您希望为现有语言之一提供翻译,您可以从[github的这个issue](https://github.com/wokwi/wokwi-features/issues/221)的列表中下载特定语言的翻译文件,并从那里开始工作。
13 |
14 | 当您准备提交翻译时,请[open an issue](https://github.com/wokwi/wokwi-features/issues/new?assignees=&labels=enhancement&template=translation.md&title=)并附加文件。GitHub不支持直接附加JSON文件,因此您可以将文件内容复制到新问题中,也可以压缩并附加Zip文件。
15 |
16 | 目前并非所有文本都可以翻译,但我们一直在添加新文本。您可以订阅[这个issue](https://github.com/wokwi/wokwi-features/issues/221),以便在有新文本可供翻译时收到通知。
17 |
18 | ### 现有的翻译
19 |
20 | - [Chinese](https://wokwi.com/projects/new?lang=zh)
21 | - [Spanish (spain)](https://wokwi.com/projects/new?lang=es-ES)
22 | - [German](https://wokwi.com/projects/new?lang=de)
23 | - [Hungarian](https://wokwi.com/projects/new?lang=hu)
24 | - [Italian](https://wokwi.com/projects/new?lang=it)
25 | - [Portuguese](https://wokwi.com/projects/new?lang=pt-BR)
26 | - [Ukrainian](https://wokwi.com/projects/new?lang=ua)
27 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/keyboard-shortcuts.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 编辑器键盘快捷键
3 | sidebar_label: 键盘快捷键
4 | ---
5 |
6 | ## 一般快捷键
7 |
8 | | 描述 | Windows / Linux | Mac |
9 | | ------------------------------ | --------------- | ------- |
10 | | 启动模拟器 | Ctrl + Enter | ⌘ Enter |
11 | | 保存项目 | Ctrl + S | ⌘ S |
12 | | 代码格式化 | Alt + Shift + F | ⌥ ⇧ F |
13 | | 开/关代码自动补全 | Ctrl + Space | ⌘ Space |
14 | | 显示所有命令列表 | F1 | F1 |
15 | | 跳转到文件中的下个错误 | F8 | F8 |
16 | | 跳转到文件中的上个错误 | Shift + F8 | ⇧ F8 |
17 |
18 | ## 普通编辑快捷键
19 |
20 | | 描述 | Windows / Linux | Mac |
21 | | -------------------------- | --------------- | --- |
22 | | 缩进\* | Ctrl + ] | ⌘ ] |
23 | | 反向缩进\* | Ctrl + [ | ⌘ [ |
24 | | 注释 / 取消注释\* | Ctrl + / | ⌘ / |
25 | | 查找 | Ctrl + F | ⌘ F |
26 | | 替换 | Ctrl + H | ⌘ H |
27 |
28 | \* 如果你选中了一部分代码,这会在选中部分起作用而不是当前行。
29 |
30 |
31 | ## 高级编辑快捷键
32 |
33 | 这些快捷键提供强大的编辑操作,例如控制多行光标和选中部分。
34 |
35 | | 描述 | Windows / Linux | Mac |
36 | | --------------------------------------- | ------------------- | --------- |
37 | | 选中当前选中部分文字的下一处 | Ctrl + D | ⌘ D |
38 | | 选中所有和当前选中文字相同的部分 | Ctrl + Shift + L | ⌘ ⇧ L |
39 | | 复制上一行\* | Alt + Shift + Up | ⌥ ⇧ Up |
40 | | 复制下一行\* | Alt + Shift + Down | ⌥ ⇧ Down |
41 | | 将当前行上移一行\* | Alt + Up | ⌥ Up |
42 | | 将当前行下移一行\* | Alt + Down | ⌥ Down |
43 | | 在上一行增加一个光标 | Ctrl + Alt + Up | ⌘ ⌥ Up |
44 | | 在下一行增加一个光标 | Ctrl + Alt + Down | ⌘ ⌥ Down |
45 | | 扩展选中区域 | Alt + Shift + Right | ⌥ ⇧ Right |
46 | | 缩小选中区域 | Alt + Shift + Left | ⌥ ⇧ Left |
47 |
48 | \* 如果你选中了一部分代码,这会在选中部分起作用而不是当前行。
49 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/board-franzininho-wifi.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: board-franzininiho-wifi板卡参考
3 | sidebar_label: board-franzininiho-wifi板卡参考
4 | ---
5 |
6 | 有关更多在巴西创建的开源ESP32-S2开发板信息,请参阅 [ESP32 Guide](../guides/esp32) 。
7 |
8 | 
9 |
10 | ## 板卡硬件
11 |
12 | 这个板卡包括三个内置的LED:
13 |
14 | - 绿色电源LED
15 | - 连接在33号脚的橙色LED
16 | - 连接在21号脚的蓝色LED
17 |
18 | ## 仿真例子
19 |
20 | - [Franzininho WiFi LCD Clock (NTP) client](https://wokwi.com/projects/323796775459619410)
21 | - [Servo motor control](https://wokwi.com/projects/327061759288410708)
22 | - [LED RGB Mixer (using 3 potentiometers)](https://wokwi.com/projects/324682033130373716)
23 | - [CircuitPython blink example](https://wokwi.com/projects/313606939786347074)
24 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/board-ssd1306.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: board-ssd1306显示模块参考
3 | sidebar_label: board-ssd1306显示模块
4 | ---
5 |
6 | 具有I2C接口的单色128x64 OLED显示器
7 |
8 | 
9 |
10 | ## 引脚名称
11 |
12 | | 名称 | 介绍 | Arduino Uno pin |
13 | | ---- | --------- | --------------- |
14 | | GND | 接地 | GND |
15 | | VCC | 接电源 | 5V |
16 | | SCL | I2C时钟线 | A5 |
17 | | SDA | I2C数据线 | A4 |
18 |
19 | SSD1306模块的默认I2C地址为0x3c(60)。
20 |
21 | ## 属性
22 |
23 | | Name | Description | Default value |
24 | | ----------- | --------------- | ------------- |
25 | | i2cAddress | 显示器的I2C地址 | "0x3c" |
26 |
27 | ## 在Arduino中使用
28 |
29 | 您可以在几个SSD1306 Arduino库之间进行选择:
30 |
31 | - [Adafruit SSD1306](https://wokwi.com/arduino/libraries/Adafruit_SSD1306)
32 | - [ssd1306](https://wokwi.com/arduino/libraries/ssd1306)
33 | - [lcdgfx](https://wokwi.com/arduino/libraries/lcdgfx)
34 | - [U8glib](https://github.com/olikraus/u8glib)
35 | - [U8g2](https://github.com/olikraus/u8g2) (also U8x8)
36 | - [SSD1306Ascii](https://github.com/greiman/SSD1306Ascii)
37 | - [Tiny4kOLED](https://www.arduino.cc/reference/en/libraries/tiny4koled/) - for ATtiny85 users
38 |
39 | 上述所有库都可以在Wokwi上找到。
40 |
41 | ## 仿真案例
42 |
43 | - [SSD1306 Snake Game](https://wokwi.com/projects/296135008348799496) (using Adafruit SSD1306)
44 | - [ATtiny85 Digital Temperature + Humidity on SSD1306](https://wokwi.com/projects/292900020514980360)
45 | - [U8glib Progress Bar](https://wokwi.com/projects/300867986768527882)
46 | - [SSD1306Ascii Fonts](https://wokwi.com/projects/291197274604700168)
47 | - [Adafruit SSD1306 Showcase](https://wokwi.com/projects/344892392214626898)
48 | - [U8g2 Menu](https://wokwi.com/projects/291572875238834696)
49 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-74hc165.svg:
--------------------------------------------------------------------------------
1 |
17 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-74hc595.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-74hc595模块参考
3 | sidebar_label: wokwi-74hc595模块
4 | ---
5 |
6 | 8位串行并行输出(SIPO)移位寄存器
7 |
8 | 
9 |
10 | 使用74HC595移位寄存器扩展微控制器上的_output_引脚数量。对于输入移位寄存器(例如,使用单个输入引脚读取多个按钮),请参阅[wokwi-74hc165](wokwi-74hc165) 。
11 |
12 | ## 引脚名称
13 |
14 | | Pin | 描述 |
15 | | ----- | --------------------------------------------- |
16 | | DS | 串行输入 |
17 | | SHCP | 串行时钟 |
18 | | STCP | 锁存引脚 |
19 | | OE | 输出使能,低有效。如果不使用,请连接到GND。 |
20 | | Q0…Q7 | 并行输出 |
21 | | Q7S | 串行输出* |
22 | | MR | 复位(清除),低有效。如果不使用,请连接到VCC |
23 | | GND | 接地 |
24 | | VCC | 接电源 |
25 |
26 | \* 使用Q7S将多个74HC595单元连接在一起。将Q7S连接到链中的下一个74HC595芯片的DS引脚。
27 |
28 | ## 在Arduino中使用
29 |
30 | 您需要将至少3个引脚连接到微控制器:DS、SHCP和STCP。
31 |
32 | OE引脚可用于禁用移位寄存器的输出。如果您需要该功能,请将其连接到您的微控制器。否则,将其连接到地面以永久启用输出。
33 |
34 | 移位寄存器的输出引脚Q0到Q7,通常连接到 [LEDs](wokwi-led)或7段显示器。
35 |
36 | 以下代码示例假设您将DS连接到Arduino引脚2,SHCP连接到Arduino引脚3,并且STCP到Arduino的4号引脚。它输出一个8位的数,该数每秒翻转两次:
37 |
38 | ```cpp
39 | const int dataPin = 2; /* DS */
40 | const int clockPin = 3; /* SHCP */
41 | const int latchPin = 4; /* STCP */
42 |
43 | void setup() {
44 | pinMode(dataPin, OUTPUT);
45 | pinMode(clockPin, OUTPUT);
46 | pinMode(latchPin, OUTPUT);
47 | }
48 |
49 | int pattern = 0b10101010;
50 | void loop() {
51 | digitalWrite(latchPin, LOW);
52 | shiftOut(dataPin, clockPin, LSBFIRST, pattern);
53 | digitalWrite(latchPin, HIGH);
54 | delay(500);
55 | pattern = ~pattern; // Invert the pattern
56 | }
57 | ```
58 |
59 | 你可以 [尝试该项目](https://wokwi.com/projects/301192672203244042).
60 |
61 | ## 仿真实例
62 |
63 | - [75HC595 shift register with 8 LEDs](https://wokwi.com/projects/301188813482361352)
64 | - [Arduino 16-LED shift register blink](https://wokwi.com/projects/301213976182653448)
65 | - [ATtiny85 75HC595 clock](https://wokwi.com/projects/301366580039647753)
66 | - [8-digit seven-segment hex counter](https://wokwi.com/projects/301304715310793225)
67 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-74hc595.svg:
--------------------------------------------------------------------------------
1 |
17 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-7segment-diagram.svg:
--------------------------------------------------------------------------------
1 |
17 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-7segment-digits.svg:
--------------------------------------------------------------------------------
1 |
14 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-a4988.svg:
--------------------------------------------------------------------------------
1 |
33 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-arduino-nano.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-arduino-nano参考
3 | sidebar_label: wokwi-arduino-nano参考
4 | ---
5 |
6 | Arduino Nano与[Arduino Uno](wokwi-arduino-uno)非常相似,但外形较小。它携带相同的ATmega328p芯片,该芯片具有32K字节的Flash程序内存、2k字节的SRAM和1K字节的EEPROM。
7 |
8 |
9 |
10 | 有关更多信息,请参阅 [wokwi-arduino-uno reference](wokwi-arduino-uno)。
11 |
12 | ## 与Arduino Uno的区别
13 |
14 | Arduino Nano包括两个额外的模拟引脚:A6和A7。这些引脚只能用于模拟输入。它们不能用作数字GPIO引脚。
15 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-attiny85.svg:
--------------------------------------------------------------------------------
1 |
20 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-buzzer.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-buzze参考
3 | sidebar_label: wokwi-buzzer参考
4 | ---
5 |
6 | 压电蜂鸣器
7 |
8 |
9 |
10 | ## 引脚名称
11 |
12 | | Name | Description |
13 | | ---- | ----------- |
14 | | 1 | 负(黑色)引脚 |
15 | | 2 | 正(红色)引脚 |
16 |
17 | ## 属性
18 |
19 | | Name | Description | Default value |
20 | | ------ | ----------------------------------------- | ------------- |
21 | | mode | 蜂鸣器操作模式:"smooth" or "accurate" | "smooth" |
22 | | volume | 声音的音量(响度),介于“0.01”和“1.0”之间 | "1.0" |
23 |
24 | ### 工作模式
25 |
26 | 蜂鸣器可以以两种模式运行:“smooth”(默认)和“accurate”。
27 |
28 | “smooth”听起来更好,适合简单的单频音调。可以在使用Arduino的`tone()`函数演奏旋律或演奏音调时使用。复杂和复调声音在“平滑模式”下可能无法正常播放(或根本无法播放)。
29 |
30 | 当您需要播放复杂的声音时,请使用“accurate”模式。它将准确地播放你输入的声音。然而,它会为您的声音添加可听到的咔嗒声。这些噪音是由于模拟速度的波动-它并不总是能够提供完整的实时声音缓冲区。
31 |
32 | ## Arduino例子
33 |
34 | 将蜂鸣器的引脚1连接到Arduino GND引脚,将蜂鸣器引脚2连接到Arduino引脚8。然后使用`tone()`函数播放声音:
35 |
36 | ```cpp
37 | tone(8, 262, 250); // Plays 262Hz tone for 0.250 seconds
38 | ```
39 |
40 | ## 仿真案例
41 |
42 | - [Simon game](https://wokwi.com/arduino/libraries/demo/simon-game) - 一个有4个按钮的记忆游戏
43 | - [Diatonic piano](https://wokwi.com/projects/291958456169005577) -一架8音符钢琴,使用1-8键按下按钮并播放音符
44 | - [Alarm clock](https://wokwi.com/playground/alarm-clock) - 使用蜂鸣器播放闹钟声
45 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-dht22.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-dht22参考
3 | sidebar_label: wokwi-dht22参考
4 | ---
5 |
6 | 数字湿度和温度传感器。
7 |
8 |
9 |
10 | ## 引脚名称
11 |
12 | | Name | Description |
13 | | ---- | ------------------------- |
14 | | VCC | Positive voltage |
15 | | SDA | 数字数据引脚(输入/输出) |
16 | | NC | Not connected |
17 | | GND | Ground |
18 |
19 | ## 属性
20 |
21 | | Name | Description | Default value |
22 | | ----------- | ------------------------ | ------------- |
23 | | temperature | 初始温度值(摄氏度) | "24" |
24 | | humidity | 初始相对湿度值(百分比) | "40" |
25 |
26 | ## 控制温度
27 |
28 | 您可以在模拟运行期间更改温度和湿度值。单击DHT22传感器,将打开一个小弹出窗口。使用温度和湿度滑块来改变值。点按“隐藏”以关闭弹出窗口。
29 |
30 | :::warning
31 |
32 | 如果您尝试从ESP32读取此传感器,请使用“DHT sensor library for ESPx”库。其他DHT22库可能无法在ESP32上可靠地工作。您可以使用此 [example project](https://wokwi.com/projects/322410731508073042) 作为开始的点。
33 |
34 | :::
35 |
36 | ## 仿真案例
37 |
38 | - [DHTlib DHT22 test](https://wokwi.com/arduino/libraries/DHTlib/dht22_test)
39 | - [DHT-sensor-library code examples](https://wokwi.com/arduino/libraries/DHT-sensor-library)
40 | - [DHT22 on the ESP32](https://wokwi.com/projects/322410731508073042)
41 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-dip-switch-8.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-dip-switch-8参考
3 | sidebar_label: wokwi-dip-switch-8参考
4 | ---
5 |
6 | 一个8路开关
7 |
8 |
9 |
10 | ## 引脚名称
11 |
12 | | Name | Description |
13 | | ---- | ------------------- |
14 | | 1a | 开关1的第一个连接点 |
15 | | 1b | 开关1的第二个连接点 |
16 | | 2a | 开关2的第一个连接点 |
17 | | 2b | 开关2的第二个连接点 |
18 | | … | … |
19 | | 8a | 开关8的第一个连接点 |
20 | | 8b | 开关8的第二个连接点 |
21 |
22 | ## 键盘操作
23 |
24 | 在仿真运行期间,您可以使用键盘切换开关。单击DIP开关进行选择,然后按键“1”到“8”切换开关。
25 |
26 | Firefox用户:如果键盘快捷键不能工作,请确保禁用“开始键入时搜索文本”设置。
27 |
28 | ## 仿真案例
29 |
30 | - [DIP Switch + LED Bar example](https://wokwi.com/projects/314167394611233344)
31 | - [Arduino PIND register example](https://wokwi.com/projects/314168546236039745)
32 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-ds1307.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-ds1307参考
3 | sidebar_label: wokwi-ds1307参考
4 | ---
5 |
6 | 带有I2C接口和56字节NV SRAM的RTC(实时时钟)模块。
7 |
8 |
9 |
10 | ## 引脚名称
11 |
12 | | Name | Description |
13 | | ---- | ------------------------ |
14 | | GND | Ground |
15 | | 5V | Positive voltage (5V) |
16 | | SDA | I2C 数据线 |
17 | | SCL | I2C 时钟线 |
18 | | SQW | 方波输出。模拟中不可用。 |
19 |
20 | DS1307的I2C地址是0x68。
21 |
22 | ## 仿真工作
23 |
24 | 模拟的DS1307在开始模拟时会自动初始化为当前系统时间。然后它继续数时间。
25 |
26 | 仿真中运行的代码可以更新DS1307的日期/时间,DS1307将跟踪更新时间。
27 |
28 | ## 仿真案例
29 |
30 | - [Reading current date/time using RTClib](https://wokwi.com/projects/305979285237137984)
31 | - [Alarm clock](https://wokwi.com/playground/alarm-clock)
32 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-hc-sr04.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-hc-sr04参考
3 | sidebar_label: wokwi-hc-sr04参考
4 | ---
5 |
6 | HC-SR04超声波距离传感器
7 |
8 |
9 |
10 | ## 引脚名称
11 |
12 | | Name | Description |
13 | | ---- | ------------------------ |
14 | | VCC | Voltage supply (5V) |
15 | | TRIG | 脉冲开始测量 |
16 | | ECHO | 测量高脉冲长度以获得距离 |
17 | | GND | Ground |
18 |
19 | ## 属性
20 |
21 | | Name | Description | Default value |
22 | | -------- | ---------------------- | ------------- |
23 | | distance | 初始距离值,单位:厘米 | "400" |
24 |
25 | ## 工作方式
26 |
27 | 要开始新的距离测量,请将TRIG引脚设置为10uS或更高的高度。然后等到ECHO引脚变高,并计算它保持高的时间(脉冲长度)。ECHO高脉冲的长度与距离成正比。下表将ECHO脉冲长度(以微秒为单位)转换为厘米/英寸:
28 |
29 | | 单位 | 距离 |
30 | | ----------- | -------------- |
31 | | Centimeters | 脉冲长度 / 58 |
32 | | Inches | 脉冲长度 / 148 |
33 |
34 | ### 设置距离
35 |
36 | 要在模拟运行时更改距离,请单击图表中的HC-SR04图并使用滑块设置距离值。您可以选择2厘米到400厘米之间的任何值。
37 |
38 | ## Arduino代码参考
39 |
40 | ```cpp
41 | #define PIN_TRIG 3
42 | #define PIN_ECHO 2
43 |
44 | void setup() {
45 | Serial.begin(115200);
46 | pinMode(PIN_TRIG, OUTPUT);
47 | pinMode(PIN_ECHO, INPUT);
48 | }
49 |
50 | void loop() {
51 | // Start a new measurement:
52 | digitalWrite(PIN_TRIG, HIGH);
53 | delayMicroseconds(10);
54 | digitalWrite(PIN_TRIG, LOW);
55 |
56 | // Read the result:
57 | int duration = pulseIn(PIN_ECHO, HIGH);
58 | Serial.print("Distance in CM: ");
59 | Serial.println(duration / 58);
60 | Serial.print("Distance in inches: ");
61 | Serial.println(duration / 148);
62 |
63 | delay(1000);
64 | }
65 | ```
66 |
67 | 在这里尝试 [this example on Wokwi](https://wokwi.com/projects/304444938977804866)
68 |
69 | ## 仿真实例
70 |
71 | - [Distance sensor and LED](https://wokwi.com/projects/290056311044833800)
72 | - [Display distance on LCD screen](https://wokwi.com/projects/290043622233997832)
73 | - [Seven segment distance display](https://wokwi.com/projects/295030553275532810)
74 | - [Franzininho ultrasonic sensor](https://wokwi.com/projects/302020345098928648)
75 | - [Parking sensor](https://wokwi.com/projects/290964046833779209)
76 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-ir-receiver.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-ir-receiver参考
3 | sidebar_label: wokwi-ir-receiver参考
4 | ---
5 |
6 | 38KHz红外接收器
7 |
8 |
9 |
10 | ## 引脚名称
11 |
12 | | Name | Description |
13 | | ---- | ---------------- |
14 | | GND | Ground |
15 | | VCC | Positive voltage |
16 | | DAT | Digital output |
17 |
18 | ## 使用接收器
19 |
20 | The receiver can be used in two ways:
21 |
22 | 1. Use the [IR Remote](wokwi-ir-remote) to send infrared commands.
23 | 2. Click on the receiver (while the simulation is running) to send arbitrary [NEC-encoded IR signals](https://exploreembedded.com/wiki/NEC_IR_Remote_Control_Interface_with_8051#NEC_Protocol). The user interface lets you specify both the address and the command fields on the NEC message.
24 |
25 | To read the commands from your Arduino Code, you can use the [IRRemote](https://github.com/Arduino-IRremote/Arduino-IRremote) or [IRMP](https://github.com/ukw100/IRMP) libraries.
26 |
27 | 接收器可以通过两种方式使用:
28 |
29 | 1. 使用 [IR Remote](wokwi-ir-remote) 发送红外命令。
30 |
31 | 2. 单击接收器(在模拟运行时)发送任意 [NEC-encoded IR signals](https://exploreembedded.com/wiki/NEC_IR_Remote_Control_Interface_with_8051#NEC_Protocol) 。用户界面允许您指定NEC消息上的地址和命令字段。
32 |
33 | 要从Arduino代码中读取命令,您可以使用 [IRRemote](https://github.com/Arduino-IRremote/Arduino-IRremote) 或者 [IRMP](https://github.com/ukw100/IRMP) 库。
34 |
35 | ## 仿真案例
36 |
37 | - [IRRemote + LCD Display](https://wokwi.com/projects/298934082074575369)
38 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-ir-remote.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-ir-remote参考
3 | sidebar_label: wokwi-ir-remote参考
4 | ---
5 |
6 | 38KHz红外遥控器,带20个功能键。与[IR Receiver module](wokwi-ir-receiver)一起使用。
7 |
8 |
9 |
10 | ## 功能键
11 |
12 | 密钥发送使用[NEC frame format](https://exploreembedded.com/wiki/NEC_IR_Remote_Control_Interface_with_8051#NEC_Protocol).编码的红外消息。每个键发送不同的命令值(见下表),地址字段始终为0。
13 |
14 | 每个按键都有一个键盘快捷键,可以在遥控器对焦时激活该键。
15 |
16 | 下表列出了NEC命令、NEC编码值和键盘快捷键,对于每个按键:
17 |
18 | | Key | Command | NEC encoded | Keyboard Shortcut |
19 | | -------- | ------- | ----------- | ----------------- |
20 | | Power | 162 | 0xFFA25D | O |
21 | | Menu | 226 | 0xFFE21D | M |
22 | | Test | 34 | 0xFF22DD | T |
23 | | Plus | 2 | 0xFF02FD | + |
24 | | Back | 194 | 0xFFC23D | B |
25 | | Previous | 224 | 0xFFE01F | Left arrow key |
26 | | Play | 168 | 0xFFA857 | P |
27 | | Next | 144 | 0xFF906F | Right arrow key |
28 | | 0 | 104 | 0xFF6897 | 0 |
29 | | Minus | 152 | 0xFF9867 | - (minus) |
30 | | C | 176 | 0xFFB04F | C |
31 | | 1 | 48 | 0xFF30CF | 1 |
32 | | 2 | 24 | 0xFF18E7 | 2 |
33 | | 3 | 122 | 0xFF7A85 | 3 |
34 | | 4 | 16 | 0xFF10EF | 4 |
35 | | 5 | 56 | 0xFF38C7 | 5 |
36 | | 6 | 90 | 0xFF5AA5 | 6 |
37 | | 7 | 66 | 0xFF42BD | 7 |
38 | | 8 | 74 | 0xFF4AB5 | 8 |
39 | | 9 | 82 | 0xFF52AD | 9 |
40 |
41 | ## 仿真案例
42 |
43 | - [IRRemote + LCD Display](https://wokwi.com/projects/298934082074575369)
44 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-ks2e-m-dc5.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: ks2e-m-dc5 Relay参考
3 | sidebar_label: wokwi-ks2e-m-dc5继电器参考
4 | ---
5 |
6 | 双路双刀(DPDT)继电器
7 |
8 |
9 |
10 | ## 引脚名称
11 |
12 | | Name | Description |
13 | | ----- | --------------------------------- |
14 | | COIL1 | 线圈的第一个端子 |
15 | | COIL2 | 线圈的第二个端子 |
16 | | P1 | 第一个连接点 |
17 | | NC1 | 正常关闭 - 当线圈不供电时连接到P1 |
18 | | NO1 | 正常打开-线圈供电时连接到P1 |
19 | | P2 | 第二个连接点 |
20 | | NC2 | 正常关闭-当线圈无法供电时连接到P2 |
21 | | NO2 | 正常打开-线圈供电时连接到P2 |
22 |
23 | ## 操作方式
24 |
25 | 继电器是一种具有两种状态的电子开关:线圈无动力和线圈供电。默认情况下,线圈没有动力。您可以通过在引脚COIL1和COIL2之间施加电压来为线圈供电。
26 |
27 | 当线圈断开电源时,P1连接到NC1,P2连接到NC2(通常关闭/连接的NC手段)。
28 |
29 | 当线圈供电时,P1连接到NO1,P2连接到NO2(NC表示正常打开/断开)。
30 |
31 | 下图总结了继电器的状态:
32 |
33 | 
34 |
35 | ## 仿真案例
36 |
37 | - [One relay controlling two LEDs](https://wokwi.com/projects/322846360729551444)
38 | - [Relay Flip-Flop](https://wokwi.com/projects/322802227591774802) - 使用三个继电器的单位内存元素
39 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-ky-040-timing.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wokwi/wokwi-docs/de857df2b8ecd29420541f37b90a0746e48ff014/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-ky-040-timing.png
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-lcd2004.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-lcd2004显示模块参考
3 | sidebar_label: wokwi-lcd2004显示模块参考
4 | ---
5 |
6 | 液晶显示器,每行4行,20个字符。
7 |
8 |
9 |
10 | 这个组件具有与wokwi-lcd1602相同的引脚和属性。
11 |
12 | 有关**完整信息和代码示例**,请参阅 [wokwi-lcd1602 reference](wokwi-lcd1602)。
13 |
14 | ### 示例
15 |
16 | | Result | Attrs |
17 | | --------------------------------------------------------------------- | -------------------------------------------- |
18 | | | `{ }` |
19 | | | `{ "pins": "i2c" }` |
20 | | | `{ "background": "blue", "color": "white" }` |
21 |
22 | ## 仿真案例
23 |
24 | - [LCD2004 Tiny Pacman on Wokwi](https://wokwi.com/projects/294590769009787402)
25 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-led-bar-graph.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-led-bar-graph参考
3 | sidebar_label: wokwi-led-bar-graph参考
4 | ---
5 |
6 | 10段LED条形图。
7 |
8 |
9 |
10 | ## 引脚名称
11 |
12 | | Name | Description |
13 | | ------ | ------------------------------------ |
14 | | A**n** | LED的阳极(正引脚) **n** (n = 1…10) |
15 | | C**n** | LED的阴极(负引脚) **n** (n = 1…10) |
16 |
17 | 例如,例如A1是顶部LED的阳极,C1是顶部LED的阴极。
18 |
19 | ## 属性
20 |
21 | | Name | Description | Default value |
22 | | ----- | ---------------------------------------- | ------------- |
23 | | color | LED主体的颜色,或特殊值“GYR”/“BCYR”之一* | "red" |
24 |
25 | \* GYR的意思是绿色-黄色-红色。BCYR的意思是青蓝色-黄色-红色
26 |
27 | ### 示例
28 |
29 | | Result | Attrs |
30 | | ----------------------------------------------------------------------- | ------------------------ |
31 | | | `{ "color": "yellow" }` |
32 | | | `{ "color": "#9EFF3C" }` |
33 | | | `{ "color": "GYR"}` |
34 | | | `{ "color": "BCYR"}` |
35 |
36 | ## 仿真案例
37 |
38 | - [Arduino LED Graph Bar](https://wokwi.com/projects/309829489359061570) - Move the potentiometer knob to control the LEDs
39 | - [Raspberry Pi Pico Binary Counter](https://wokwi.com/projects/309828467927548481)
40 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-max7219-matrix-chain-4.svg:
--------------------------------------------------------------------------------
1 |
34 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-max7219-matrix.svg:
--------------------------------------------------------------------------------
1 |
48 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-microsd-card-upload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wokwi/wokwi-docs/de857df2b8ecd29420541f37b90a0746e48ff014/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-microsd-card-upload.png
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-nlsf595.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-nlsf595参考
3 | sidebar_label: wokwi-nlsf595参考
4 | ---
5 |
6 | 串行(SPI)三色LED驱动器
7 |
8 | 
9 |
10 | 使用NLSF595移位寄存器将耗电的RGB LED连接到微控制器。一个单元可以控制两个RGB LED,一个由两个单元组成的链条最多可以控制五个RGB LED。
11 |
12 | ## 引脚名称
13 |
14 | | Pin | Description |
15 | | ----- | ------------------------------------------------------ |
16 | | SI | Serial input |
17 | | SCK | Serial clock |
18 | | RCK | Storage (latch) pin |
19 | | OE | Output enable, active low. Connect to GND if not used. |
20 | | QA…QH | Parallel output |
21 | | SQH | Serial output\* |
22 | | SCLR | Reset (clear), active low. Connect to VCC if not used |
23 | | GND | Ground |
24 | | VCC | Supply voltage |
25 |
26 | \* 使用Q7S将多个NLSF595设备链接在一起。将SQH连接到链式下一个NLSF595芯片的SI引脚。
27 |
28 | ## 使用NLSF595
29 |
30 | 您需要将至少3个引脚连接到微控制器:SI、SCK和RCK。
31 |
32 | OE引脚可用于禁用移位寄存器的输出。如果您需要该功能,请将其连接到您的微控制器。否则,将其连接到地面以永久启用输出。
33 |
34 | 移位寄存器的输出引脚QA通过QH,通常连接到共极的[RGB LEDs](wokwi-rgb-led)输入引脚。
35 |
36 | ## 仿真案例
37 |
38 | - [NLSF595 LED Driver with 2 RGB LEDs](https://wokwi.com/projects/315085666329297472)
39 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-nlsf595.svg:
--------------------------------------------------------------------------------
1 |
17 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-ntc-temperature-sensor.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-ntc-temperature-sensor参考
3 | sidebar_label: wokwi-ntc-temperature-sensor参考
4 | ---
5 |
6 | 模拟温度传感器:NTC(负温度系数)热敏电阻。
7 |
8 |
9 |
10 | ## 引脚名称
11 |
12 | | Name | Description |
13 | | ---- | ---------------------- |
14 | | VCC | Positive power supply |
15 | | OUT | Output signal (analog) |
16 | | GND | Ground |
17 |
18 | ## 属性
19 |
20 | | Name | Description | Default value |
21 | | ----------- | -------------------- | ------------- |
22 | | temperature | 初始温度值(摄氏度) | "24" |
23 | | beta | 热敏电阻的β系数 | "3950" |
24 |
25 | ## 读取温度
26 |
27 | 温度传感器模块包括一个10K NTC热敏电阻和10K电阻串联。
28 |
29 | 这种设置产生的电压取决于温度。您可以通过以下方式读取此电压
30 |
31 | 将热敏电阻的OUT引脚连接到模拟输入引脚,然后使用
32 |
33 | `analogRead()`函数。
34 |
35 | 使用以下代码将`analogRead()` 的返回值转换为温度值(以摄氏度为单位):
36 |
37 | ```cpp
38 | const float BETA = 3950; // should match the Beta Coefficient of the thermistor
39 | int analogValue = analogRead(A0);
40 | float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
41 | ```
42 |
43 | ## 仿真实例
44 |
45 | - [NTC Thermistor Basic Example](https://wokwi.com/projects/299330254810382858)
46 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-pir-motion-sensor.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-pir-motion-sensor参考
3 | sidebar_label: wokwi-pir-motion-sensor参考
4 | ---
5 |
6 | 被动红外(PIR)运动传感器。
7 |
8 |
9 |
10 | ## 引脚名称
11 |
12 | | Name | Description |
13 | | ---- | ---------------- |
14 | | GND | Ground |
15 | | OUT | Output (digital) |
16 | | VCC | Supply voltage |
17 |
18 | ## 属性
19 |
20 | | Name | Description | Default value |
21 | | ----------- | ------------------------------------------- | ------------- |
22 | | delayTime | OUT引脚的保持高电平的时间 | "5" |
23 | | inhibitTime | 当OUT恢复到低电平时,传感器将忽略运动的秒数 | "1.2" |
24 | | retrigger | 设置为“0”以禁用重新触发 | "" |
25 |
26 | ## 使用传感器
27 |
28 | 要触发PIR运动传感器:
29 |
30 | 1. 通过单击传感器(在模拟运行时)选择传感器。
31 |
32 | 2. 将打开一个小弹出窗口。点按“模拟运动”。
33 |
34 | 触发传感器将使OUT引脚高5秒(延迟时间),然后又变低。在接下来1.2秒(抑制时间),传感器将忽略任何进一步的输入,然后再次开始感应运动。
35 |
36 | 您可以通过设置延迟时间来调整OUT引脚的高持续时间属性(在物理传感器上,您使用电位器设置延迟)。
37 |
38 | 传感器的默认设置是重新触发:传感器不断检查在OUT引脚高时进行运动。它将延长每次的延迟时间检测到另一个运动事件的时间。您可以通过以下方式禁用此行为设置“retrigger”属性为“0”。
39 |
40 | ## 仿真实例
41 |
42 | - [PIR sensor example (from AdaFruit)](https://wokwi.com/projects/299284655047180808)
43 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-potentiometer.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-potentiometer参考
3 | sidebar_label: wokwi-potentiometer参考
4 | ---
5 |
6 | 旋钮控制可变电阻(线性电位器)
7 |
8 |
9 |
10 | 以下信息也适用于[slide potentiometer](wokwi-slide-potentiometer)。
11 |
12 | ## 引脚名称
13 |
14 | | Name | Description |
15 | | ---- | -------------------------------------- |
16 | | GND | Ground |
17 | | SIG | Output, connect to an analog input pin |
18 | | VCC | Supply voltage |
19 |
20 | 注意:Wokwi**不**支持完整的模拟仿真,因此您将获得相同的结果,即使您没有连接GND/VCC引脚。
21 |
22 | 这在将来可能会改变,所以无论如何,总是连接GND/VCC是个好习惯。
23 |
24 | ## 属性
25 |
26 | | Name | Description | Default value |
27 | | ----- | ----------------------------- | ------------- |
28 | | value | 电位器的初始值,在0到1023之间 | "0" |
29 |
30 | ## 在Arduino中使用电位器
31 |
32 | 将SIG引脚连接到Arduino的模拟输入引脚之一(A0、A1、...)。然后使用`analogRead()`函数读取电位器的当前值。
33 |
34 | 以下代码示例假设电位器连接到A0。
35 |
36 | 它将每100毫秒读取和打印电位器的当前值:
37 |
38 | ```cpp
39 | void setup() {
40 | Serial.begin(115200);
41 | pinMode(A0, INPUT);
42 | }
43 |
44 | void loop() {
45 | int value = analogRead(A0);
46 | Serial.println(value);
47 | delay(100);
48 | }
49 | ```
50 |
51 | 您可以 [run the example on Wokwi](https://wokwi.com/projects/298685457758159369)。观察绘图仪在移动电位器旋钮时如何变化。
52 |
53 | ## 键盘控制
54 |
55 | 您可以使用键盘控制电位器:
56 |
57 | - 左/右 - 精细运动
58 |
59 | - 上页/下页 - 粗略的移动
60 |
61 | - 主页/结束 - 移动到范围的开始(0)或结束(1023)
62 |
63 | 在使用这些键盘快捷键之前,您需要单击电位器。
64 |
65 | ## 仿真实例
66 |
67 | - [Knob](https://wokwi.com/arduino/libraries/Servo/Knob) - Control a [servo](wokwi-servo) with a potentiometer
68 | - [Plot](https://wokwi.com/projects/298685457758159369) - Plot potentiometer values in the Serial Plotter
69 | - [Block shooter](https://wokwi.com/projects/291960996581343753) - Breakout style game
70 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-resistor.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-resistor参考
3 | sidebar_label: wokwi-resistor参考
4 | ---
5 |
6 | 这就是电阻。
7 |
8 |
9 |
10 | :::warning
11 |
12 | Wokwi只有一个非常基本的模拟电路仿真。您将无法同时使用电阻器和模拟组件(例如电位器或NTC温度传感器)。您仍然可以将电阻用作外部上拉/下拉电阻。
13 |
14 | :::
15 |
16 | ## 引脚名称
17 |
18 | | Pin | Description |
19 | | --- | ----------- |
20 | | 1 | First pin |
21 | | 2 | Second pin |
22 |
23 | ## 属性
24 |
25 | | Name | Description | Default value |
26 | | ----- | -------------------- | ------------- |
27 | | value | 电阻值,以欧姆为单位 | "1000" |
28 |
29 | ### 示例
30 |
31 | | Result | Attrs |
32 | | ----------------------------------- | ------------------------- |
33 | | | `{ "value": "1" }` |
34 | | | `{ "value": "220" }` |
35 | | | `{ "value": "10000000" }` |
36 |
37 | 查看[resistor showcase by Koepel](https://wokwi.com/projects/300936732038136328) 以获取更多示例。
38 |
39 | ## 仿真案例
40 |
41 | - [External pull-down resistor](https://wokwi.com/projects/302214836102627848) - 如何使用电阻作为按钮的下拉
42 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-rgb-led.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-rgb-led参考
3 | sidebar_label: wokwi-rgb-led参考
4 | ---
5 |
6 | 5毫米红色、绿色和蓝色(RGB)LED。
7 |
8 |
9 |
10 | ## 引脚名称
11 |
12 | | Name | Description |
13 | | ---- | ------------ |
14 | | R | Red LED |
15 | | G | Green LED |
16 | | B | Blue LED |
17 | | COM | Common pin\* |
18 |
19 | \* 默认情况下,公共引脚是阳极(正引脚)。您可以通过将“通用”属性设置为“cathode”来更改它。
20 |
21 | ## 属性
22 |
23 | | Name | Description | Default value |
24 | | ------ | ---------------------------------- | ------------- |
25 | | common | 常见的引脚类型:“cathode”或“anode” | "anode" |
26 |
27 | ## 仿真实例
28 |
29 | - [RGB LED with 3 linear sliders](https://wokwi.com/projects/306455554559050306)
30 | - [Soft pulsating RGB LED](https://wokwi.com/projects/306461175146611264)
31 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-servo.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-servo参考
3 | sidebar_label: wokwi-servo参考
4 | ---
5 |
6 | 标准微伺服电机
7 |
8 |
9 |
10 | ## 引脚名称
11 |
12 | | Name | Description |
13 | | ---- | --------------------- |
14 | | PWM | Servo control signal |
15 | | V+ | Positive voltage (5V) |
16 | | GND | Ground |
17 |
18 | ## 属性
19 |
20 | | Name | Description | Default value |
21 | | --------- | ------------------------------------------- | ------------- |
22 | | horn | 安装角的类型: "single", "double" or "cross" | "single" |
23 | | hornColor | 伺服角的颜色 | "#ccc" |
24 |
25 | ### 示例
26 |
27 | | Result | Attrs |
28 | | -------------------------------- | ---------------------------- |
29 | | | `{ "horn": "single" }` |
30 | | | `{ "hornColor": "#000088" }` |
31 | | | `{ "horn": "double" }` |
32 | | | `{ "horn": "cross" }` |
33 |
34 | ## 仿真实例
35 |
36 | - [Sweep](https://wokwi.com/arduino/libraries/Servo/Sweep)
37 | - [Knob](https://wokwi.com/arduino/libraries/Servo/Knob)
38 | - [Arduino Nano controlling 1 servo with two pushbuttons](https://wokwi.com/projects/328312829780165204)
39 | - [Arduino Uno controlling 5 servos](https://wokwi.com/projects/305087394119418434)
40 | - [Arduino Mega animating 32 servos](https://wokwi.com/projects/305336312628511297)
41 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-slide-potentiometer.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-slide-potentiometer参考
3 | sidebar_label: wokwi-slide-potentiometer参考
4 | ---
5 |
6 | 滑动可变电阻(线性电位器)
7 |
8 |
9 |
10 | 滑动电位器的功能和引脚与 [wokwi-potentiometer](wokwi-potentiometer)相同。查看 [wokwi-potentiometer docs](wokwi-potentiometer) 了解更多信息。
11 |
12 | ## 属性
13 |
14 | | Name | Description | Default value |
15 | | ------------ | ------------------------------------------------------------ | ------------- |
16 | | value | 电位器的初始值,在0到1023之间 | "0" |
17 | | travelLength | 尖端的行程长度(毫米)。控制电位器的宽度.
常用值: "15", "20", "30", "45", "60", "100" | "30" |
18 |
19 | ### 示例
20 |
21 | | Result | Attrs |
22 | | ------------------------------------------------ | --------------------------- |
23 | | | `{ "travelLength": "15" }` |
24 | | | `{ "travelLength": "60" }` |
25 | | | `{ "travelLength": "100" }` |
26 |
27 | ## 仿真实例
28 |
29 | - [Slide potentiometer + Servo](https://wokwi.com/projects/297604176384360973) - Control a [servo](wokwi-servo) with a slide potentiometer
30 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-slide-switch.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-slide-switch参考
3 | sidebar_label: wokwi-slide-switch参考
4 | ---
5 |
6 | 标准单极双掷(SPDT)滑动开关。
7 |
8 |
9 |
10 | ## 引脚名称
11 |
12 | | Name | Description |
13 | | ---- | --------------- |
14 | | 1 | Left terminal |
15 | | 2 | Common terminal |
16 | | 3 | Right terminal |
17 |
18 | 滑动开关有三个引脚。引脚2(中间)是常见的引脚。根据在不同开关的手柄中的位置,它连接到引脚1或3:
19 |
20 | | Handle position | Description |
21 | | --------------- | --------------------- |
22 | | Left | Shorting pins 1 and 2 |
23 | | Right | Shorting pins 3 and 2 |
24 |
25 | 下图说明了滑动开关内部的连接。你可以看到灰色的滑动与手柄一起移动并在引脚2和引脚1或3之间建立连接的触点:
26 |
27 | 
28 |
29 | ## 属性
30 |
31 | | Name | Description | Default value |
32 | | ------ | -------------------------------------------------------------------- | ------------- |
33 | | value | 滑动开关的初始位置:
"" for left, "1" for right | "" |
34 | | bounce | 设置为“0”以禁用反弹 | "" |
35 |
36 | ### 弹跳
37 |
38 | 当您移动物理滑动开关时,电路会打开和关闭数十次或数百次。
39 |
40 | 这种现象被称为 [Bouncing](wokwi-pushbutton#bouncing)。
41 |
42 | Wokwi默认模拟开启反弹。您可以通过将单个开关的“bounce”设置为“0”来禁用:
43 |
44 | `{ "bounce": "0" }`
45 |
46 | ## 仿真实例
47 |
48 | - [Slide Switch and LED](https://wokwi.com/projects/288276100805558797) - Using a slide switch to toggle an LED
49 | - [Slide Switch and 2 LEDs](https://wokwi.com/projects/288278249939665421) - A slide switch toggles between 2 LEDs
50 | - [Digital Pin Output Switching](https://wokwi.com/projects/292033853022798344) - A slide switch redirects the output of a digital pin to one of two LEDs
51 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-ssd1306.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-ssd1306显示模块参考
3 | sidebar_label: wokwi-ssd1306参考
4 | ---
5 |
6 | 具有I2C接口的单色128x64 OLED显示器
7 |
8 |
9 |
10 | 注:此部件已被弃用。请改用[board-ssd1306](./board-ssd1306)。
11 |
12 | ## 引脚名称
13 |
14 | | Name | Description | Arduino Uno pin |
15 | | ----------- | --------------------- | --------------- |
16 | | DATA | I2C data line (SDA) | A4 |
17 | | CLK | I2C clock line (SCL) | A5 |
18 | | DC, RST, CS | Unused\* | - |
19 | | 3V3 | 3.3V regulated output | - |
20 | | GND | Ground | GND |
21 | | VIN | Supply voltage | 5V |
22 |
23 | \* DC、RST和CS适用于SPI模式。SSD1306模拟仅支持I2C模式,因此这些引脚不起作用。
24 |
25 | SSD1306模块的默认I2C地址为0x3c(60)。
26 |
27 | ## 属性
28 |
29 | | Name | Description | Default value |
30 | | ---------- | -------------------------- | ------------- |
31 | | i2cAddress | I2C address of the display | "0x3c" |
32 |
33 | ## 仿真实例
34 |
35 | See [board-ssd1306](board-ssd1306#simulator-examples).
36 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/parts/wokwi-tm1637-7segment.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-tm1637-7segment参考
3 | sidebar_label: wokwi-tm1637-7segment参考
4 | ---
5 |
6 | TM1637——4线接口的七段LED显示模块
7 |
8 | 
9 |
10 | ## 引脚名称
11 |
12 | | Name | Description |
13 | | ---- | ----------- |
14 | | CLK | 时钟线 |
15 | | DIO | 数据线 |
16 | | VCC | 电源 |
17 | | GND | 接地 |
18 |
19 | ## 属性
20 |
21 | | Name | Description | Default value |
22 | | ----- | ----------- | ------------- |
23 | | color | 段LED的颜色 | "red" |
24 |
25 | ## 使用 7 段显示器
26 |
27 | 七段显示器的这种变体使用TM1637芯片。您只需要2个微控制器引脚即可与它通信。
28 |
29 | TM1637通信协议不标准。它类似于I2C协议,但它更简单,与I2C不兼容。幸运的是,您可以使用库,而不必担心协议的实现。以下是您可以在Arduino上使用的一些TM1637库: [SevenSegmentTM1637@1.0.0](https://github.com/bremme/arduino-tm1637),Grove 4-Digit Display。
30 |
31 | ## 仿真实例
32 |
33 | - [TM1637 Counter](https://wokwi.com/projects/339227323398095442)
34 | - [TM1637 Clock](https://wokwi.com/projects/339227567530705492)
35 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/vscode/debugging.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 调试你的代码
3 | sidebar_label: 调试
4 | ---
5 |
6 | 您可以在模拟器运行代码时使用 VS Code 调试器对其进行调试。要设置调试器,请按照以下步骤操作:
7 |
8 | ## 配置 Wokwi
9 |
10 | 将以下行添加到 `wokwi.toml` 配置文件的 `[wokwi]` 部分:
11 |
12 | ```toml
13 | gdbServerPort=3333
14 | ```
15 |
16 | ## 配置 VS Code
17 |
18 | 在 `.vscode/launch.json` 为 VS Code 创建启动配置文件。这是您可以使用的模板:
19 |
20 | ```json
21 | {
22 | "version": "0.2.0",
23 | "configurations": [
24 | {
25 | "name": "Wokwi GDB",
26 | "type": "cppdbg",
27 | "request": "launch",
28 | "program": "${workspaceFolder}/build/your-firmware.elf",
29 | "cwd": "${workspaceFolder}",
30 | "MIMode": "gdb",
31 | "miDebuggerPath": "/usr/local/bin/xtensa-esp32-elf-gdb",
32 | "miDebuggerServerAddress": "localhost:3333"
33 | }
34 | ]
35 | }
36 | ```
37 | `type` 描述了此处使用的 VS Code 扩展。在本例中为 `cppdbg`。因此必须安装以下扩展:https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools
38 | 将 `program` 路径替换为固件的 ELF 文件路径,将 `miDebuggerPath` 替换为支持项目架构的 GDB 可执行文件的路径(例如,对于 AVR 项目,使用 `avr-gdb`)。
39 |
40 | ## 启动调试器
41 |
42 | 按 **F1** 启动 Wokwi 模拟器,然后选择“**Wokwi: Start Simulator and Wait for Debugger**”。模拟器将加载,但程序将暂停,等待调试器连接。然后按 **F5** 启动调试器。
43 |
44 | :::warning
45 | 您需要在启动调试器之前启动 Wokwi。如果先启动调试器,它将无法连接到模拟器。
46 | :::
47 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-plugin-content-docs/current/welcome.md:
--------------------------------------------------------------------------------
1 | ---
2 | slug: /
3 | title: 欢迎使用Wokwi!
4 | ---
5 |
6 | import { LEDBullet } from '@site/src/components/LEDBullet'
7 |
8 | Wokwi是一个在线的电子电路仿真器。你可以使用它来仿真Arduino、ESP32和许多其他流行的电路板、元器件以及传感器。
9 |
10 | 这里为你准备了可以体验Wokwi的一些快速示例:
11 |
12 | - [Arduino Uno "Hello World"](https://wokwi.com/projects/322062421191557714)
13 | - [Blink an LED on ESP32](https://wokwi.com/projects/305566932847821378)
14 | - [Monitor the weather on ATtiny85](https://wokwi.com/projects/292900020514980360)
15 | - [Control 32 Servos with Arduino Mega](https://wokwi.com/projects/305336312628511297)
16 | - [Animate an LED Matrix with FastLED](https://wokwi.com/projects/320579687608746578)
17 | - [7 Segment Counter with MicroPython on ESP32](https://wokwi.com/projects/300210834979684872)
18 |
19 | ## Wokwi有什么特点呢?
20 |
21 |
22 |
23 | 无需使用实际的元器件或下载大型软件。wokwi在线网站可以提供你需要的一切!在这里你可以用短时间去构建你的下一个物联网项目。
24 |
25 |
26 |
27 |
28 |
29 | 您是不会损坏虚拟硬件的。相信我们,我们都测试完毕了!所以不要担心烧毁了你珍贵的元器件。与真正的硬件不同,在这里,你总是可以撤销,你还有重来无数次的机会。
30 |
31 |
32 |
33 |
34 |
35 | 在这里,你只需要分享你的Wokwi项目的链接,就可以方便的寻求帮助。
36 |
37 |
38 |
39 |
40 |
41 | 在这里,硬件和软件问题是分开的,不用担心硬件的问题,专心你的软件。
42 |
43 |
44 |
45 |
46 |
47 | 再也不用从旧的项目中拆除元器件了,随意的取用你需要使用的零件吧!你再也不用担心项目的花费和元器件的库存。
48 |
49 |
50 |
51 |
52 |
53 | 这是一个分享项目、寻求帮助和获得灵感的地方!
54 | Wokwi Discord Community
55 |
56 |
57 | ## 独家提供——特色功能!
58 |
59 | - [WiFi 仿真](guides/esp32-wifi) - 仿真项目可以连接到互联网。您可以使用MQTT、HTTP、NTP和许多其他网络协议。
60 | - [虚拟逻辑分析仪](guides/logic-analyzer) - 在仿真中可以捕获数字信号(例如UART、I2C、SPI)并在你的计算机上进行分析。
61 | - [强力的GDB仿真](gdb-debugging) - 为高级用户提供了强大的Arduino和Raspberry Pi Pico调试器。
62 | - [SD卡仿真](parts/wokwi-microsd-card) - 可以使用代码来存储和检索文件和目录。[Club](https://wokwi.com/pricing?ref=docs_sdcard) 会员也可以上传二进制文件(例如图像)。
63 |
64 | ## 要付多少钱才能用wokwi?
65 |
66 | Wokwi个人使用是免费的。对于商业用户和专业人士,请查看我们的[定价页面](https://wokwi.com/pricing?ref=docs_welcome)了解付费计划。
67 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-theme-classic/footer.json:
--------------------------------------------------------------------------------
1 | {
2 | "link.title.Docs": {
3 | "message": "文档",
4 | "description": "The title of the footer links column with title=Docs in the footer"
5 | },
6 | "link.title.Community": {
7 | "message": "社区",
8 | "description": "The title of the footer links column with title=Community in the footer"
9 | },
10 | "link.title.More": {
11 | "message": "更多",
12 | "description": "The title of the footer links column with title=More in the footer"
13 | },
14 | "link.item.label.Welcome": {
15 | "message": "欢迎",
16 | "description": "The label of footer link with label=Welcome linking to /"
17 | },
18 | "link.item.label.diagram.json": {
19 | "message": "diagram.json",
20 | "description": "The label of footer link with label=diagram.json linking to /diagram-format"
21 | },
22 | "link.item.label.Discord": {
23 | "message": "Discord",
24 | "description": "The label of footer link with label=Discord linking to https://wokwi.com/discord"
25 | },
26 | "link.item.label.Twitter": {
27 | "message": "Twitter",
28 | "description": "The label of footer link with label=Twitter linking to https://twitter.com/WokwiMakes"
29 | },
30 | "link.item.label.Blog": {
31 | "message": "Blog",
32 | "description": "The label of footer link with label=Blog linking to https://blog.wokwi.com"
33 | },
34 | "link.item.label.GitHub": {
35 | "message": "GitHub",
36 | "description": "The label of footer link with label=GitHub linking to https://github.com/wokwi/wokwi-docs"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/i18n/zh-CN/docusaurus-theme-classic/navbar.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": {
3 | "message": "Wokwi",
4 | "description": "The title in the navbar"
5 | },
6 | "item.label.Docs": {
7 | "message": "文档",
8 | "description": "Navbar item with label Docs"
9 | },
10 | "item.label.Blog": {
11 | "message": "Blog",
12 | "description": "Navbar item with label Blog"
13 | },
14 | "item.label.Simulator": {
15 | "message": "模拟器",
16 | "description": "Navbar item with label Simulator"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "wokwi-docs",
3 | "version": "0.0.0",
4 | "private": true,
5 | "scripts": {
6 | "docusaurus": "docusaurus",
7 | "start": "docusaurus start",
8 | "build": "docusaurus build && node scripts/thumb-urls.js",
9 | "swizzle": "docusaurus swizzle",
10 | "deploy": "docusaurus deploy",
11 | "serve": "docusaurus serve",
12 | "clear": "docusaurus clear"
13 | },
14 | "dependencies": {
15 | "@algolia/client-search": "^4.22.0",
16 | "@docusaurus/core": "^3.6.1",
17 | "@docusaurus/preset-classic": "^3.6.1",
18 | "@mdx-js/react": "^3.0.0",
19 | "clsx": "^1.1.1",
20 | "react": "^18.2.0",
21 | "react-dom": "^18.2.0"
22 | },
23 | "devDependencies": {
24 | "@types/react": "^18.2.47",
25 | "husky": "^5.1.1",
26 | "prettier": "^2.2.1",
27 | "pretty-quick": "^3.1.0"
28 | },
29 | "engines": {
30 | "node": ">=18.0"
31 | },
32 | "husky": {
33 | "hooks": {
34 | "pre-commit": "pretty-quick --staged"
35 | }
36 | },
37 | "browserslist": {
38 | "production": [
39 | ">0.5%",
40 | "not dead",
41 | "not op_mini all"
42 | ],
43 | "development": [
44 | "last 1 chrome version",
45 | "last 1 firefox version",
46 | "last 1 safari version"
47 | ]
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/prettier.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | printWidth: 100,
3 | singleQuote: true,
4 | tabWidth: 2,
5 | trailingComma: 'all',
6 | endOfLine: 'auto',
7 | };
8 |
--------------------------------------------------------------------------------
/scripts/thumb-urls.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs');
2 | const glob = require('glob');
3 | const path = require('path');
4 |
5 | const buildDir = path.join(__dirname, '../build');
6 | const files = glob.sync(path.join(buildDir, '**/index.html'));
7 |
8 | for (const file of files) {
9 | const urlPathname = path
10 | .relative(buildDir, file)
11 | .split(path.sep)
12 | .join('/')
13 | .replace(/\/index.html$/, '');
14 | if (urlPathname.endsWith('/search')) {
15 | continue;
16 | }
17 | const html = fs.readFileSync(file, { encoding: 'utf-8' });
18 | fs.writeFileSync(
19 | file,
20 | html.replace(
21 | /https:\/\/docs.wokwi.com(\/[^/]+)?\/img\/wokwi-book\.jpg/g,
22 | `https://thumbs.wokwi.com/docs/${urlPathname}/thumbnail.png`,
23 | ),
24 | );
25 | }
26 |
--------------------------------------------------------------------------------
/src/components/LEDBullet.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { useEffect, useState } from 'react';
3 | import { LED } from './LED';
4 |
5 | declare global {
6 | namespace JSX {
7 | interface IntrinsicElements {
8 | 'wokwi-led': any;
9 | }
10 | }
11 | }
12 |
13 | interface ILEDBulletProps {
14 | title: string;
15 | color: string;
16 | children: React.ReactNode;
17 | }
18 |
19 | export function LEDBullet({ title, color, children }: ILEDBulletProps) {
20 | const [brightness, setBrightness] = useState(0);
21 | const [targetBrightness, setTargetBrightness] = useState(0);
22 |
23 | useEffect(() => {
24 | if (brightness == targetBrightness) {
25 | return;
26 | }
27 |
28 | const timer = setTimeout(() => {
29 | if (targetBrightness > brightness) {
30 | setBrightness(Math.min(brightness + 0.05, targetBrightness));
31 | } else {
32 | setBrightness(Math.max(brightness - 0.05, targetBrightness));
33 | }
34 | }, 10);
35 |
36 | return () => clearTimeout(timer);
37 | }, [brightness, targetBrightness]);
38 |
39 | const mouseOver = () => {
40 | setTargetBrightness(1);
41 | };
42 | const mouseOut = () => {
43 | setTargetBrightness(0);
44 | };
45 |
46 | return (
47 |
48 |
53 |
54 | {title}.
{children}
55 |
56 |
57 | );
58 | }
59 |
--------------------------------------------------------------------------------
/src/css/custom.css:
--------------------------------------------------------------------------------
1 | /* stylelint-disable docusaurus/copyright-header */
2 | /**
3 | * Any CSS included here will be global. The classic template
4 | * bundles Infima by default. Infima is a CSS framework designed to
5 | * work well for content-centric websites.
6 | */
7 |
8 | /* You can override the default Infima variables here. */
9 | :root {
10 | --ifm-color-primary: #25c2a0;
11 | --ifm-color-primary-dark: rgb(33, 175, 144);
12 | --ifm-color-primary-darker: rgb(31, 165, 136);
13 | --ifm-color-primary-darkest: rgb(26, 136, 112);
14 | --ifm-color-primary-light: rgb(70, 203, 174);
15 | --ifm-color-primary-lighter: rgb(102, 212, 189);
16 | --ifm-color-primary-lightest: rgb(146, 224, 208);
17 | --ifm-code-font-size: 95%;
18 | }
19 |
20 | figure {
21 | margin-top: 56px;
22 | }
23 |
24 | figure > img {
25 | display: block;
26 | }
27 |
28 | figcaption {
29 | text-align: center;
30 | margin-top: 10px;
31 | color: rgb(117, 117, 117);
32 | line-height: 20px;
33 | font-size: 14px;
34 | }
35 |
36 | .docusaurus-highlight-code-line {
37 | background-color: rgb(72, 77, 91);
38 | display: block;
39 | margin: 0 calc(-1 * var(--ifm-pre-padding));
40 | padding: 0 var(--ifm-pre-padding);
41 | }
42 |
43 | .simulator-link {
44 | font-weight: bold;
45 | color: orange;
46 | }
47 |
48 | html .svg-font-table {
49 | fill: currentColor;
50 | max-width: 100%;
51 | height: auto;
52 | }
53 |
54 | html[data-theme='dark'] .svg-font-table path {
55 | fill: seagreen;
56 | }
57 |
58 | wokwi-analog-joystick[disabled] {
59 | display: inline-block;
60 | position: relative;
61 | }
62 |
63 | wokwi-analog-joystick[disabled]:before {
64 | position: absolute;
65 | content: ' ';
66 | top: 0;
67 | right: 0;
68 | left: 0;
69 | bottom: 0;
70 | }
71 |
72 | .led-bullet {
73 | display: flex;
74 | }
75 |
76 | .led-bullet span p {
77 | display: inline;
78 | margin: 0;
79 | }
80 |
--------------------------------------------------------------------------------
/src/theme/SiteMetadata/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import SiteMetadata from '@theme-original/SiteMetadata';
3 | import Head from '@docusaurus/Head';
4 |
5 | export default function SiteMetadataWrapper(props) {
6 | return (
7 | <>
8 |
9 |
10 |
11 |
12 |
13 | >
14 | );
15 | }
16 |
--------------------------------------------------------------------------------
/static/_redirects:
--------------------------------------------------------------------------------
1 | /getting-started/wokwi-club https://wokwi.com/pricing?ref=docs_club_redirect 301
2 |
--------------------------------------------------------------------------------
/static/img/favicon-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wokwi/wokwi-docs/de857df2b8ecd29420541f37b90a0746e48ff014/static/img/favicon-white.png
--------------------------------------------------------------------------------
/static/img/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wokwi/wokwi-docs/de857df2b8ecd29420541f37b90a0746e48ff014/static/img/favicon.ico
--------------------------------------------------------------------------------
/static/img/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/static/img/social-thumbnail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wokwi/wokwi-docs/de857df2b8ecd29420541f37b90a0746e48ff014/static/img/social-thumbnail.png
--------------------------------------------------------------------------------
/static/img/wokwi-book.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wokwi/wokwi-docs/de857df2b8ecd29420541f37b90a0746e48ff014/static/img/wokwi-book.jpg
--------------------------------------------------------------------------------
/translating.md:
--------------------------------------------------------------------------------
1 | # Steps for Translating Wokwi Docs
2 |
3 | Contributed by [Anderson Costa](https://github.com/arcostasi).
4 |
5 | ## Install git on your console or any other GUI tool that supports the steps below.
6 |
7 | 1. Fork the Wokwi docs repository on GitHub: (https://github.com/wokwi/wokwi-docs).
8 |
9 | 2. Clone your repository to your local machine:
10 | (e.g. `git clone https://github.com//wokwi-docs`).
11 |
12 | 3. Add an upstream remote:
13 | (e.g. `git remote add upstream https://github.com/wokwi/wokwi-docs/`).
14 |
15 | 4. Fetch all branches from the upstream remote:
16 | (e.g. `git fetch upstream`).
17 |
18 | 5. Checkout the main branch (`git checkout main`).
19 |
20 | 6. Rebase the main branch to incorporate updates from the upstream remote
21 | (e.g. `git rebase upstream/main`).
22 |
23 | If necessary, force a push to your own Github repository
24 | (e.g. `git push -f origin main`).
25 |
26 | 7. Create a new branch for your updates (e.g. git branch `pt-br#01`).
27 |
28 | 8. Checkout the new branch (e.g. git checkout `pt-br#01`).
29 |
30 | 9. Make changes to the translation files inside the folder
31 | (./wokwi-docs/i18n//docusaurus-plugin-content-docs/current/).
32 | (e.g. ./wokwi-docs/i18n/pt-BR/docusaurus-plugin-content-docs/current/)
33 |
34 | 10. Add the changed files
35 | (e.g. `git add file1 file2`, or `git add .` for all changes).
36 |
37 | 11. Commit the changes with a descriptive message
38 | (e.g. `git commit -m "feat(i18n): update pt-BR texts"`).
39 |
40 | 12. Push the changes to your remote repository
41 | (e.g. `git push --set-upstream origin pt-br#01`).
42 |
43 | 13. Create a pull request from your repository to the official Wokwi docs repository
44 | (https://github.com/wokwi/wokwi-docs/).
45 |
46 | 14. Wait for the checks to pass and for approval from the administrator "urish".
47 | Note: If an error message appears, wait for a response from the administrator.
48 |
--------------------------------------------------------------------------------
/workers/README.md:
--------------------------------------------------------------------------------
1 | # Cloudflare Workers Scripts
2 |
3 | - [auto-locale](auto-locale.js) - Automatically redirect users to their native language documentation, if available, based on the Accept-Language header sent from their browser.
4 |
--------------------------------------------------------------------------------
/workers/auto-locale.js:
--------------------------------------------------------------------------------
1 | /*
2 | Automatically redirect users to their native language documentation, if available, based on the Accept-Language header
3 | sent from their browser. Runs on Cloudflare Workers.
4 |
5 | Copyright (C) 2021, Uri Shaked.
6 | Released under the terms of the MIT license.
7 | */
8 | /* SPDX-License-Identifier: MIT */
9 |
10 | const docsUrl = 'https://docs.wokwi.com';
11 |
12 | /**
13 | * @param {Request} request
14 | */
15 | function getLanguages(request) {
16 | const acceptLanguage = request.headers.get('Accept-Language');
17 | const result = [];
18 | for (const item of (acceptLanguage ?? '').split(',')) {
19 | const [lang, rest] = item.split(';');
20 | const quality = (rest ?? '').startsWith('q=') ? parseFloat(rest.substr(2)) : 1;
21 | result.push({ lang, quality });
22 | }
23 | return result;
24 | }
25 |
26 | /**
27 | * @param {ReturnType} langs
28 | * @param {string[]} supportedLangs
29 | * @param {string} defaultLang
30 | */
31 | function pickLanguage(langs, supportedLangs, defaultLang) {
32 | langs = [...langs].sort((a, b) => b.quality - a.quality);
33 | for (const { lang, quality } of langs) {
34 | if (supportedLangs.includes(lang.toLowerCase())) {
35 | return { lang, quality };
36 | }
37 | }
38 | return { lang: defaultLang, quality: 0 };
39 | }
40 |
41 | addEventListener('fetch', (event) => {
42 | event.respondWith(handleRequest(event.request).catch((err) => new Response({ status: 500 })));
43 | });
44 |
45 | /**
46 | * @param {Request} request
47 | * @returns {Promise}
48 | */
49 | async function handleRequest(request) {
50 | const { pathname } = new URL(request.url);
51 | const referer = request.headers.get('Referer');
52 | const secFetchSite = request.headers.get('Sec-Fetch-Site');
53 | const { lang } = pickLanguage(getLanguages(request), ['pt-br', 'pt', 'en'], 'en');
54 |
55 | if (secFetchSite !== 'same-origin' && (!referer || !referer.startsWith(docsUrl))) {
56 | if (
57 | lang.startsWith('pt') &&
58 | !pathname.startsWith('/pt-BR/') &&
59 | !pathname.startsWith('/assets/')
60 | ) {
61 | return Response.redirect(`${docsUrl}/pt-BR${pathname}`);
62 | }
63 | }
64 |
65 | return fetch(request);
66 | }
67 |
--------------------------------------------------------------------------------