Skip to content

Commit 5225805

Browse files
committed
feat(wokwi-slide-potentiometer/pot-uno): add test
1 parent 157adbe commit 5225805

File tree

6 files changed

+92
-4
lines changed

6 files changed

+92
-4
lines changed

.github/workflows/wokwi-test.yml

+13-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ on:
99
jobs:
1010
test:
1111
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
test:
15+
- name: dht22-uno
16+
path: wokwi-dht22/dht22-uno
17+
scenario: dht22.test.yaml
18+
- name: slide-potentiometer-uno
19+
path: wokwi-slide-potentiometer/pot-uno
20+
scenario: slide-potentiometer.test.yaml
1221
steps:
1322
- uses: actions/checkout@v4
1423

@@ -18,7 +27,7 @@ jobs:
1827
pip install platformio
1928
2029
- name: Build with PlatformIO
21-
working-directory: wokwi-dht22/dht22-uno
30+
working-directory: ${{ matrix.test.path }}
2231
run: pio run
2332

2433
- name: Run Wokwi CI Server
@@ -28,7 +37,7 @@ jobs:
2837
uses: wokwi/wokwi-ci-action@v1
2938
with:
3039
token: ${{ secrets.WOKWI_CLI_TOKEN }}
31-
path: wokwi-dht22/dht22-uno
40+
path: ${{ matrix.test.path }}
3241
timeout: 10000
33-
scenario: dht22.test.yaml
34-
serial_log_file: serial.log
42+
scenario: ${{ matrix.test.scenario }}
43+
serial_log_file: serial-${{ matrix.test.name }}.log
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"version": 1,
3+
"author": "Wokwi",
4+
"editor": "wokwi",
5+
"parts": [
6+
{
7+
"type": "wokwi-arduino-uno",
8+
"id": "uno",
9+
"top": 0,
10+
"left": 0,
11+
"attrs": {}
12+
},
13+
{
14+
"type": "wokwi-slide-potentiometer",
15+
"id": "pot1",
16+
"top": 100,
17+
"left": 100,
18+
"attrs": {
19+
"value": "512",
20+
"travelLength": "30"
21+
}
22+
}
23+
],
24+
"connections": [
25+
["uno:A0", "pot1:SIG", "green", ["v0", "h0"]],
26+
["uno:GND.1", "pot1:GND", "black", ["v0", "h0"]],
27+
["uno:5V", "pot1:VCC", "red", ["v0", "h0"]]
28+
]
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[env:uno]
2+
platform = atmelavr
3+
board = uno
4+
framework = arduino
5+
build_flags = -D ARDUINO_ARCH_AVR
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: 'Slide Potentiometer Test'
2+
version: 1
3+
author: 'Test Author'
4+
5+
steps:
6+
- delay: 1000ms
7+
- wait-serial: 'Potentiometer value: 512'
8+
- set-control:
9+
part-id: pot1
10+
control: position
11+
value: 1
12+
- delay: 100ms
13+
- wait-serial: 'Potentiometer value: 1023'
14+
- set-control:
15+
part-id: pot1
16+
control: position
17+
value: 0
18+
- delay: 100ms
19+
- wait-serial: 'Potentiometer value: 0'
20+
- set-control:
21+
part-id: pot1
22+
control: position
23+
value: 0.5
24+
- delay: 100ms
25+
- wait-serial: 'Potentiometer value: 512'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <Arduino.h>
2+
3+
const int POT_PIN = A0; // Slide potentiometer connected to A0
4+
5+
void setup() {
6+
Serial.begin(115200);
7+
pinMode(POT_PIN, INPUT);
8+
}
9+
10+
void loop() {
11+
int potValue = analogRead(POT_PIN);
12+
Serial.print("Potentiometer value: ");
13+
Serial.println(potValue);
14+
delay(100); // Small delay to prevent flooding the serial output
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[wokwi]
2+
version = 1
3+
name = "Slide Potentiometer Test"
4+
firmware = '.pio/build/uno/firmware.hex'
5+
elf = '.pio/build/uno/firmware.elf'

0 commit comments

Comments
 (0)