-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathled_control_program.json
More file actions
62 lines (62 loc) · 1.71 KB
/
Copy pathled_control_program.json
File metadata and controls
62 lines (62 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{
"metadata": {
"version": "1.0",
"signature": "ed25519_signature_placeholder",
"timestamp": "2023-12-01T10:00:00Z",
"checksum": "sha256_checksum_placeholder",
"author": "ESP32_Secure_System",
"description": "Simple LED blinking program"
},
"config": {
"runtime_limit_ms": 5000,
"memory_limit_kb": 25,
"permissions": ["gpio", "time"],
"hot_reload_enabled": true,
"max_loop_iterations": 10000
},
"imports": [
"import machine",
"import time"
],
"functions": [
"def initialize_led(pin_number):",
" led = machine.Pin(pin_number, machine.Pin.OUT)",
" return led",
"",
"def blink_led(led, duration):",
" led.value(1)",
" time.sleep(duration)",
" led.value(0)",
" time.sleep(duration)",
"",
"def fade_led(led, steps=10):",
" # Simulated PWM effect with digital pin",
" for i in range(steps):",
" led.value(1)",
" time.sleep(0.05)",
" led.value(0)",
" time.sleep(0.05)"
],
"setup": [
"# Initialize LED on GPIO 2 (built-in LED on many ESP32 boards)",
"led_pin = 2",
"led = initialize_led(led_pin)",
"print('LED initialized on pin:', led_pin)"
],
"loop_logic": [
"# Blink the LED with 500ms interval",
"blink_led(led, 0.5)",
"",
"# Every 10 cycles, do a fade effect",
"if iteration_count % 10 == 0:",
" print('Fading LED...')",
" fade_led(led)",
"",
"# Increment iteration counter",
"iteration_count = iteration_count + 1 if 'iteration_count' in globals() else 1",
"",
"# Optional: print status every 5 cycles",
"if iteration_count % 5 == 0:",
" print('Iteration:', iteration_count)"
]
}