diff --git a/arduino/level1/7_segment_display_basic/description.md b/arduino/level1/7_segment_display_basic/description.md new file mode 100644 index 0000000000000000000000000000000000000000..c69f7cde54db949f061cfbb408fdb8f53bce5572 --- /dev/null +++ b/arduino/level1/7_segment_display_basic/description.md @@ -0,0 +1,30 @@ +# One Digit 7-segment Display + +## Project Description +This is an Arduino project that show number 5 with digit 7-segment display. + +## Hardware Components +- Arduino Uno +- 330Ω resistor * 8 +- 7-segment display + +## Circuit Description +Circuit is designed to use a 7-segment display. The 7-segment display is a common anode type, so the common pin is connected to 5V. The A to G and DP pins are connected to Arduino digital pins 2 to 9 through 330-ohm resistors. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set 2~9 pin as an output. +2. Taking into account that the display is common anode, set the corresponding pins to HIGH or LOW so that the number 5 appears on the 7-segment display. + +## Success Criteria +The test is successful when: +1. The number 5 appears on the 7-segment display. + +## Notes for Implementation +- The 7-segment display is a common anode type. + +## Variants +This project may have different variants with the segment pins connected to the different pins. + +## Attributes +- To use 330Ω resistor, set the property name "value" to "330 ohm". \ No newline at end of file diff --git a/arduino/level1/7_segment_display_basic/description_no_pin.md b/arduino/level1/7_segment_display_basic/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..1dff738f4f0b5bcfe12e18c73a105e41c3022885 --- /dev/null +++ b/arduino/level1/7_segment_display_basic/description_no_pin.md @@ -0,0 +1,30 @@ +# One Digit 7-segment Display + +## Project Description +This is an Arduino project that show number 5 with digit 7-segment display. + +## Hardware Components +- Arduino Uno +- 330Ω resistor * 8 +- 7-segment display + +## Circuit Description +Circuit is designed to use a 7-segment display. The 7-segment display is a common anode type. The A to G and DP pins are connected to Arduino through 330-ohm resistors. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set segment pins as an output. +2. Taking into account that the display is common anode, set the corresponding pins to HIGH or LOW so that the number 5 appears on the 7-segment display. + +## Success Criteria +The test is successful when: +1. The number 5 appears on the 7-segment display. + +## Notes for Implementation +- The 7-segment display is a common anode type. + +## Variants +This project may have different variants with the segment pins connected to the different pins. + +## Attributes +- To use 330Ω resistor, set the property name "value" to "330 ohm". \ No newline at end of file diff --git a/arduino/level1/7_segment_display_basic/diagram.json b/arduino/level1/7_segment_display_basic/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..2452874c0d411705e210d6ccac84e25505c271bd --- /dev/null +++ b/arduino/level1/7_segment_display_basic/diagram.json @@ -0,0 +1,242 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Use one digit 7-segment display", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-7segment", + "id": "7-segment display1", + "top": 24.18, + "left": 408.28, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 128.75, + "left": 451.2, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -15.25, + "left": 451.2, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 109.55, + "left": 441.6, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 128.75, + "left": 355.2, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": 109.55, + "left": 364.8, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -15.25, + "left": 345.6, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": 3.95, + "left": 364.8, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": 3.95, + "left": 441.6, + "attrs": { + "value": "330" + } + } + ], + "connections": [ + [ + "7-segment display1:F", + "resistor7:2", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:A", + "resistor8:1", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:G", + "resistor6:2", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:B", + "resistor2:1", + "green", + [ + "v0" + ] + ], + [ + "resistor5:2", + "7-segment display1:D", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:C", + "resistor3:1", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:E", + "resistor4:2", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:DP", + "resistor1:1", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:COM.1", + "arduino uno1:5V", + "green", + [ + "h0", + "v124.8" + ] + ], + [ + "resistor8:2", + "arduino uno1:2", + "green", + [ + "v-19.2", + "h-260.4" + ] + ], + [ + "resistor2:2", + "arduino uno1:3", + "green", + [ + "v-9.6", + "h-279.6" + ] + ], + [ + "resistor3:2", + "arduino uno1:4", + "green", + [ + "v0", + "h27.6", + "v-144", + "h-307.2" + ] + ], + [ + "resistor5:1", + "arduino uno1:5", + "green", + [ + "v-153.6", + "h-153.6" + ] + ], + [ + "resistor4:1", + "arduino uno1:6", + "green", + [ + "v-182.4", + "h-153.6" + ] + ], + [ + "resistor7:1", + "arduino uno1:7", + "green", + [ + "v-67.2", + "h-172.8" + ] + ], + [ + "resistor6:1", + "arduino uno1:8", + "green", + [ + "v-57.6", + "h-172.8" + ] + ], + [ + "resistor1:2", + "arduino uno1:9", + "green", + [ + "v-211.2", + "h-346.8" + ] + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/7_segment_display_basic/diagram_breadboard.json b/arduino/level1/7_segment_display_basic/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..fbc2cb0839292f885a433da678f0a918a88070c5 --- /dev/null +++ b/arduino/level1/7_segment_display_basic/diagram_breadboard.json @@ -0,0 +1,399 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Use one digit 7-segment display", + "config": { + "button_pin": 4, + "gnd_pin": "GND.3" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -127.8, + "left": 338.8, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 115.8, + "left": 527.4, + "attrs": {} + }, + { + "type": "wokwi-7segment", + "id": "7-segment display1", + "top": -62.22, + "left": 629.08, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 23.15, + "left": 672, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -72.85, + "left": 662.4, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 13.55, + "left": 662.4, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 23.15, + "left": 576, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": 13.55, + "left": 585.6, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -82.45, + "left": 576, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": -72.85, + "left": 585.6, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": -82.45, + "left": 672, + "attrs": { + "value": "330" + } + } + ], + "connections": [ + [ + "7-segment display1:COM.1", + "breadboard1:31b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:COM.2", + "breadboard1:31t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:A", + "breadboard1:32t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:B", + "breadboard1:33t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:C", + "breadboard1:32b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:D", + "breadboard1:30b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:E", + "breadboard1:29b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:F", + "breadboard1:30t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:G", + "breadboard1:29t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:DP", + "breadboard1:33b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:33b.j", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:39b.j", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:32t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:38t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:32b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:38b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor4:1", + "breadboard1:23b.j", + "", + [ + "$bb" + ] + ], + [ + "resistor4:2", + "breadboard1:29b.j", + "", + [ + "$bb" + ] + ], + [ + "resistor5:1", + "breadboard1:24b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor5:2", + "breadboard1:30b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor6:1", + "breadboard1:23t.a", + "", + [ + "$bb" + ] + ], + [ + "resistor6:2", + "breadboard1:29t.a", + "", + [ + "$bb" + ] + ], + [ + "resistor7:1", + "breadboard1:24t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor7:2", + "breadboard1:30t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor8:1", + "breadboard1:33t.a", + "", + [ + "$bb" + ] + ], + [ + "resistor8:2", + "breadboard1:39t.a", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:38t.d", + "arduino uno1:2", + "green", + [ + "v134.4", + "h48" + ] + ], + [ + "breadboard1:39t.d", + "arduino uno1:3", + "green", + [ + "v144", + "h19.2" + ] + ], + [ + "breadboard1:38b.g", + "arduino uno1:4", + "green", + [ + "v105.6", + "h28.8" + ] + ], + [ + "breadboard1:24b.g", + "arduino uno1:5", + "green", + [ + "v0", + "h-57.6", + "v76.8", + "h201.6" + ] + ], + [ + "breadboard1:23b.h", + "arduino uno1:6", + "green", + [ + "v0", + "h-38.4", + "v76.8", + "h182.4" + ] + ], + [ + "breadboard1:24t.d", + "arduino uno1:7", + "green", + [ + "v144", + "h124.8" + ] + ], + [ + "breadboard1:23t.d", + "arduino uno1:8", + "green", + [ + "v153.6", + "h124.8" + ] + ], + [ + "breadboard1:39b.h", + "arduino uno1:9", + "green", + [ + "v38.4", + "h-38.4" + ] + ], + [ + "breadboard1:31b.j", + "arduino uno1:5V", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level1/7_segment_display_basic/diagram_breadboard_shdf.json b/arduino/level1/7_segment_display_basic/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..ea1ce66bc88f27b19e335f7033e2808c1caba741 --- /dev/null +++ b/arduino/level1/7_segment_display_basic/diagram_breadboard_shdf.json @@ -0,0 +1,214 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "sevseg1", + "type": "7-segment display" + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r2", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r3", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r4", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r5", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r6", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r7", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r8", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + } + ], + "connections": [ + [ + "sevseg1.com.1", + "bb1.pin31b.h" + ], + [ + "sevseg1.com.2", + "bb1.pin31t.c" + ], + [ + "sevseg1.a", + "bb1.pin32t.c" + ], + [ + "sevseg1.b", + "bb1.pin33t.c" + ], + [ + "sevseg1.c", + "bb1.pin32b.h" + ], + [ + "sevseg1.d", + "bb1.pin30b.h" + ], + [ + "sevseg1.e", + "bb1.pin29b.h" + ], + [ + "sevseg1.f", + "bb1.pin30t.c" + ], + [ + "sevseg1.g", + "bb1.pin29t.c" + ], + [ + "sevseg1.dp", + "bb1.pin33b.h" + ], + [ + "r1.1", + "bb1.pin33b.j" + ], + [ + "r1.2", + "bb1.pin39b.j" + ], + [ + "r2.1", + "bb1.pin32t.b" + ], + [ + "r2.2", + "bb1.pin38t.b" + ], + [ + "r3.1", + "bb1.pin32b.i" + ], + [ + "r3.2", + "bb1.pin38b.i" + ], + [ + "r4.1", + "bb1.pin23b.j" + ], + [ + "r4.2", + "bb1.pin29b.j" + ], + [ + "r5.1", + "bb1.pin24b.i" + ], + [ + "r5.2", + "bb1.pin30b.i" + ], + [ + "r6.1", + "bb1.pin23t.a" + ], + [ + "r6.2", + "bb1.pin29t.a" + ], + [ + "r7.1", + "bb1.pin24t.b" + ], + [ + "r7.2", + "bb1.pin30t.b" + ], + [ + "r8.1", + "bb1.pin33t.a" + ], + [ + "r8.2", + "bb1.pin39t.a" + ], + [ + "bb1.pin38t.d", + "uno.2" + ], + [ + "bb1.pin39t.d", + "uno.3" + ], + [ + "bb1.pin38b.g", + "uno.4" + ], + [ + "bb1.pin24b.g", + "uno.5" + ], + [ + "bb1.pin23b.h", + "uno.6" + ], + [ + "bb1.pin24t.d", + "uno.7" + ], + [ + "bb1.pin23t.d", + "uno.8" + ], + [ + "bb1.pin39b.h", + "uno.9" + ], + [ + "bb1.pin31b.j", + "uno.5v" + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/7_segment_display_basic/diagram_shdf.json b/arduino/level1/7_segment_display_basic/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..4ee472d9c581b65e0b50aaa3ba1508687eebdd94 --- /dev/null +++ b/arduino/level1/7_segment_display_basic/diagram_shdf.json @@ -0,0 +1,138 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "sevseg1", + "type": "7-segment display" + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r2", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r3", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r4", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r5", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r6", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r7", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r8", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + } + ], + "connections": [ + [ + "sevseg1.f", + "r7.2" + ], + [ + "sevseg1.a", + "r8.1" + ], + [ + "sevseg1.g", + "r6.2" + ], + [ + "sevseg1.b", + "r2.1" + ], + [ + "r5.2", + "sevseg1.d" + ], + [ + "sevseg1.c", + "r3.1" + ], + [ + "sevseg1.e", + "r4.2" + ], + [ + "sevseg1.dp", + "r1.1" + ], + [ + "sevseg1.com.1", + "uno.5v" + ], + [ + "r8.2", + "uno.2" + ], + [ + "r2.2", + "uno.3" + ], + [ + "r3.2", + "uno.4" + ], + [ + "r5.1", + "uno.5" + ], + [ + "r4.1", + "uno.6" + ], + [ + "r7.1", + "uno.7" + ], + [ + "r6.1", + "uno.8" + ], + [ + "r1.2", + "uno.9" + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/7_segment_display_basic/platformio.ini b/arduino/level1/7_segment_display_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level1/7_segment_display_basic/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level1/7_segment_display_basic/scenario.yaml b/arduino/level1/7_segment_display_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..651ad81365d3d1b43a51d6fcf2f1ef95fe6b85c0 --- /dev/null +++ b/arduino/level1/7_segment_display_basic/scenario.yaml @@ -0,0 +1,37 @@ +author: Blind Author +description: Determine how long a switch is pressed +name: Serial Monitor +steps: +- delay: 10ms +- wait-multi-pin: + timeout: 5000 + interval: 100 + pins: + - part-id: '7-segment display1' + pin: 'COM' + value: 1 + - part-id: '7-segment display1' + pin: 'A' + value: 0 + - part-id: '7-segment display1' + pin: 'B' + value: 1 + - part-id: '7-segment display1' + pin: 'C' + value: 0 + - part-id: '7-segment display1' + pin: 'D' + value: 0 + - part-id: '7-segment display1' + pin: 'E' + value: 1 + - part-id: '7-segment display1' + pin: 'F' + value: 0 + - part-id: '7-segment display1' + pin: 'G' + value: 0 + - part-id: '7-segment display1' + pin: 'DP' + value: 1 +version: 1.0 diff --git a/arduino/level1/7_segment_display_basic/src/main.ino b/arduino/level1/7_segment_display_basic/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..438132fb68f034169ad4b8873ce1621ae79a106a --- /dev/null +++ b/arduino/level1/7_segment_display_basic/src/main.ino @@ -0,0 +1,36 @@ +/** + Use one digit 7-segment display to show number 5 + 7 APR 2025 by Blind Author +*/ + +const int segA = 2; +const int segB = 3; +const int segC = 4; +const int segD = 5; +const int segE = 6; +const int segF = 7; +const int segG = 8; +const int segDP = 9; + +void setup() { + pinMode(segA, OUTPUT); + pinMode(segB, OUTPUT); + pinMode(segC, OUTPUT); + pinMode(segD, OUTPUT); + pinMode(segE, OUTPUT); + pinMode(segF, OUTPUT); + pinMode(segG, OUTPUT); + pinMode(segDP, OUTPUT); + + digitalWrite(segA, LOW); + digitalWrite(segB, HIGH); + digitalWrite(segC, LOW); + digitalWrite(segD, LOW); + digitalWrite(segE, HIGH); + digitalWrite(segF, LOW); + digitalWrite(segG, LOW); + digitalWrite(segDP, HIGH); +} + +void loop() { +} \ No newline at end of file diff --git a/arduino/level1/7_segment_display_basic/wokwi.toml b/arduino/level1/7_segment_display_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level1/7_segment_display_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level1/LCD_display_basic/description.md b/arduino/level1/LCD_display_basic/description.md new file mode 100644 index 0000000000000000000000000000000000000000..232c61900edfa025a05f5a95405b88516bc9d799 --- /dev/null +++ b/arduino/level1/LCD_display_basic/description.md @@ -0,0 +1,25 @@ +# LCD Display Basic + +## Project Description +This is a simple Arduino project that shows text to the ili9341 lcd display. + +## Hardware Components +- Arduino Uno +- Ili9341 LCD Display + +## Circuit Description +Ili9341 LCD Display is connected to the Arudino Uno board. D/C, CS, MOSI, MISO, SCK pin of LCD display is connected to arduino pin 9 to 13, respectively. GND pin of LCD display is connected to arduino pin gnd1. VCC pin of LCD display is connected to arduino pin 5v. + +## Expected Behavior +When the Arduino powers up, it should: +1. Declare Adafruit_ILI9341 object +2. Begin display and change it to landscape mode +3. Fill the display with black color +4. Display 'Hello World!' at position (0, 0) in white color with text size 2. + +## Success Criteria +The test is successful when: +1. Text "Hello World!" is successfully printed to the display, with correct position, color, and size. + +## Notes for Implementation +- Use the following libraries: , , and . diff --git a/arduino/level1/LCD_display_basic/description_no_pin.md b/arduino/level1/LCD_display_basic/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..5bf7ed3f2a5e27bf1bf40f8cadaf0d05bc86aa7e --- /dev/null +++ b/arduino/level1/LCD_display_basic/description_no_pin.md @@ -0,0 +1,25 @@ +# LCD Display Basic + +## Project Description +This is a simple Arduino project that shows text to the ili9341 lcd display. + +## Hardware Components +- Arduino Uno +- Ili9341 LCD Display + +## Circuit Description +Ili9341 LCD Display is connected to the Arudino Uno board. D/C, CS, MOSI, MISO, SCK pin of LCD display is connected to arduino digital pins. + +## Expected Behavior +When the Arduino powers up, it should: +1. Declare Adafruit_ILI9341 object +2. Begin display and change it to landscape mode +3. Fill the display with black color +4. Display 'Hello World!' at position (0, 0) in white color with text size 2. + +## Success Criteria +The test is successful when: +1. Text "Hello World!" is successfully printed to the display, with correct position, color, and size. + +## Notes for Implementation +- Use the following libraries: , , and . diff --git a/arduino/level1/LCD_display_basic/diagram.json b/arduino/level1/LCD_display_basic/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..9f8bdda87de15576cc6b7dae44d36f95904a7395 --- /dev/null +++ b/arduino/level1/LCD_display_basic/diagram.json @@ -0,0 +1,90 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Use lcd display", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 331.89, + "left": 1.49, + "attrs": {} + }, + { + "type": "wokwi-ili9341", + "id": "ili9341 lcd display1", + "top": 5.51, + "left": 40.77, + "attrs": {} + } + ], + "connections": [ + [ + "ili9341 lcd display1:GND", + "arduino uno1:GND.1", + "black", + [ + "v22", + "h-46" + ] + ], + [ + "ili9341 lcd display1:SCK", + "arduino uno1:13", + "green", + [ + "v16", + "h-75" + ] + ], + [ + "ili9341 lcd display1:MISO", + "arduino uno1:12", + "limegreen", + [ + "v20", + "h-78" + ] + ], + [ + "ili9341 lcd display1:MOSI", + "arduino uno1:11", + "green", + [ + "v24", + "h-75" + ] + ], + [ + "ili9341 lcd display1:CS", + "arduino uno1:10", + "orange", + [ + "v32", + "h-64" + ] + ], + [ + "ili9341 lcd display1:D/C", + "arduino uno1:9", + "purple", + [ + "v36", + "h-84" + ] + ], + [ "ili9341 lcd display1:RST", "arduino uno1:8", "green", [ "v33.69", "h54.93" ] ], + [ + "ili9341 lcd display1:VCC", + "arduino uno1:5V", + "red", + [ + "v24.09", + "h-98.67", + "v230.4", + "h172.8" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level1/LCD_display_basic/diagram_breadboard.json b/arduino/level1/LCD_display_basic/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..534c15fa2f293ee4b629f0bcc561dba1b9fbdee3 --- /dev/null +++ b/arduino/level1/LCD_display_basic/diagram_breadboard.json @@ -0,0 +1,191 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Use lcd display", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": 45, + "left": -160.4, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 331.89, + "left": 1.49, + "attrs": {} + }, + { + "type": "wokwi-ili9341", + "id": "ili9341 lcd display1", + "top": -124, + "left": 47.7, + "attrs": {} + } + ], + "connections": [ + [ + "ili9341 lcd display1:VCC", + "breadboard1:25b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:GND", + "breadboard1:26b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:CS", + "breadboard1:27b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:RST", + "breadboard1:28b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:D/C", + "breadboard1:29b.f", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:28b.j", + "arduino uno1:8", + "green", + [ + "v105.6", + "h57.6", + "v28.8" + ] + ], + [ + "ili9341 lcd display1:MOSI", + "breadboard1:30b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:SCK", + "breadboard1:31b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:LED", + "breadboard1:32b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:MISO", + "breadboard1:33b.f", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:25b.i", + "breadboard1:bp.20", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:26b.i", + "breadboard1:bn.20", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:27b.j", + "arduino uno1:10", + "orange", + [ + "v105.6", + "h38.4" + ] + ], + [ + "breadboard1:29b.j", + "arduino uno1:9", + "green", + [ + "v96", + "h28.8" + ] + ], + [ + "breadboard1:30b.j", + "arduino uno1:11", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:31b.j", + "arduino uno1:13", + "green", + [ + "v67.2", + "h-28.8" + ] + ], + [ + "breadboard1:33b.j", + "arduino uno1:12", + "green", + [ + "v48", + "h-38.4" + ] + ], + [ + "breadboard1:bp.8", + "arduino uno1:5V", + "red", + [ + "v306.3", + "h191.2" + ] + ], + [ + "breadboard1:bn.12", + "arduino uno1:GND.1", + "black", + [ + "v75.5", + "h104.8" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level1/LCD_display_basic/platformio.ini b/arduino/level1/LCD_display_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..b50154ebd53c2b66823f9f470aba4ff925f6d00a --- /dev/null +++ b/arduino/level1/LCD_display_basic/platformio.ini @@ -0,0 +1,21 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + Adafruit ILI9341 \ No newline at end of file diff --git a/arduino/level1/LCD_display_basic/scenario.yaml b/arduino/level1/LCD_display_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..33cea086ec8a9b4acc826fffc73375ec3d34748e --- /dev/null +++ b/arduino/level1/LCD_display_basic/scenario.yaml @@ -0,0 +1,9 @@ +author: Blind Author +description: Use LCD display +name: LCD Display Basic +steps: +- delay: 4000ms +- take-screenshot: + part-id: ili9341 lcd display1 + compare-with: screenshots/0.png +version: 1.0 diff --git a/arduino/level1/LCD_display_basic/screenshots/0.png b/arduino/level1/LCD_display_basic/screenshots/0.png new file mode 100644 index 0000000000000000000000000000000000000000..b6960471609c1584928ab01ea53fe502d0426b78 --- /dev/null +++ b/arduino/level1/LCD_display_basic/screenshots/0.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:934059cdd6daa6b5895229b0ad5732f18d8a39beef481630705947bd8b4c4d7c +size 1301 diff --git a/arduino/level1/LCD_display_basic/src/main.ino b/arduino/level1/LCD_display_basic/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..f15a4bcd1823820b5d7bc168e108b592e5bdcf18 --- /dev/null +++ b/arduino/level1/LCD_display_basic/src/main.ino @@ -0,0 +1,28 @@ +/** + Show text in ili9431 lcd display + 05 MAY 2025 by Blind Author +*/ + +#include +#include +#include + +#define TFT_CS 10 +#define TFT_DC 9 +#define TFT_RST 8 + +Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); + +void setup() { + tft.begin(); + tft.setRotation(1); + tft.fillScreen(ILI9341_BLACK); + + tft.setCursor(0, 0); + tft.setTextColor(ILI9341_WHITE); + tft.setTextSize(2); + tft.println("Hello World!"); +} + +void loop() { +} \ No newline at end of file diff --git a/arduino/level1/LCD_display_basic/wokwi.toml b/arduino/level1/LCD_display_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level1/LCD_display_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level1/RTC_module_basic/description.md b/arduino/level1/RTC_module_basic/description.md new file mode 100644 index 0000000000000000000000000000000000000000..32415f4a4e33ee8ac8a39c2ef02faf20a5625e01 --- /dev/null +++ b/arduino/level1/RTC_module_basic/description.md @@ -0,0 +1,34 @@ +# RTC module + +## Project Description +This is a simple Arduino project that uses RTC module to get current time. + +## Hardware Components +- Arduino Uno +- RTC module + +## Circuit Description +The RTC module is connected to the Arduino. The VCC pin is connected to 5V, the GND pin to gnd2, the SDA pin to A4, and the SCL pin to A5. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Check if the RTC module can begin +3. Read current time with RTC module +4. Print to the serial monitor in the following format: "Current time: YYYY/M/D (Day of the week) H:M:S" + +## Success Criteria +The test is successful when: +1. Correct day and time is printed in the serial monitor. + +## Notes for Implementation +- No actions are required in the loop function. +- Day of the week is one of the "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". +- Use RTClib to generate RTC_DS1307 object and read the value. +- RTC module has I2C interface. + +## Variants +There may be variants with GND pin. + +## Test Inputs +Test init value is: "2024-11-24T04:48:00" \ No newline at end of file diff --git a/arduino/level1/RTC_module_basic/description_no_pin.md b/arduino/level1/RTC_module_basic/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..760c48f562452054c92f8b4784886947f0a0c607 --- /dev/null +++ b/arduino/level1/RTC_module_basic/description_no_pin.md @@ -0,0 +1,34 @@ +# RTC module + +## Project Description +This is a simple Arduino project that uses RTC module to get current time. + +## Hardware Components +- Arduino Uno +- RTC module + +## Circuit Description +The RTC module is connected to the Arduino. It follows the standard wiring conventions defined by the I2C protocol. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Check if the RTC module can begin +3. Read current time with RTC module +4. Print to the serial monitor in the following format: "Current time: YYYY/M/D (Day of the week) H:M:S" + +## Success Criteria +The test is successful when: +1. Correct day and time is printed in the serial monitor. + +## Notes for Implementation +- No actions are required in the loop function. +- Day of the week is one of the "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". +- Use RTClib to generate RTC_DS1307 object and read the value. +- RTC module has I2C interface. + +## Variants +There may be variants with GND pin. + +## Test Inputs +Test init value is: "2024-11-24T04:48:00" \ No newline at end of file diff --git a/arduino/level1/RTC_module_basic/diagram.json b/arduino/level1/RTC_module_basic/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..a52a4f4f1869c5cd800d1f74d285f579011baffc --- /dev/null +++ b/arduino/level1/RTC_module_basic/diagram.json @@ -0,0 +1,67 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Get the current time using an RTC sensor", + "config": { + "gnd_pin": "GND.2", + "vcc_pin": "5V" + }, + "parts": [ + { + "id": "arduino uno1", + "type": "wokwi-arduino-uno", + "top": 0, + "left": 20 + }, + { + "id": "ds1307 real time clock module1307", + "type": "wokwi-ds1307", + "top": 250, + "left": 220, + "attrs": { + "initTime": "2024-11-24T04:48:00" + } + } + ], + "connections": [ + [ + "arduino uno1:GND.2", + "ds1307 real time clock module1307:GND", + "black", + [ + "v20", + "*", + "v0" + ] + ], + [ + "arduino uno1:5V", + "ds1307 real time clock module1307:5V", + "red", + [ + "v0" + ] + ], + [ + "arduino uno1:A4", + "ds1307 real time clock module1307:SDA", + "green", + [ + "v16", + "h0", + "*", + "h-34" + ] + ], + [ + "arduino uno1:A5", + "ds1307 real time clock module1307:SCL", + "orange", + [ + "v20", + "*", + "h-30" + ] + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/RTC_module_basic/diagram_breadboard.json b/arduino/level1/RTC_module_basic/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..399ca8d3fdd5af18b494a6d4ec570da85a1765bb --- /dev/null +++ b/arduino/level1/RTC_module_basic/diagram_breadboard.json @@ -0,0 +1,126 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Get the current time using an RTC sensor", + "config": { + "gnd_pin": "GND.2", + "vcc_pin": "5V" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": 208.2, + "left": -6.8, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 20, + "attrs": {} + }, + { + "type": "wokwi-ds1307", + "id": "ds1307 real time clock module1307", + "top": 295.1, + "left": 183.2, + "rotate": 90, + "attrs": { + "initTime": "2024-11-24T04:48:00" + } + } + ], + "connections": [ + [ + "ds1307 real time clock module1307:GND", + "breadboard1:26t.e", + "", + [ + "$bb" + ] + ], + [ + "ds1307 real time clock module1307:5V", + "breadboard1:25t.e", + "", + [ + "$bb" + ] + ], + [ + "ds1307 real time clock module1307:SDA", + "breadboard1:24t.e", + "", + [ + "$bb" + ] + ], + [ + "ds1307 real time clock module1307:SCL", + "breadboard1:23t.e", + "", + [ + "$bb" + ] + ], + [ + "ds1307 real time clock module1307:SQW", + "breadboard1:22t.e", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:26t.c", + "breadboard1:tn.20", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:tn.19", + "arduino uno1:GND.2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:25t.c", + "breadboard1:tp.17", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:tp.16", + "arduino uno1:5V", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:24t.c", + "arduino uno1:A4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:23t.c", + "arduino uno1:A5", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level1/RTC_module_basic/diagram_breadboard_shdf.json b/arduino/level1/RTC_module_basic/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..30209e0b0adaf0ba1bff53eaea473123ea2ec46f --- /dev/null +++ b/arduino/level1/RTC_module_basic/diagram_breadboard_shdf.json @@ -0,0 +1,62 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "ds1307", + "type": "ds1307 real time clock module" + } + ], + "connections": [ + [ + "ds1307.gnd", + "bb1.pin26t.e" + ], + [ + "ds1307.5v", + "bb1.pin25t.e" + ], + [ + "ds1307.sda", + "bb1.pin24t.e" + ], + [ + "ds1307.scl", + "bb1.pin23t.e" + ], + [ + "ds1307.sqw", + "bb1.pin22t.e" + ], + [ + "bb1.pin26t.c", + "bb1.tn.20" + ], + [ + "bb1.tn.19", + "uno.gnd.2" + ], + [ + "bb1.pin25t.c", + "bb1.tp.17" + ], + [ + "bb1.tp.16", + "uno.5v" + ], + [ + "bb1.pin24t.c", + "uno.a4" + ], + [ + "bb1.pin23t.c", + "uno.a5" + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/RTC_module_basic/diagram_shdf.json b/arduino/level1/RTC_module_basic/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..01dd8384ec290e214582cdac3e42bba3c9facb4e --- /dev/null +++ b/arduino/level1/RTC_module_basic/diagram_shdf.json @@ -0,0 +1,30 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "ds1307", + "type": "ds1307 real time clock module" + } + ], + "connections": [ + [ + "uno.gnd.2", + "ds1307.gnd" + ], + [ + "uno.5v", + "ds1307.5v" + ], + [ + "uno.a4", + "ds1307.sda" + ], + [ + "uno.a5", + "ds1307.scl" + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/RTC_module_basic/platformio.ini b/arduino/level1/RTC_module_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..df4b80305bbe895d07c0f1c0e74b60a1d2862746 --- /dev/null +++ b/arduino/level1/RTC_module_basic/platformio.ini @@ -0,0 +1,21 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + RTClib \ No newline at end of file diff --git a/arduino/level1/RTC_module_basic/scenario.yaml b/arduino/level1/RTC_module_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4964e03194e68ee9661c4e14817ff690b664d1c2 --- /dev/null +++ b/arduino/level1/RTC_module_basic/scenario.yaml @@ -0,0 +1,11 @@ +author: Blind Author +description: Get the current time using an RTC sensor +name: RTC sensor +test-values: + - part-type: wokwi-ds1307 + attr-name: initTime + value: "2024-11-24T04:48:00" +steps: + - delay: 10ms + - wait-serial: 2024/11/24 (Sunday) 4:48:0 +version: 1.0 diff --git a/arduino/level1/RTC_module_basic/src/main.ino b/arduino/level1/RTC_module_basic/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..df0c4df0b2f9c122b7b2b6ea01d500465f4eebc1 --- /dev/null +++ b/arduino/level1/RTC_module_basic/src/main.ino @@ -0,0 +1,41 @@ +/** + Get the current time using an RTC sensor + 10 APR 2025 by Blind Author +*/ + +#include "RTClib.h" + +RTC_DS1307 rtc; + +char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; + +void setup () { + Serial.begin(115200); + + if (!rtc.begin()) { + Serial.println("Couldn't find RTC"); + Serial.flush(); + abort(); + } + + DateTime now = rtc.now(); + + Serial.print("Current time: "); + Serial.print(now.year(), DEC); + Serial.print('/'); + Serial.print(now.month(), DEC); + Serial.print('/'); + Serial.print(now.day(), DEC); + Serial.print(" ("); + Serial.print(daysOfTheWeek[now.dayOfTheWeek()]); + Serial.print(") "); + Serial.print(now.hour(), DEC); + Serial.print(':'); + Serial.print(now.minute(), DEC); + Serial.print(':'); + Serial.print(now.second(), DEC); + Serial.println(); +} + +void loop () { +} diff --git a/arduino/level1/RTC_module_basic/wokwi.toml b/arduino/level1/RTC_module_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level1/RTC_module_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level1/bar_led_basic/description.md b/arduino/level1/bar_led_basic/description.md new file mode 100644 index 0000000000000000000000000000000000000000..7d5c8bba531ebed5d2ebfa2c6602ea81eaea1a55 --- /dev/null +++ b/arduino/level1/bar_led_basic/description.md @@ -0,0 +1,32 @@ +# Bar LED + +## Project Description +This is a simple Arduino project that turns on an bar graph LED. + +## Hardware Components +- Arduino Uno +- Bar graph LED +- 220Ω resistor * 10 + +## Circuit Description +Anode pins 1~10 of bar graph LED are connected to pin2, pin3, pin4, pin5, pin6, pin7, pin8, pin9, pin10, pin11, respectively. The cathode pins 1 through 10 of the bar graph LED are connected to GND pin gnd1 through 220kΩ resistors. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set pin2, pin3, pin4, pin5, pin6, pin7, pin8, pin9, pin10, pin11 pin mode as OUTPUT +2. Turn on the bar graph LEDs only up to the threshold, which is 6 + +## Success Criteria +The test is successful when: +1. Pins 1 to 6 of the bar graph LED anodes receive HIGH signals, while pins 7 to 10 receive LOW signals. + +## Notes for Implementation +- The LED should turn on immediately during setup and stay on +- No actions are required in the loop function +- The pin number used should match the circuit diagram + +## Variants +This project may have different variants with the bar graph LED connected to different pins or using bar graph LED of different colors. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level1/bar_led_basic/description_no_pin.md b/arduino/level1/bar_led_basic/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..d8fefb11661486aaa7da363e98369e4c44b097b0 --- /dev/null +++ b/arduino/level1/bar_led_basic/description_no_pin.md @@ -0,0 +1,32 @@ +# Bar LED + +## Project Description +This is a simple Arduino project that turns on an bar graph LED. + +## Hardware Components +- Arduino Uno +- Bar graph LED +- 220Ω resistor * 10 + +## Circuit Description +Anode pins of bar graph LED are connected to arduino. The cathode pins of the bar graph LED are connected to ground through 220kΩ resistors. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set pins connected to bar graph LED as OUTPUT +2. Turn on the bar graph LEDs only up to the threshold, which is 6 + +## Success Criteria +The test is successful when: +1. Pins 1 to 6 of the bar graph LED anodes receive HIGH signals, while pins 7 to 10 receive LOW signals. + +## Notes for Implementation +- The LED should turn on immediately during setup and stay on +- No actions are required in the loop function +- The pin number used should match the circuit diagram + +## Variants +This project may have different variants with the bar graph LED connected to different pins or using bar graph LED of different colors. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level1/bar_led_basic/diagram.json b/arduino/level1/bar_led_basic/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..ade2337bff483a73370694eee9408c8f03281370 --- /dev/null +++ b/arduino/level1/bar_led_basic/diagram.json @@ -0,0 +1,400 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Turn on bar graph LED", + "config": { + "1_pin": 2, + "2_pin": 3, + "3_pin": 4, + "4_pin": 5, + "5_pin": 6, + "6_pin": 7, + "7_pin": 8, + "8_pin": 9, + "9_pin": 10, + "10_pin": 11, + "led_color": "lime", + "gnd_pin": "GND.1" + }, + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 67.8, + "left": 517.8, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 109.85, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": 129.05, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 119.45, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-led-bar-graph", + "id": "bar graph led1", + "top": 110.4, + "left": 849.6, + "attrs": { + "color": "lime" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 138.65, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": 148.25, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": 157.85, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": 167.45, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": 177.05, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor9", + "top": 186.65, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor10", + "top": 196.25, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "resistor1:2", + "bar graph led1:C1", + "green", + [ + "v0" + ] + ], + [ + "resistor2:2", + "bar graph led1:C2", + "green", + [ + "v0" + ] + ], + [ + "resistor3:2", + "bar graph led1:C3", + "green", + [ + "v0" + ] + ], + [ + "resistor4:2", + "bar graph led1:C4", + "green", + [ + "v0" + ] + ], + [ + "resistor5:2", + "bar graph led1:C5", + "green", + [ + "v0" + ] + ], + [ + "resistor6:2", + "bar graph led1:C6", + "green", + [ + "v0" + ] + ], + [ + "resistor7:2", + "bar graph led1:C7", + "green", + [ + "v0" + ] + ], + [ + "resistor8:2", + "bar graph led1:C8", + "green", + [ + "v0" + ] + ], + [ + "resistor9:2", + "bar graph led1:C9", + "green", + [ + "v0" + ] + ], + [ + "resistor10:2", + "bar graph led1:C10", + "green", + [ + "v0" + ] + ], + [ + "arduino uno1:GND.1", + "resistor10:1", + "black", + [ + "v-28.8", + "h365.1", + "v153.6" + ] + ], + [ + "arduino uno1:GND.1", + "resistor9:1", + "black", + [ + "v-28.8", + "h365.1", + "v144" + ] + ], + [ + "arduino uno1:GND.1", + "resistor8:1", + "black", + [ + "v-28.8", + "h365.1", + "v134.4" + ] + ], + [ + "arduino uno1:GND.1", + "resistor7:1", + "black", + [ + "v-28.8", + "h365.1", + "v124.8" + ] + ], + [ + "arduino uno1:GND.1", + "resistor6:1", + "black", + [ + "v-28.8", + "h365.1", + "v115.2" + ] + ], + [ + "arduino uno1:GND.1", + "resistor5:1", + "black", + [ + "v-28.8", + "h365.1", + "v105.6" + ] + ], + [ + "arduino uno1:GND.1", + "resistor4:1", + "black", + [ + "v-28.8", + "h365.1", + "v96" + ] + ], + [ + "arduino uno1:GND.1", + "resistor3:1", + "black", + [ + "v-28.8", + "h365.1", + "v86.4" + ] + ], + [ + "arduino uno1:GND.1", + "resistor2:1", + "black", + [ + "v-28.8", + "h365.1", + "v76.8" + ] + ], + [ + "arduino uno1:GND.1", + "resistor1:1", + "black", + [ + "v-28.8", + "h365.1", + "v67.2" + ] + ], + [ + "bar graph led1:A1", + "arduino uno1:2", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A2", + "arduino uno1:3", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A3", + "arduino uno1:4", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A4", + "arduino uno1:5", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A5", + "arduino uno1:6", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A6", + "arduino uno1:7", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A7", + "arduino uno1:8", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A8", + "arduino uno1:9", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A9", + "arduino uno1:10", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A10", + "arduino uno1:11", + "green", + [ + "h0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level1/bar_led_basic/diagram_breadboard.json b/arduino/level1/bar_led_basic/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..46dc5b7c691b94656101af70ecb7a9bf2c44ccd6 --- /dev/null +++ b/arduino/level1/bar_led_basic/diagram_breadboard.json @@ -0,0 +1,608 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Turn on bar graph LED", + "config": { + "1_pin": 2, + "2_pin": 3, + "3_pin": 4, + "4_pin": 5, + "5_pin": 6, + "6_pin": 7, + "7_pin": 8, + "8_pin": 9, + "9_pin": 10, + "10_pin": 11, + "led_color": "lime", + "gnd_pin": "GND.1" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -156.6, + "left": 406, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 67.8, + "left": 623.4, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -34.45, + "left": 652.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-led-bar-graph", + "id": "bar graph led1", + "top": -101, + "left": 734.6, + "rotate": 90, + "attrs": { + "color": "lime" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -24.85, + "left": 662.4, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -15.25, + "left": 672, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 4.8, + "left": 709.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": -34.45, + "left": 796.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -24.85, + "left": 787.2, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": -15.25, + "left": 777.6, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": 4.8, + "left": 738.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor9", + "top": 4.8, + "left": 719.45, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor10", + "top": 4.8, + "left": 729.05, + "rotate": 90, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "bar graph led1:A1", + "breadboard1:39t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A2", + "breadboard1:38t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A3", + "breadboard1:37t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A4", + "breadboard1:36t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A5", + "breadboard1:35t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A6", + "breadboard1:34t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A7", + "breadboard1:33t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A8", + "breadboard1:32t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A9", + "breadboard1:31t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A10", + "breadboard1:30t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C1", + "breadboard1:39b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C2", + "breadboard1:38b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C3", + "breadboard1:37b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C4", + "breadboard1:36b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C5", + "breadboard1:35b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C6", + "breadboard1:34b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C7", + "breadboard1:33b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C8", + "breadboard1:32b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C9", + "breadboard1:31b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C10", + "breadboard1:30b.f", + "", + [ + "$bb" + ] + ], + [ + "resistor5:1", + "breadboard1:39b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor5:2", + "breadboard1:45b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor6:1", + "breadboard1:38b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor6:2", + "breadboard1:44b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor7:1", + "breadboard1:37b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor7:2", + "breadboard1:43b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:26b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:32b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:25b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:31b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:24b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:30b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor9:1", + "breadboard1:34b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor9:2", + "breadboard1:bn.27", + "", + [ + "$bb" + ] + ], + [ + "resistor10:1", + "breadboard1:35b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor10:2", + "breadboard1:bn.28", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:43b.j", + "breadboard1:bn.35", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:44b.i", + "breadboard1:bn.36", + "green", + [ + "v0" + ] + ], + [ + "resistor8:1", + "breadboard1:36b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor8:2", + "breadboard1:bn.29", + "", + [ + "$bb" + ] + ], + [ + "resistor4:1", + "breadboard1:33b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor4:2", + "breadboard1:bn.26", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:45b.h", + "breadboard1:bn.37", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:26b.j", + "breadboard1:bn.21", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:25b.i", + "breadboard1:bn.20", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:24b.h", + "breadboard1:bn.19", + "green", + [ + "v0" + ] + ], + [ + "arduino uno1:GND.1", + "breadboard1:bn.24", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:30t.d", + "arduino uno1:11", + "green", + [ + "v-105.6", + "h48" + ] + ], + [ + "breadboard1:31t.d", + "arduino uno1:10", + "green", + [ + "v-115.2", + "h57.6" + ] + ], + [ + "breadboard1:32t.d", + "arduino uno1:9", + "green", + [ + "v-124.8", + "h57.6" + ] + ], + [ + "breadboard1:33t.d", + "arduino uno1:8", + "green", + [ + "v-134.4", + "h57.6" + ] + ], + [ + "breadboard1:34t.d", + "arduino uno1:7", + "green", + [ + "v-96", + "h57.6" + ] + ], + [ + "breadboard1:35t.d", + "arduino uno1:6", + "green", + [ + "v-105.6", + "h57.6" + ] + ], + [ + "breadboard1:36t.d", + "arduino uno1:5", + "green", + [ + "v-115.2", + "h67.2" + ] + ], + [ + "breadboard1:37t.d", + "arduino uno1:4", + "green", + [ + "v-86.4", + "h67.2" + ] + ], + [ + "breadboard1:38t.d", + "arduino uno1:3", + "green", + [ + "v-76.8", + "h67.2" + ] + ], + [ + "breadboard1:39t.d", + "arduino uno1:2", + "green", + [ + "v-96", + "h67.2" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level1/bar_led_basic/diagram_breadboard_shdf.json b/arduino/level1/bar_led_basic/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..bd34752255923e039b46bfd8fdd1ad94382ea1e9 --- /dev/null +++ b/arduino/level1/bar_led_basic/diagram_breadboard_shdf.json @@ -0,0 +1,319 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "Bar graph LED1", + "type": "bar graph led", + "properties": { + "color": "lime" + } + }, + { + "id": "r2", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r3", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r4", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r5", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r6", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r7", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r8", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r9", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r10", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + } + ], + "connections": [ + [ + "Bar graph LED1.a1", + "bb1.pin39t.e" + ], + [ + "Bar graph LED1.a2", + "bb1.pin38t.e" + ], + [ + "Bar graph LED1.a3", + "bb1.pin37t.e" + ], + [ + "Bar graph LED1.a4", + "bb1.pin36t.e" + ], + [ + "Bar graph LED1.a5", + "bb1.pin35t.e" + ], + [ + "Bar graph LED1.a6", + "bb1.pin34t.e" + ], + [ + "Bar graph LED1.a7", + "bb1.pin33t.e" + ], + [ + "Bar graph LED1.a8", + "bb1.pin32t.e" + ], + [ + "Bar graph LED1.a9", + "bb1.pin31t.e" + ], + [ + "Bar graph LED1.a10", + "bb1.pin30t.e" + ], + [ + "Bar graph LED1.c1", + "bb1.pin39b.f" + ], + [ + "Bar graph LED1.c2", + "bb1.pin38b.f" + ], + [ + "Bar graph LED1.c3", + "bb1.pin37b.f" + ], + [ + "Bar graph LED1.c4", + "bb1.pin36b.f" + ], + [ + "Bar graph LED1.c5", + "bb1.pin35b.f" + ], + [ + "Bar graph LED1.c6", + "bb1.pin34b.f" + ], + [ + "Bar graph LED1.c7", + "bb1.pin33b.f" + ], + [ + "Bar graph LED1.c8", + "bb1.pin32b.f" + ], + [ + "Bar graph LED1.c9", + "bb1.pin31b.f" + ], + [ + "Bar graph LED1.c10", + "bb1.pin30b.f" + ], + [ + "r5.1", + "bb1.pin39b.g" + ], + [ + "r5.2", + "bb1.pin45b.g" + ], + [ + "r6.1", + "bb1.pin38b.h" + ], + [ + "r6.2", + "bb1.pin44b.h" + ], + [ + "r7.1", + "bb1.pin37b.i" + ], + [ + "r7.2", + "bb1.pin43b.i" + ], + [ + "r3.1", + "bb1.pin26b.i" + ], + [ + "r3.2", + "bb1.pin32b.i" + ], + [ + "r2.1", + "bb1.pin25b.h" + ], + [ + "r2.2", + "bb1.pin31b.h" + ], + [ + "r1.1", + "bb1.pin24b.g" + ], + [ + "r1.2", + "bb1.pin30b.g" + ], + [ + "r9.1", + "bb1.pin34b.h" + ], + [ + "r9.2", + "bb1.bn.27" + ], + [ + "r10.1", + "bb1.pin35b.h" + ], + [ + "r10.2", + "bb1.bn.28" + ], + [ + "bb1.pin43b.j", + "bb1.bn.35" + ], + [ + "bb1.pin44b.i", + "bb1.bn.36" + ], + [ + "r8.1", + "bb1.pin36b.h" + ], + [ + "r8.2", + "bb1.bn.29" + ], + [ + "r4.1", + "bb1.pin33b.h" + ], + [ + "r4.2", + "bb1.bn.26" + ], + [ + "bb1.pin45b.h", + "bb1.bn.37" + ], + [ + "bb1.pin26b.j", + "bb1.bn.21" + ], + [ + "bb1.pin25b.i", + "bb1.bn.20" + ], + [ + "bb1.pin24b.h", + "bb1.bn.19" + ], + [ + "uno.gnd.1", + "bb1.bn.24" + ], + [ + "bb1.pin30t.d", + "uno.11" + ], + [ + "bb1.pin31t.d", + "uno.10" + ], + [ + "bb1.pin32t.d", + "uno.9" + ], + [ + "bb1.pin33t.d", + "uno.8" + ], + [ + "bb1.pin34t.d", + "uno.7" + ], + [ + "bb1.pin35t.d", + "uno.6" + ], + [ + "bb1.pin36t.d", + "uno.5" + ], + [ + "bb1.pin37t.d", + "uno.4" + ], + [ + "bb1.pin38t.d", + "uno.3" + ], + [ + "bb1.pin39t.d", + "uno.2" + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/bar_led_basic/diagram_shdf.json b/arduino/level1/bar_led_basic/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..b0af0f199ffb2f984703d9fc04d05cbc25897b7e --- /dev/null +++ b/arduino/level1/bar_led_basic/diagram_shdf.json @@ -0,0 +1,207 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r2", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r3", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "bar graph led1", + "type": "bar graph led", + "properties": { + "color": "lime" + } + }, + { + "id": "r4", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r5", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r6", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r7", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r8", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r9", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r10", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + } + ], + "connections": [ + [ + "r1.2", + "bar graph led1.c1" + ], + [ + "r3.2", + "bar graph led1.c2" + ], + [ + "r2.2", + "bar graph led1.c3" + ], + [ + "r4.2", + "bar graph led1.c4" + ], + [ + "r5.2", + "bar graph led1.c5" + ], + [ + "r6.2", + "bar graph led1.c6" + ], + [ + "r7.2", + "bar graph led1.c7" + ], + [ + "r8.2", + "bar graph led1.c8" + ], + [ + "r9.2", + "bar graph led1.c9" + ], + [ + "r10.2", + "bar graph led1.c10" + ], + [ + "uno.gnd.1", + "r10.1" + ], + [ + "uno.gnd.1", + "r9.1" + ], + [ + "uno.gnd.1", + "r8.1" + ], + [ + "uno.gnd.1", + "r7.1" + ], + [ + "uno.gnd.1", + "r6.1" + ], + [ + "uno.gnd.1", + "r5.1" + ], + [ + "uno.gnd.1", + "r4.1" + ], + [ + "uno.gnd.1", + "r2.1" + ], + [ + "uno.gnd.1", + "r3.1" + ], + [ + "uno.gnd.1", + "r1.1" + ], + [ + "bar graph led1.a1", + "uno.2" + ], + [ + "bar graph led1.a2", + "uno.3" + ], + [ + "bar graph led1.a3", + "uno.4" + ], + [ + "bar graph led1.a4", + "uno.5" + ], + [ + "bar graph led1.a5", + "uno.6" + ], + [ + "bar graph led1.a6", + "uno.7" + ], + [ + "bar graph led1.a7", + "uno.8" + ], + [ + "bar graph led1.a8", + "uno.9" + ], + [ + "bar graph led1.a9", + "uno.10" + ], + [ + "bar graph led1.a10", + "uno.11" + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/bar_led_basic/platformio.ini b/arduino/level1/bar_led_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level1/bar_led_basic/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level1/bar_led_basic/scenario.yaml b/arduino/level1/bar_led_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1e58861a8271ac0200fd681a5c785ce595cd6a04 --- /dev/null +++ b/arduino/level1/bar_led_basic/scenario.yaml @@ -0,0 +1,86 @@ +author: Blind Author +description: Turn on the bar graph LED +name: Bar graph LED +steps: +- delay: 10ms +- expect-pin: + part-id: bar graph led1 + pin: C1 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: c2 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C3 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C4 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C5 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C6 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C7 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C8 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C9 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C10 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A1 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A2 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A3 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A4 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A5 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A6 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A7 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A8 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A9 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A10 + value: 0 +version: 1.0 diff --git a/arduino/level1/bar_led_basic/src/main.ino b/arduino/level1/bar_led_basic/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..9bf4c1aca5c16e70701ef037c3a1c00759d1ff74 --- /dev/null +++ b/arduino/level1/bar_led_basic/src/main.ino @@ -0,0 +1,25 @@ +/** + Use bar LED + 10 APR 2025 by Blind Author +*/ + +int pinList[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; + +int threshold = 6; + +void setup() { + for (int i=0; i<10; i++) { + pinMode(pinList[i], OUTPUT); + } + + for (int i=0; i<10; i++) { + if (i < threshold) { + digitalWrite(pinList[i], HIGH); + } else { + digitalWrite(pinList[i], LOW); + } + } +} + +void loop() { +} \ No newline at end of file diff --git a/arduino/level1/bar_led_basic/wokwi.toml b/arduino/level1/bar_led_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level1/bar_led_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level1/buzzer_basic/description.md b/arduino/level1/buzzer_basic/description.md new file mode 100644 index 0000000000000000000000000000000000000000..a91f2ebe8247fdc6296dff228d5996ffdaa98a62 --- /dev/null +++ b/arduino/level1/buzzer_basic/description.md @@ -0,0 +1,26 @@ +# Piezo Buzzer + +## Project Description +This is a simple Arduino project that uses piezoelectric buzzer to play 262Hz tone. + +## Hardware Components +- Arduino Uno +- Piezoelectric buzzer + +## Circuit Description +The piezo buzzer is connected to the Arduino. The positive pin is connected to pin2, the negative pin to gnd1. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set the pin mode as OUTPUT +2. Continuously play 262Hz tone + +## Success Criteria +The test is successful when: +1. Piezo buzzer runs successfuly + +## Notes for Implementation +- In the loop function, make buzzer play 262Hz tone + +## Variants +There may be variants with buzzer, GND pin number and the pitch of the sound being played. \ No newline at end of file diff --git a/arduino/level1/buzzer_basic/description_no_pin.md b/arduino/level1/buzzer_basic/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..3d6e6831c80c690146c7c2534cd685da48cc738b --- /dev/null +++ b/arduino/level1/buzzer_basic/description_no_pin.md @@ -0,0 +1,26 @@ +# Piezo Buzzer + +## Project Description +This is a simple Arduino project that uses piezoelectric buzzer to play 262Hz tone. + +## Hardware Components +- Arduino Uno +- Piezoelectric buzzer + +## Circuit Description +The piezo buzzer is connected to the Arduino. The positive pin is connected to arduino digital pin. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set the pin mode as OUTPUT +2. Continuously play 262Hz tone + +## Success Criteria +The test is successful when: +1. Piezo buzzer runs successfuly + +## Notes for Implementation +- In the loop function, make buzzer play 262Hz tone + +## Variants +There may be variants with buzzer, GND pin number and the pitch of the sound being played. \ No newline at end of file diff --git a/arduino/level1/buzzer_basic/diagram.json b/arduino/level1/buzzer_basic/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..1aaedc22c2053f4adbfadf90f9492a014eff3695 --- /dev/null +++ b/arduino/level1/buzzer_basic/diagram.json @@ -0,0 +1,42 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Play tone with piezo buzzer", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-buzzer", + "id": "piezoelectric buzzer1", + "top": -141.6, + "left": 97.8, + "attrs": { + "volume": "0.1" + } + } + ], + "connections": [ + [ + "piezoelectric buzzer1:1", + "arduino uno1:GND.1", + "green", + [ + "v0" + ] + ], + [ + "piezoelectric buzzer1:2", + "arduino uno1:2", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level1/buzzer_basic/diagram_breadboard.json b/arduino/level1/buzzer_basic/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..1b27650a98ba3000f6b3339b5a0185f4a3eb275f --- /dev/null +++ b/arduino/level1/buzzer_basic/diagram_breadboard.json @@ -0,0 +1 @@ +{"version": 1.0, "author": "Blind Author", "description": "Play tone with piezo buzzer", "parts": [{"type": "wokwi-breadboard", "id": "breadboard1", "top": -243, "left": -198.8, "attrs": {}}, {"type": "wokwi-arduino-uno", "id": "arduino uno1", "top": -9, "left": -19.8, "attrs": {}}, {"type": "wokwi-buzzer", "id": "piezoelectric buzzer1", "top": -208.8, "left": 88.2, "attrs": {"volume": "0.1"}}], "connections": [["piezoelectric buzzer1:1", "breadboard1:31b.f", "", ["$bb"]], ["piezoelectric buzzer1:2", "breadboard1:32b.f", "", ["$bb"]], ["breadboard1:31b.g", "arduino uno1:GND.1", "green", ["v0"]], ["breadboard1:32b.g", "arduino uno1:2", "green", ["v0"]]], "dependencies": {}} \ No newline at end of file diff --git a/arduino/level1/buzzer_basic/diagram_breadboard_shdf.json b/arduino/level1/buzzer_basic/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..c3d388219f19afcfbe26477c06550990a4740826 --- /dev/null +++ b/arduino/level1/buzzer_basic/diagram_breadboard_shdf.json @@ -0,0 +1,34 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "bz1", + "type": "piezoelectric buzzer" + } + ], + "connections": [ + [ + "bz1.1", + "bb1.pin31b.f" + ], + [ + "bz1.2", + "bb1.pin32b.f" + ], + [ + "bb1.pin31b.g", + "uno.gnd.1" + ], + [ + "bb1.pin32b.g", + "uno.2" + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/buzzer_basic/diagram_shdf.json b/arduino/level1/buzzer_basic/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..0f260fe9b2be49f3fbd31843b58db71eab14ba44 --- /dev/null +++ b/arduino/level1/buzzer_basic/diagram_shdf.json @@ -0,0 +1,22 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "bz1", + "type": "piezoelectric buzzer" + } + ], + "connections": [ + [ + "bz1.1", + "uno.gnd.1" + ], + [ + "bz1.2", + "uno.2" + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/buzzer_basic/platformio.ini b/arduino/level1/buzzer_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level1/buzzer_basic/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level1/buzzer_basic/scenario.yaml b/arduino/level1/buzzer_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..263e075b51f3a08d407f69e33cc437dab389ee1c --- /dev/null +++ b/arduino/level1/buzzer_basic/scenario.yaml @@ -0,0 +1,12 @@ +author: Blind Author +description: Control a servo motor +name: Servo Motor Control +steps: +- delay: 10ms +- wait-pin: + timeout: 1000 + interval: 100 + part-id: piezoelectric buzzer1 + pin: 2 + value: 1 +version: 1.0 diff --git a/arduino/level1/buzzer_basic/src/main.ino b/arduino/level1/buzzer_basic/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..23d9e1fd7e6ef110df160f06d4f38e079844929d --- /dev/null +++ b/arduino/level1/buzzer_basic/src/main.ino @@ -0,0 +1,15 @@ +/* + Use a piezoelectric buzzer to play 262Hz tone. + 4 APR 2025 by Blind Author +*/ + +const int BUZZER_PIN = 2; + +void setup() { + pinMode(BUZZER_PIN, OUTPUT); +} + +void loop() { + tone(BUZZER_PIN, 262, 250); +} + diff --git a/arduino/level1/buzzer_basic/wokwi.toml b/arduino/level1/buzzer_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level1/buzzer_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level1/distance_sensor_basic/description.md b/arduino/level1/distance_sensor_basic/description.md new file mode 100644 index 0000000000000000000000000000000000000000..e0b1c9d09618ed2b124153f1891a1cc6a7059008 --- /dev/null +++ b/arduino/level1/distance_sensor_basic/description.md @@ -0,0 +1,27 @@ +# Distance Sensor + +## Project Description +This is a simple Arduino project that uses Ultrasonic distance sensor to measure the distance. + +## Hardware Components +- Arduino Uno +- Ultrasonic Distance Sensor + +## Circuit Description +The ultrasonic distance sensor is connected to the Arduino. The VCC pin is connected to 5V, the GND pin to gnd3, the TRIG pin to pin3, and the ECHO pin to pin2. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Continuously trigger and read the Ultrasonic distance sensor +3. Change the value to the centimeter and print in the format: "Distance in CM: {value}" + +## Success Criteria +The test is successful when: +1. Correct distance value in centimeter is printed in the serial monitor. + +## Notes for Implementation +- To convert the distance sensor value to centimeters, divide it by 58. + +## Variants +There may be variants with init distance value and ECHO, TRIG, GND pin number. \ No newline at end of file diff --git a/arduino/level1/distance_sensor_basic/description_no_pin.md b/arduino/level1/distance_sensor_basic/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..1a53f35f04a171478a5effc21ec5eff5e787f16a --- /dev/null +++ b/arduino/level1/distance_sensor_basic/description_no_pin.md @@ -0,0 +1,27 @@ +# Distance Sensor + +## Project Description +This is a simple Arduino project that uses Ultrasonic distance sensor to measure the distance. + +## Hardware Components +- Arduino Uno +- Ultrasonic Distance Sensor + +## Circuit Description +The ultrasonic distance sensor is connected to the Arduino. The TRIG pin and the ECHO pin is connected to arduino digital pins. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Continuously trigger and read the Ultrasonic distance sensor +3. Change the value to the centimeter and print in the format: "Distance in CM: {value}" + +## Success Criteria +The test is successful when: +1. Correct distance value in centimeter is printed in the serial monitor. + +## Notes for Implementation +- To convert the distance sensor value to centimeters, divide it by 58. + +## Variants +There may be variants with init distance value and ECHO, TRIG, GND pin number. \ No newline at end of file diff --git a/arduino/level1/distance_sensor_basic/diagram.json b/arduino/level1/distance_sensor_basic/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..6aba5d9a4051d62402bc00c135fe05ba0bbdb9e7 --- /dev/null +++ b/arduino/level1/distance_sensor_basic/diagram.json @@ -0,0 +1,65 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read value of distance sensor", + "config": { + "distance_echo_pin": "2", + "distance_trig_pin": "3", + "gnd_pin": "GND.3", + "distance_init": "400" + }, + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-hc-sr04", + "id": "ultrasonic distance sensor1", + "top": 43.5, + "left": 288.9, + "rotate": 90, + "attrs": { + "distance": "400" + } + } + ], + "connections": [ + [ + "ultrasonic distance sensor1:VCC", + "arduino uno1:5V", + "red", + [ + "h0" + ] + ], + [ + "ultrasonic distance sensor1:GND", + "arduino uno1:GND.3", + "black", + [ + "h0" + ] + ], + [ + "ultrasonic distance sensor1:TRIG", + "arduino uno1:3", + "green", + [ + "h0" + ] + ], + [ + "ultrasonic distance sensor1:ECHO", + "arduino uno1:2", + "green", + [ + "h0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level1/distance_sensor_basic/diagram_breadboard.json b/arduino/level1/distance_sensor_basic/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..e690e163c6f1abc5b175cf38151e1ac0f3637b1b --- /dev/null +++ b/arduino/level1/distance_sensor_basic/diagram_breadboard.json @@ -0,0 +1,103 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read value of distance sensor", + "config": { + "distance_echo_pin": "2", + "distance_trig_pin": "3", + "gnd_pin": "GND.3", + "distance_init": "400" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -252.6, + "left": -64.4, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-hc-sr04", + "id": "ultrasonic distance sensor1", + "top": -228.9, + "left": 178.3, + "attrs": { + "distance": "400" + } + } + ], + "connections": [ + [ + "ultrasonic distance sensor1:VCC", + "breadboard1:31b.f", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:TRIG", + "breadboard1:32b.f", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:ECHO", + "breadboard1:33b.f", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:GND", + "breadboard1:34b.f", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:34b.g", + "arduino uno1:GND.3", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:31b.g", + "arduino uno1:5V", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:32b.g", + "arduino uno1:3", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:33b.g", + "arduino uno1:2", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level1/distance_sensor_basic/diagram_breadboard_shdf.json b/arduino/level1/distance_sensor_basic/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..d93278b034afcbfedaeb41d0fb658d9d64eb1e70 --- /dev/null +++ b/arduino/level1/distance_sensor_basic/diagram_breadboard_shdf.json @@ -0,0 +1,50 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "ultrasonic1", + "type": "ultrasonic distance sensor" + } + ], + "connections": [ + [ + "ultrasonic1.vcc", + "bb1.pin31b.f" + ], + [ + "ultrasonic1.trig", + "bb1.pin32b.f" + ], + [ + "ultrasonic1.echo", + "bb1.pin33b.f" + ], + [ + "ultrasonic1.gnd", + "bb1.pin34b.f" + ], + [ + "bb1.pin34b.g", + "uno.gnd.3" + ], + [ + "bb1.pin31b.g", + "uno.5v" + ], + [ + "bb1.pin32b.g", + "uno.3" + ], + [ + "bb1.pin33b.g", + "uno.2" + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/distance_sensor_basic/diagram_shdf.json b/arduino/level1/distance_sensor_basic/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..4ebed208df8ae49a8027670f9d713b2fa40aedc5 --- /dev/null +++ b/arduino/level1/distance_sensor_basic/diagram_shdf.json @@ -0,0 +1,30 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "ultrasonic1", + "type": "ultrasonic distance sensor" + } + ], + "connections": [ + [ + "ultrasonic1.vcc", + "uno.5v" + ], + [ + "ultrasonic1.gnd", + "uno.gnd.3" + ], + [ + "ultrasonic1.trig", + "uno.3" + ], + [ + "ultrasonic1.echo", + "uno.2" + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/distance_sensor_basic/platformio.ini b/arduino/level1/distance_sensor_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level1/distance_sensor_basic/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level1/distance_sensor_basic/scenario.yaml b/arduino/level1/distance_sensor_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c2eb34dd8488eb205958ec1e0fb68cd5eb083bab --- /dev/null +++ b/arduino/level1/distance_sensor_basic/scenario.yaml @@ -0,0 +1,7 @@ +author: Blind Author +description: Measure distance with Ultrasonic distance sensor +name: Distance Sensor +steps: +- delay: 10ms +- wait-serial: 'Distance in CM: 403' +version: 1.0 diff --git a/arduino/level1/distance_sensor_basic/src/main.ino b/arduino/level1/distance_sensor_basic/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..111c501e66d10d848ae155b28e6cbc33a5eb2f9d --- /dev/null +++ b/arduino/level1/distance_sensor_basic/src/main.ino @@ -0,0 +1,25 @@ +/** + Measure distance with Ultrasonic distance sensor. + 3 APR 2025 by Blind Author +*/ + +#define PIN_TRIG 3 +#define PIN_ECHO 2 + +void setup() { + Serial.begin(115200); + pinMode(PIN_TRIG, OUTPUT); + pinMode(PIN_ECHO, INPUT); +} + +void loop() { + digitalWrite(PIN_TRIG, HIGH); + delayMicroseconds(10); + digitalWrite(PIN_TRIG, LOW); + + int duration = pulseIn(PIN_ECHO, HIGH); + Serial.print("Distance in CM: "); + Serial.println(duration / 58); + + delay(500); +} \ No newline at end of file diff --git a/arduino/level1/distance_sensor_basic/wokwi.toml b/arduino/level1/distance_sensor_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level1/distance_sensor_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level1/humidity_sensor_basic/description.md b/arduino/level1/humidity_sensor_basic/description.md new file mode 100644 index 0000000000000000000000000000000000000000..da2a3c1bf10b7014cc9844f6899d7c8f1039a9ee --- /dev/null +++ b/arduino/level1/humidity_sensor_basic/description.md @@ -0,0 +1,25 @@ +# Humidity Sensor Basic + +## Project Description +This is a simple Arduino project that uses dht22 sensor to measure the humidity. + +## Hardware Components +- Arduino Uno +- DHT22 sensor + +## Circuit Description +The DHT22 sensor is connected to an Arduino Uno. The VCC pin is connected to the 5V pin on the Arduino, and the GND pin is connected to the GND2 pin. The data pin is connected to digital pin 2 on the Arduino. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial monitor +2. Initialize and begin DHT sensor +3. Continuously read the DHT sensor's humidity value +4. Print humidity to the serial monitor in the following format: "Humidity: {humidity value}", for example: "Humidity: 40.0" + +## Success Criteria +The test is successful when: +1. The correct humidity value is printed to the serial monitor. + +## Notes for Implementation + diff --git a/arduino/level1/humidity_sensor_basic/description_no_pin.md b/arduino/level1/humidity_sensor_basic/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..a40ea71413457a21ec2ed025c6561ce65de74fa4 --- /dev/null +++ b/arduino/level1/humidity_sensor_basic/description_no_pin.md @@ -0,0 +1,25 @@ +# Humidity Sensor Basic + +## Project Description +This is a simple Arduino project that uses dht22 sensor to measure the humidity. + +## Hardware Components +- Arduino Uno +- DHT22 sensor + +## Circuit Description +The DHT22 sensor is connected to an Arduino Uno. The data pin is connected to digital pin of the Arduino. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial monitor +2. Initialize and begin DHT sensor +3. Continuously read the DHT sensor's humidity value +4. Print humidity to the serial monitor in the following format: "Humidity: {humidity value}", for example: "Humidity: 40.0" + +## Success Criteria +The test is successful when: +1. The correct humidity value is printed to the serial monitor. + +## Notes for Implementation + diff --git a/arduino/level1/humidity_sensor_basic/diagram.json b/arduino/level1/humidity_sensor_basic/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..20cfeb45d6e47ccdb6a50691e4cdc500be2cff4b --- /dev/null +++ b/arduino/level1/humidity_sensor_basic/diagram.json @@ -0,0 +1,57 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read humidity sensor value", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-dht22", + "id": "dht22 sensor1", + "top": -201.3, + "left": 100.2, + "attrs": { + "humidity": "64.5" + } + } + ], + "connections": [ + [ + "dht22 sensor1:VCC", + "arduino uno1:5V", + "red", + [ + "v48", + "h-134.4", + "v259.2", + "h182.4" + ] + ], + [ + "dht22 sensor1:GND", + "arduino uno1:GND.2", + "black", + [ + "v48", + "h144", + "v268.8", + "h19.2" + ] + ], + [ + "dht22 sensor1:SDA", + "arduino uno1:2", + "green", + [ + "v76.8", + "h115.3" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level1/humidity_sensor_basic/diagram_breadboard.json b/arduino/level1/humidity_sensor_basic/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..a02cc67f74cf91a80f0ddce36538652e336b20cc --- /dev/null +++ b/arduino/level1/humidity_sensor_basic/diagram_breadboard.json @@ -0,0 +1,109 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read humidity sensor value", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -223.8, + "left": -93.2, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-dht22", + "id": "dht22 sensor1", + "top": -210.9, + "left": 100.2, + "attrs": { + "humidity": "64.5" + } + } + ], + "connections": [ + [ + "dht22 sensor1:VCC", + "breadboard1:20b.g", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:SDA", + "breadboard1:21b.g", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:NC", + "breadboard1:22b.g", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:GND", + "breadboard1:23b.g", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:20b.h", + "breadboard1:bp.16", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:21b.h", + "arduino uno1:2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:23b.h", + "breadboard1:bn.18", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:bn.1", + "arduino uno1:GND.2", + "green", + [ + "v238.7", + "h210.4" + ] + ], + [ + "breadboard1:bp.1", + "arduino uno1:5V", + "green", + [ + "v-0.9", + "h-20", + "v259.2", + "h230.4" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level1/humidity_sensor_basic/platformio.ini b/arduino/level1/humidity_sensor_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..598164a9e2d3c7598b562fda5974537e4ca29102 --- /dev/null +++ b/arduino/level1/humidity_sensor_basic/platformio.ini @@ -0,0 +1,22 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + DHT sensor library + DHT22 \ No newline at end of file diff --git a/arduino/level1/humidity_sensor_basic/scenario.yaml b/arduino/level1/humidity_sensor_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..72079d1b5961685ce1e98f868de4ced11c1d81f6 --- /dev/null +++ b/arduino/level1/humidity_sensor_basic/scenario.yaml @@ -0,0 +1,11 @@ +author: Blind Author +description: Read humidity sensor value +name: Humidity Sensor Basic +steps: +- delay: 100ms +- wait-serial: 'Humidity: 64.5' +test-values: +- attr-name: humidity + part-type: wokwi-dht22 + value: '64.5' +version: 1.0 diff --git a/arduino/level1/humidity_sensor_basic/src/main.ino b/arduino/level1/humidity_sensor_basic/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..09de5d77fbd0203c122918439cc230caa556d3c6 --- /dev/null +++ b/arduino/level1/humidity_sensor_basic/src/main.ino @@ -0,0 +1,26 @@ +/** + Read the humidity sensor value + 03 MAY 2025 by Blind Author +*/ + +#include "DHT.h" + +#define DHTTYPE DHT22 + +#define DHTPIN 2 + +DHT dht(DHTPIN, DHTTYPE); + +void setup() { + Serial.begin(9600); + dht.begin(); +} + +void loop() { + float humidity = dht.readHumidity(); + + Serial.print("Humidity: "); + Serial.println(humidity); + + delay(1000); +} \ No newline at end of file diff --git a/arduino/level1/humidity_sensor_basic/wokwi.toml b/arduino/level1/humidity_sensor_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level1/humidity_sensor_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level1/led_RGB_basic/description.md b/arduino/level1/led_RGB_basic/description.md new file mode 100644 index 0000000000000000000000000000000000000000..ba0bcc02e74bde7aaa834791e0977e6700f2e1d7 --- /dev/null +++ b/arduino/level1/led_RGB_basic/description.md @@ -0,0 +1,32 @@ +# LED RGB + +## Project Description +This is a simple Arduino project that turns on an RGB LED. + +## Hardware Components +- Arduino Uno +- RGB LED +- 220Ω resistor * 3 + +## Circuit Description +The R, G, B pin of the RGB LED is connected to the pin4, pin3, pin2 pin of the Arduino Uno through a 220Ω current-limiting resistor. The common pin of the RGB LED is connected to 5V. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set pin4, pin3, pin2 pin mode to OUTPUT +2. Considering that the LED's common pin is connected to 5V, turn on only the blue segment at full brightness. + +## Success Criteria +The test is successful when: +1. Only the blue light of the RGB LED is fully on. + +## Notes for Implementation +- The LED should turn on immediately during setup and stay on +- No actions are required in the loop function +- The pin number used should match the circuit diagram + +## Variants +This project may have different variants with the RGB LED connected to different pins. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level1/led_RGB_basic/description_no_pin.md b/arduino/level1/led_RGB_basic/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..868378a2092b8b02e4c4b06dcfaf4aebd0903852 --- /dev/null +++ b/arduino/level1/led_RGB_basic/description_no_pin.md @@ -0,0 +1,32 @@ +# LED RGB + +## Project Description +This is a simple Arduino project that turns on an RGB LED. + +## Hardware Components +- Arduino Uno +- RGB LED +- 220Ω resistor * 3 + +## Circuit Description +The R, G, B pin of the RGB LED is connected to the digital pins of the Arduino Uno through a 220Ω resistor. RGB LED has common anode configuration. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set arduino digital pin mode to OUTPUT +2. Considering that the LED has common anode configuration, turn on only the blue segment at full brightness. + +## Success Criteria +The test is successful when: +1. Only the blue light of the RGB LED is fully on. + +## Notes for Implementation +- The LED should turn on immediately during setup and stay on +- No actions are required in the loop function +- The pin number used should match the circuit diagram + +## Variants +This project may have different variants with the RGB LED connected to different pins. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level1/led_RGB_basic/diagram.json b/arduino/level1/led_RGB_basic/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..269c62e266af93a069ba84ecfe2ef14f0746d799 --- /dev/null +++ b/arduino/level1/led_RGB_basic/diagram.json @@ -0,0 +1 @@ +{"version": 1.0, "author": "Blind Author", "description": "Turn on RGB LED", "config": {"R_pin": 4, "G_pin": 3, "B_pin": 2}, "parts": [{"type": "wokwi-arduino-uno", "id": "arduino uno1", "top": 115.8, "left": 527.4, "attrs": {}}, {"type": "wokwi-rgb-led", "id": "rgb led1", "top": -92, "left": 644.3, "attrs": {}}, {"type": "wokwi-resistor", "id": "resistor1", "top": 4.8, "left": 623.45, "rotate": 90, "attrs": {"value": "220"}}, {"type": "wokwi-resistor", "id": "resistor2", "top": 4.8, "left": 642.65, "rotate": 90, "attrs": {"value": "220"}}, {"type": "wokwi-resistor", "id": "resistor3", "top": 4.8, "left": 661.85, "rotate": 90, "attrs": {"value": "220"}}], "connections": [["rgb led1:COM", "arduino uno1:5V", "green", ["v0"]], ["rgb led1:R", "resistor1:1", "green", ["v19.2"]], ["resistor2:1", "rgb led1:G", "green", ["h0"]], ["resistor3:1", "rgb led1:B", "green", ["h0"]], ["resistor1:2", "arduino uno1:4", "green", ["h0", "v66", "h86.4"]], ["resistor2:2", "arduino uno1:3", "green", ["h0", "v56.4", "h76.8"]], ["resistor3:2", "arduino uno1:2", "green", ["h0", "v46.8", "h76.8"]]]} \ No newline at end of file diff --git a/arduino/level1/led_RGB_basic/diagram_breadboard.json b/arduino/level1/led_RGB_basic/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..fed3fa7c9bb1cde1db2d90f013c3b4523401b8ce --- /dev/null +++ b/arduino/level1/led_RGB_basic/diagram_breadboard.json @@ -0,0 +1 @@ +{"version": 1.0, "author": "Blind Author", "description": "Turn on RGB LED", "config": {"R_pin": 4, "G_pin": 3, "B_pin": 2}, "parts": [{"type": "wokwi-breadboard", "id": "breadboard1", "top": -137.4, "left": 502, "attrs": {}}, {"type": "wokwi-arduino-uno", "id": "arduino uno1", "top": 115.8, "left": 527.4, "attrs": {}}, {"type": "wokwi-rgb-led", "id": "rgb led1", "top": -120.8, "left": 653.9, "attrs": {}}, {"type": "wokwi-resistor", "id": "resistor1", "top": -33.6, "left": 633.05, "rotate": 90, "attrs": {"value": "220"}}, {"type": "wokwi-resistor", "id": "resistor2", "top": -33.6, "left": 652.25, "rotate": 90, "attrs": {"value": "220"}}, {"type": "wokwi-resistor", "id": "resistor3", "top": -33.6, "left": 661.85, "rotate": 90, "attrs": {"value": "220"}}], "connections": [["rgb led1:R", "breadboard1:15t.b", "", ["$bb"]], ["rgb led1:COM", "breadboard1:16t.c", "", ["$bb"]], ["rgb led1:G", "breadboard1:17t.b", "", ["$bb"]], ["rgb led1:B", "breadboard1:18t.b", "", ["$bb"]], ["resistor1:1", "breadboard1:15t.d", "", ["$bb"]], ["resistor1:2", "breadboard1:15b.h", "", ["$bb"]], ["resistor2:1", "breadboard1:17t.d", "", ["$bb"]], ["resistor2:2", "breadboard1:17b.h", "", ["$bb"]], ["resistor3:1", "breadboard1:18t.d", "", ["$bb"]], ["resistor3:2", "breadboard1:18b.h", "", ["$bb"]], ["breadboard1:17b.j", "arduino uno1:3", "green", ["v86.4", "h76.8"]], ["breadboard1:16t.e", "arduino uno1:5V", "green", ["v0"]], ["breadboard1:15b.j", "arduino uno1:4", "green", ["v0"]], ["arduino uno1:2", "breadboard1:18b.j", "green", ["v0"]]], "dependencies": {}} \ No newline at end of file diff --git a/arduino/level1/led_RGB_basic/diagram_breadboard_shdf.json b/arduino/level1/led_RGB_basic/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..625c03f4bd6cc2d28c09fb86f520ef5cf0faa04a --- /dev/null +++ b/arduino/level1/led_RGB_basic/diagram_breadboard_shdf.json @@ -0,0 +1,95 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "rgb1", + "type": "rgb led" + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r2", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r3", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + } + ], + "connections": [ + [ + "rgb1.r", + "bb1.pin15t.b" + ], + [ + "rgb1.com", + "bb1.pin16t.c" + ], + [ + "rgb1.g", + "bb1.pin17t.b" + ], + [ + "rgb1.b", + "bb1.pin18t.b" + ], + [ + "r1.1", + "bb1.pin15t.d" + ], + [ + "r1.2", + "bb1.pin15b.h" + ], + [ + "r2.1", + "bb1.pin17t.d" + ], + [ + "r2.2", + "bb1.pin17b.h" + ], + [ + "r3.1", + "bb1.pin18t.d" + ], + [ + "r3.2", + "bb1.pin18b.h" + ], + [ + "bb1.pin17b.j", + "uno.3" + ], + [ + "bb1.pin16t.e", + "uno.5v" + ], + [ + "bb1.pin15b.j", + "uno.4" + ], + [ + "uno.2", + "bb1.pin18b.j" + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/led_RGB_basic/diagram_shdf.json b/arduino/level1/led_RGB_basic/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..fd114fa5988593432cc64cc82cc7cdb42fe76f38 --- /dev/null +++ b/arduino/level1/led_RGB_basic/diagram_shdf.json @@ -0,0 +1,63 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "rgb1", + "type": "rgb led" + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r2", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r3", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + } + ], + "connections": [ + [ + "rgb1.com", + "uno.5v" + ], + [ + "rgb1.r", + "r1.1" + ], + [ + "r2.1", + "rgb1.g" + ], + [ + "r3.1", + "rgb1.b" + ], + [ + "r1.2", + "uno.4" + ], + [ + "r2.2", + "uno.3" + ], + [ + "r3.2", + "uno.2" + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/led_RGB_basic/platformio.ini b/arduino/level1/led_RGB_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level1/led_RGB_basic/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level1/led_RGB_basic/scenario.yaml b/arduino/level1/led_RGB_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..673db1e0a909e9c0ffd62191886633bf949c6058 --- /dev/null +++ b/arduino/level1/led_RGB_basic/scenario.yaml @@ -0,0 +1,22 @@ +author: Blind Author +description: Show blue light with RGB LED +name: RGB LED +steps: +- delay: 10ms +- expect-pin: + part-id: rgb led1 + pin: R + value: 1 +- expect-pin: + part-id: rgb led1 + pin: G + value: 1 +- expect-pin: + part-id: rgb led1 + pin: B + value: 0 +- expect-pin: + part-id: rgb led1 + pin: COM + value: 1 +version: 1.0 diff --git a/arduino/level1/led_RGB_basic/src/main.ino b/arduino/level1/led_RGB_basic/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..b6b2981b5804d86af203867a1529f86b725497f0 --- /dev/null +++ b/arduino/level1/led_RGB_basic/src/main.ino @@ -0,0 +1,21 @@ +/** + Turns on a RGB LED connected to a specified pin. + 3 APR 2025 by Blind Author +*/ + +const int R = 4; +const int G = 3; +const int B = 2; + +void setup() { + pinMode(R, OUTPUT); + pinMode(G, OUTPUT); + pinMode(B, OUTPUT); + + analogWrite(R, 255); + analogWrite(G, 255); + analogWrite(B, 0); +} + +void loop() { +} diff --git a/arduino/level1/led_RGB_basic/wokwi.toml b/arduino/level1/led_RGB_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level1/led_RGB_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level1/led_blink_basic/description.md b/arduino/level1/led_blink_basic/description.md new file mode 100644 index 0000000000000000000000000000000000000000..403ad28ed859932b2e74ce524351530cb1919ea3 --- /dev/null +++ b/arduino/level1/led_blink_basic/description.md @@ -0,0 +1,31 @@ +# Blink LED + +## Project Description +This is a simple Arduino project that makes an LED connected to a specific pin blink on and off at regular intervals. + +## Hardware Components +- Arduino Uno +- LED +- 220Ω resistor +- Breadboard + +## Circuit Description +The LED is connected to pin of the Arduino Uno through a 220Ω current-limiting resistor. The anode of the LED is connected to pin 13 via the resistor. The cathode of the LED is connected to gnd1. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Send a message "LED Blink test starts" to the serial monitor +3. Begin blinking the LED with the following pattern: + - Turn ON for 1 second + - Turn OFF for 1 second + - Repeat indefinitely + +## Success Criteria +The test is successful when: +1. The correct serial message is displayed +2. The LED turns on and off at regular 1-second intervals +3. The blinking pattern continues indefinitely + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level1/led_blink_basic/description_no_pin.md b/arduino/level1/led_blink_basic/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..0b06bd2ec6d741165f37e2bc0c8279db099af033 --- /dev/null +++ b/arduino/level1/led_blink_basic/description_no_pin.md @@ -0,0 +1,31 @@ +# Blink LED + +## Project Description +This is a simple Arduino project that makes an LED connected to a specific pin blink on and off at regular intervals. + +## Hardware Components +- Arduino Uno +- LED +- 220Ω resistor +- Breadboard + +## Circuit Description +The LED is connected to pin of the Arduino Uno through a 220Ω current-limiting resistor. The anode of the LED is connected to arduino digital pin via the resistor. The cathode of the LED is connected to ground. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Send a message "LED Blink test starts" to the serial monitor +3. Begin blinking the LED with the following pattern: + - Turn ON for 1 second + - Turn OFF for 1 second + - Repeat indefinitely + +## Success Criteria +The test is successful when: +1. The correct serial message is displayed +2. The LED turns on and off at regular 1-second intervals +3. The blinking pattern continues indefinitely + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level1/led_blink_basic/diagram.json b/arduino/level1/led_blink_basic/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..9fcfb0292afae8a4aafdf73ad5ff8a47b2b6c307 --- /dev/null +++ b/arduino/level1/led_blink_basic/diagram.json @@ -0,0 +1,57 @@ +{ + "version": 1, + "author": "Blind Author", + "editor": "Blind Author", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -201, + "left": 9, + "attrs": {} + }, + { + "type": "wokwi-led", + "id": "led1", + "top": -301.2, + "left": 51.8, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -245.65, + "left": 86.4, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "arduino uno1:13", + "resistor2:2", + "green", + [ + "v0" + ] + ], + [ + "resistor2:1", + "led1:A", + "green", + [ + "v0" + ] + ], + [ + "arduino uno1:GND.1", + "led1:C", + "black", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level1/led_blink_basic/diagram_breadboard.json b/arduino/level1/led_blink_basic/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..ee6ca681cf863fe71944207bed388e1bcd0a8050 --- /dev/null +++ b/arduino/level1/led_blink_basic/diagram_breadboard.json @@ -0,0 +1,95 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Turn on LED", + "config": { + "led_pin": 13, + "led_color": "red", + "gnd_pin": "GND.2" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -156.6, + "left": 2.8, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 120, + "left": 20, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -15.25, + "left": 163.2, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-led", + "id": "led1", + "top": -80.4, + "left": 138.2, + "attrs": { + "color": "red" + } + } + ], + "connections": [ + [ + "led1:A", + "breadboard1:15b.f", + "", + [ + "$bb" + ] + ], + [ + "led1:C", + "breadboard1:14b.f", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:15b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:21b.i", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:14b.i", + "arduino uno1:GND.2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:21b.j", + "arduino uno1:13", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level1/led_blink_basic/diagram_breadboard_shdf.json b/arduino/level1/led_blink_basic/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..4c1a0d0781f55d5869d04269cbff82ce4745db27 --- /dev/null +++ b/arduino/level1/led_blink_basic/diagram_breadboard_shdf.json @@ -0,0 +1,52 @@ +{ + "components": [ + { + "id": "bb", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "led1", + "type": "led", + "properties": { + "color": "red" + } + } + ], + "connections": [ + [ + "led1.a", + "bb.pin15b.f" + ], + [ + "led1.c", + "bb.pin14b.f" + ], + [ + "r1.1", + "bb.pin15b.i" + ], + [ + "r1.2", + "bb.pin21b.i" + ], + [ + "bb.pin14b.i", + "uno.gnd.2" + ], + [ + "bb.pin21b.j", + "uno.13" + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/led_blink_basic/diagram_shdf.json b/arduino/level1/led_blink_basic/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..19cb5ab4ed6aadca9fdb3ec260b0e73f6e39d494 --- /dev/null +++ b/arduino/level1/led_blink_basic/diagram_shdf.json @@ -0,0 +1,33 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "led", + "type": "led" + }, + { + "id": "r2", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + } + ], + "connections": [ + [ + "uno.13", + "r2.2" + ], + [ + "r2.1", + "led.a" + ], + [ + "uno.gnd.1", + "led.c" + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/led_blink_basic/platformio.ini b/arduino/level1/led_blink_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level1/led_blink_basic/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level1/led_blink_basic/scenario.yaml b/arduino/level1/led_blink_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4caaf0cb680634235938c6f274902214ef6f16fb --- /dev/null +++ b/arduino/level1/led_blink_basic/scenario.yaml @@ -0,0 +1,41 @@ +author: Blind Author +description: Blink LED connected to a specific Arduino pin +name: Blink LED +steps: +- delay: 10ms +- expect-pin: + part-id: led1 + pin: C + value: 0 +- expect-pin: + part-id: led1 + pin: A + value: 1 +- delay: 1000ms +- expect-pin: + part-id: led1 + pin: C + value: 0 +- expect-pin: + part-id: led1 + pin: A + value: 0 +- delay: 1000ms +- expect-pin: + part-id: led1 + pin: C + value: 0 +- expect-pin: + part-id: led1 + pin: A + value: 1 +- delay: 1000ms +- expect-pin: + part-id: led1 + pin: C + value: 0 +- expect-pin: + part-id: led1 + pin: A + value: 0 +version: 1.0 diff --git a/arduino/level1/led_blink_basic/src/main.ino b/arduino/level1/led_blink_basic/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..7baccc918b2ba0b6fbb87256ae2f4071f282f748 --- /dev/null +++ b/arduino/level1/led_blink_basic/src/main.ino @@ -0,0 +1,17 @@ +/** + Turns on an LED connected to a specified pin. + 31 MAR 2025 by Blind Author +*/ + +const int LED_PIN = 13; + +void setup() { + pinMode(LED_PIN, OUTPUT); +} + +void loop() { + digitalWrite(LED_PIN, HIGH); + delay(1000); + digitalWrite(LED_PIN, LOW); + delay(1000); +} \ No newline at end of file diff --git a/arduino/level1/led_blink_basic/wokwi.toml b/arduino/level1/led_blink_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level1/led_blink_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level1/photoresistor_basic/description.md b/arduino/level1/photoresistor_basic/description.md new file mode 100644 index 0000000000000000000000000000000000000000..509ceefb9966d46d21ccfbbdc4e2c8a6d22526b9 --- /dev/null +++ b/arduino/level1/photoresistor_basic/description.md @@ -0,0 +1,27 @@ +# Photoresistor + +## Project Description +This is a simple Arduino project that uses 4 pin photoresistoer sensor module to sense the light. + +## Hardware Components +- Arduino Uno +- Photoresistor sensor module + +## Circuit Description +The photoresistor sensor module is connected to the Arduino. The VCC pin is connected to 5V, the GND pin to gnd2, and the AO pin to a2. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Continuously read the photoresistor sensor module, and print the value in the format: "LDR Value: {value}". + +## Success Criteria +The test is successful when: +1. Correct LDR value is printed in the serial monitor. + +## Notes for Implementation +- In the loop function, read the photoresistor, and print it to the serial monitor. +- Delay 500ms in every loop. + +## Variants +There may be variants with init lux value and pin number. \ No newline at end of file diff --git a/arduino/level1/photoresistor_basic/description_no_pin.md b/arduino/level1/photoresistor_basic/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..7b3fce7c5bab268e7bebbf7169ace90258952847 --- /dev/null +++ b/arduino/level1/photoresistor_basic/description_no_pin.md @@ -0,0 +1,27 @@ +# Photoresistor + +## Project Description +This is a simple Arduino project that uses 4 pin photoresistoer sensor module to sense the light. + +## Hardware Components +- Arduino Uno +- Photoresistor sensor module + +## Circuit Description +The photoresistor sensor module is connected to the Arduino. The AO pin is connected to arduino digital pin. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Continuously read the photoresistor sensor module, and print the value in the format: "LDR Value: {value}". + +## Success Criteria +The test is successful when: +1. Correct LDR value is printed in the serial monitor. + +## Notes for Implementation +- In the loop function, read the photoresistor, and print it to the serial monitor. +- Delay 500ms in every loop. + +## Variants +There may be variants with init lux value and pin number. \ No newline at end of file diff --git a/arduino/level1/photoresistor_basic/diagram.json b/arduino/level1/photoresistor_basic/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..2741af7310173e643cbb1d7099a6ae5573aa8957 --- /dev/null +++ b/arduino/level1/photoresistor_basic/diagram.json @@ -0,0 +1 @@ +{"version": 1.0, "author": "Blind Author", "description": "Read value of photoresistor", "config": {"photoresistor_pin": "A2", "lux": "500", "gnd_pin": "GND.2"}, "parts": [{"type": "wokwi-arduino-uno", "id": "arduino uno1", "top": 87, "left": 47.4, "attrs": {}}, {"type": "wokwi-photoresistor-sensor", "id": "photoresistor1", "top": 3.2, "left": 96.8, "attrs": {"lux": "500"}}], "connections": [["photoresistor1:VCC", "arduino uno1:5V", "red", ["h76.8", "v115.2"]], ["photoresistor1:GND", "arduino uno1:GND.2", "black", ["h0"]], ["photoresistor1:AO", "arduino uno1:A2", "green", ["h0"]]], "dependencies": {}} \ No newline at end of file diff --git a/arduino/level1/photoresistor_basic/diagram_breadboard.json b/arduino/level1/photoresistor_basic/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..923ebcd5fe97f98d9f4b8bfaedbaae4b2776e4ca --- /dev/null +++ b/arduino/level1/photoresistor_basic/diagram_breadboard.json @@ -0,0 +1 @@ +{"version": 1.0, "author": "Blind Author", "description": "Read value of photoresistor", "config": {"photoresistor_pin": "A2", "lux_init": "500", "gnd_pin": "GND.2"}, "parts": [{"type": "wokwi-breadboard", "id": "breadboard1", "top": -137.4, "left": -26, "attrs": {}}, {"type": "wokwi-arduino-uno", "id": "arduino uno1", "top": 87, "left": 47.4, "attrs": {}}, {"type": "wokwi-photoresistor-sensor", "id": "photoresistor1", "top": -125.1, "left": 90.5, "rotate": 90, "attrs": {"lux": "500"}}], "connections": [["photoresistor1:VCC", "breadboard1:21b.g", "", ["$bb"]], ["photoresistor1:GND", "breadboard1:20b.g", "", ["$bb"]], ["photoresistor1:DO", "breadboard1:19b.g", "", ["$bb"]], ["photoresistor1:AO", "breadboard1:18b.g", "", ["$bb"]], ["breadboard1:21b.h", "arduino uno1:5V", "green", ["v0"]], ["breadboard1:20b.h", "arduino uno1:GND.2", "green", ["v0"]], ["breadboard1:18b.h", "arduino uno1:A2", "green", ["v0"]]], "dependencies": {}} \ No newline at end of file diff --git a/arduino/level1/photoresistor_basic/diagram_breadboard_shdf.json b/arduino/level1/photoresistor_basic/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..0395937ad0e13ebb6e422e2fb3d7ecbae8b614bf --- /dev/null +++ b/arduino/level1/photoresistor_basic/diagram_breadboard_shdf.json @@ -0,0 +1,46 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "ldr1", + "type": "photoresistor" + } + ], + "connections": [ + [ + "ldr1.vcc", + "bb1.pin21b.g" + ], + [ + "ldr1.gnd", + "bb1.pin20b.g" + ], + [ + "ldr1.do", + "bb1.pin19b.g" + ], + [ + "ldr1.ao", + "bb1.pin18b.g" + ], + [ + "bb1.pin21b.h", + "uno.5v" + ], + [ + "bb1.pin20b.h", + "uno.gnd.2" + ], + [ + "bb1.pin18b.h", + "uno.a2" + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/photoresistor_basic/diagram_shdf.json b/arduino/level1/photoresistor_basic/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..58f97d0f09886bdc6944d2f5efc0546d7de7deec --- /dev/null +++ b/arduino/level1/photoresistor_basic/diagram_shdf.json @@ -0,0 +1,26 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "ldr1", + "type": "photoresistor" + } + ], + "connections": [ + [ + "ldr1.vcc", + "uno.5v" + ], + [ + "ldr1.gnd", + "uno.gnd.2" + ], + [ + "ldr1.ao", + "uno.a2" + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/photoresistor_basic/platformio.ini b/arduino/level1/photoresistor_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level1/photoresistor_basic/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level1/photoresistor_basic/scenario.yaml b/arduino/level1/photoresistor_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c381b40eed9a538fbc750e38f91de2cec6b9cc30 --- /dev/null +++ b/arduino/level1/photoresistor_basic/scenario.yaml @@ -0,0 +1,11 @@ +author: Blind Author +description: Read value of photoresistor +name: Photoresistor +test-values: + - part-type: wokwi-photoresistor-sensor + attr-name: lux + value: "500" +steps: +- delay: 10ms +- wait-serial: 'LDR Value: 250' +version: 1.0 diff --git a/arduino/level1/photoresistor_basic/src/main.ino b/arduino/level1/photoresistor_basic/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..f45825d627a7c370d34245457f0a56828dcc31ed --- /dev/null +++ b/arduino/level1/photoresistor_basic/src/main.ino @@ -0,0 +1,17 @@ +/** + Read photoresistor value and write to serial monitor + 2 APR 2025 by Blind Author +*/ + +#define LDR_PIN A2 + +void setup() { + Serial.begin(9600); +} + +void loop() { + int ldrValue = analogRead(LDR_PIN); + Serial.print("LDR Value: "); + Serial.println(ldrValue); + delay(500); +} diff --git a/arduino/level1/photoresistor_basic/wokwi.toml b/arduino/level1/photoresistor_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level1/photoresistor_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level1/servo_motor_basic/description.md b/arduino/level1/servo_motor_basic/description.md new file mode 100644 index 0000000000000000000000000000000000000000..205888137de73a721f299fbc69271eb2cc8d55a7 --- /dev/null +++ b/arduino/level1/servo_motor_basic/description.md @@ -0,0 +1,32 @@ +# Servo Motor Control + +## Project Description +This is a simple Arduino project that uses servo motor. + +## Hardware Components +- Arduino Uno +- Servo Motor + +## Circuit Description +The servo motor is connected to the Arduino. The V+ pin is connected to 5V, the GND pin to gnd1, PWM to pin 9. + +## Expected Behavior +When the Arduino powers up, it should: +1. Attach servo motor to pin 9 +2. Move the servo from 0 to 180 degrees in 1-degree steps +3. When the moving is finished, print the current servo position to the serial monitor by reading the servo position. +4. Move the servo from 180 to 0 degrees in 1-degree steps +5. When the moving is finished, print the current servo position to the serial monitor by reading the servo position. +6. Repeat 3~6 process. + +## Success Criteria +The test is successful when: +1. The servo motor moves correctly. +2. Correct position is printed to the serial monitor. + +## Notes for Implementation +- Use Servo library to use the servo motor. +- Print only the number when printing the angle. + +## Variants +There may be variants with GND pin, PWM pin. \ No newline at end of file diff --git a/arduino/level1/servo_motor_basic/description_no_pin.md b/arduino/level1/servo_motor_basic/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..f46bb28acbe3ff331721d94174489a071f84dd29 --- /dev/null +++ b/arduino/level1/servo_motor_basic/description_no_pin.md @@ -0,0 +1,32 @@ +# Servo Motor Control + +## Project Description +This is a simple Arduino project that uses servo motor. + +## Hardware Components +- Arduino Uno +- Servo Motor + +## Circuit Description +The servo motor is connected to the Arduino. The PWM is connected to arduino digital pin. + +## Expected Behavior +When the Arduino powers up, it should: +1. Attach servo motor to digital pin +2. Move the servo from 0 to 180 degrees in 1-degree steps +3. When the moving is finished, print the current servo position to the serial monitor by reading the servo position. +4. Move the servo from 180 to 0 degrees in 1-degree steps +5. When the moving is finished, print the current servo position to the serial monitor by reading the servo position. +6. Repeat 3~6 process. + +## Success Criteria +The test is successful when: +1. The servo motor moves correctly. +2. Correct position is printed to the serial monitor. + +## Notes for Implementation +- Use Servo library to use the servo motor. +- Print only the number when printing the angle. + +## Variants +There may be variants with GND pin, PWM pin. \ No newline at end of file diff --git a/arduino/level1/servo_motor_basic/diagram.json b/arduino/level1/servo_motor_basic/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..5874ded889716a50e077a67604ea0038cd03ac18 --- /dev/null +++ b/arduino/level1/servo_motor_basic/diagram.json @@ -0,0 +1,58 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Servo motor", + "parts": [ + { + "id": "arduino uno1", + "type": "wokwi-arduino-uno", + "top": 200, + "left": 20 + }, + { + "id": "servo motor1", + "type": "wokwi-servo", + "left": 400, + "top": 200, + "attrs": { + "hornColor": "black" + }, + "rotate": 0 + } + ], + "connections": [ + [ + "arduino uno1:9", + "servo motor1:PWM", + "orange", + [ + "v-20", + "*", + "h0", + "h-52" + ] + ], + [ + "arduino uno1:5V", + "servo motor1:V+", + "red", + [ + "v20", + "h0", + "*", + "h-20" + ] + ], + [ + "arduino uno1:GND.1", + "servo motor1:GND", + "black", + [ + "v-28", + "h240", + "*", + "h-20" + ] + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/servo_motor_basic/diagram_breadboard.json b/arduino/level1/servo_motor_basic/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..43a9a887e852a17c87aa1fda7a398cea1c1f8312 --- /dev/null +++ b/arduino/level1/servo_motor_basic/diagram_breadboard.json @@ -0,0 +1 @@ +{"version": 1.0, "author": "Blind Author", "description": "Servo motor", "parts": [{"type": "wokwi-breadboard", "id": "breadboard1", "top": -51, "left": 12.4, "attrs": {}}, {"type": "wokwi-arduino-uno", "id": "arduino uno1", "top": 200, "left": 20, "attrs": {}}, {"type": "wokwi-servo", "id": "servo motor1", "top": 199.6, "left": 489.6, "attrs": {"hornColor": "black"}}], "connections": [["arduino uno1:GND.1", "breadboard1:bn.10", "black", ["v0"]], ["breadboard1:bn.11", "servo motor1:GND", "green", ["v0"]], ["arduino uno1:5V", "breadboard1:bp.14", "red", ["v0"]], ["breadboard1:bp.16", "servo motor1:V+", "green", ["v0"]], ["arduino uno1:9", "breadboard1:16b.i", "green", ["v0"]], ["breadboard1:16b.h", "servo motor1:PWM", "green", ["v0"]]], "dependencies": {}} \ No newline at end of file diff --git a/arduino/level1/servo_motor_basic/diagram_breadboard_shdf.json b/arduino/level1/servo_motor_basic/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..8ed733c50d2b0e7b06871d9bfbe6f3d0faf123ad --- /dev/null +++ b/arduino/level1/servo_motor_basic/diagram_breadboard_shdf.json @@ -0,0 +1,42 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "servo", + "type": "servo motor" + } + ], + "connections": [ + [ + "uno.gnd.1", + "bb1.bn.10" + ], + [ + "bb1.bn.11", + "servo.gnd" + ], + [ + "uno.5v", + "bb1.bp.14" + ], + [ + "bb1.bp.16", + "servo.v+" + ], + [ + "uno.9", + "bb1.pin16b.i" + ], + [ + "bb1.pin16b.h", + "servo.pwm" + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/servo_motor_basic/diagram_shdf.json b/arduino/level1/servo_motor_basic/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..d5e175378020a56351c63bc05e889dc0104e5d2f --- /dev/null +++ b/arduino/level1/servo_motor_basic/diagram_shdf.json @@ -0,0 +1,26 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "servo", + "type": "servo motor" + } + ], + "connections": [ + [ + "uno.9", + "servo.pwm" + ], + [ + "uno.5v", + "servo.v+" + ], + [ + "uno.gnd.1", + "servo.gnd" + ] + ] +} \ No newline at end of file diff --git a/arduino/level1/servo_motor_basic/platformio.ini b/arduino/level1/servo_motor_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..2033d8801bf6e9e5c685f82885d2aa139c33b31f --- /dev/null +++ b/arduino/level1/servo_motor_basic/platformio.ini @@ -0,0 +1,21 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Servo + Arduino \ No newline at end of file diff --git a/arduino/level1/servo_motor_basic/scenario.yaml b/arduino/level1/servo_motor_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..055c665095fce515d257a13127d6941fe1bb2db3 --- /dev/null +++ b/arduino/level1/servo_motor_basic/scenario.yaml @@ -0,0 +1,46 @@ +author: Blind Author +description: Control a servo motor +name: Servo Motor Control +steps: +- delay: 100ms +- expect-pin: + part-id: servo motor1 + pin: PWM + value: 0 +- expect-pin: + part-id: servo motor1 + pin: V+ + value: 1 +- expect-pin: + part-id: servo motor1 + pin: GND + value: 0 +- wait-pin: + timeout: 5000 + interval: 10 + part-id: servo motor1 + pin: PWM + value: 1 +- wait-serial: '180' +- wait-pin: + timeout: 5000 + interval: 10 + part-id: servo motor1 + pin: PWM + value: 1 +- wait-serial: '0' +- wait-pin: + timeout: 5000 + interval: 10 + part-id: servo motor1 + pin: PWM + value: 1 +- wait-serial: '180' +- wait-pin: + timeout: 5000 + interval: 10 + part-id: servo motor1 + pin: PWM + value: 1 +- wait-serial: '0' +version: 1.0 diff --git a/arduino/level1/servo_motor_basic/src/main.ino b/arduino/level1/servo_motor_basic/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..b1192142ac67ecf87bc084af3ef746c0f2add7f1 --- /dev/null +++ b/arduino/level1/servo_motor_basic/src/main.ino @@ -0,0 +1,33 @@ +/* + Control servo motor + 31 Mar 2025 by Blind Author +*/ + +#include + +Servo myservo; + +int pos = 0; + +void setup() { + Serial.begin(9600); + Serial.println("Servo Motor Control test starts"); + myservo.attach(9); +} + +void loop() { + for (pos = 0; pos <= 180; pos += 1) { + myservo.write(pos); + delay(10); + } + + Serial.println(myservo.read()); + + for (pos = 180; pos >= 0; pos -= 1) { + myservo.write(pos); + delay(10); + } + + Serial.println(myservo.read()); +} + diff --git a/arduino/level1/servo_motor_basic/wokwi.toml b/arduino/level1/servo_motor_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level1/servo_motor_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level1/temperature_sensor_basic/description.md b/arduino/level1/temperature_sensor_basic/description.md new file mode 100644 index 0000000000000000000000000000000000000000..7153b62df0ea79fc8326b1f08db3f65f5f40a43b --- /dev/null +++ b/arduino/level1/temperature_sensor_basic/description.md @@ -0,0 +1,24 @@ +# Temperature Sensor Basic + +## Project Description +This is a simple Arduino project that uses dht22 sensor to measure the temperature. + +## Hardware Components +- Arduino Uno +- DHT22 sensor + +## Circuit Description +The DHT22 sensor is connected to an Arduino Uno. The VCC pin is connected to the 5V pin on the Arduino, and the GND pin is connected to the GND2 pin. The data pin is connected to digital pin 2 on the Arduino. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial monitor +2. Initialize and begin DHT sensor +3. Continuously read the DHT sensor's temperature value +4. Print temperature to the serial monitor in the following format: "Current temperature: {temperature value}", for example: "Current temperature: 40" + +## Success Criteria +The test is successful when: +1. Correct temperature value in celsius is printed in the serial monitor. + +## Notes for Implementation \ No newline at end of file diff --git a/arduino/level1/temperature_sensor_basic/description_no_pin.md b/arduino/level1/temperature_sensor_basic/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..a44366216b524df3003e635f92586d9402c9b949 --- /dev/null +++ b/arduino/level1/temperature_sensor_basic/description_no_pin.md @@ -0,0 +1,24 @@ +# Temperature Sensor Basic + +## Project Description +This is a simple Arduino project that uses dht22 sensor to measure the temperature. + +## Hardware Components +- Arduino Uno +- DHT22 sensor + +## Circuit Description +The DHT22 sensor is connected to an Arduino Uno. The data pin is connected to digital pin on the Arduino. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial monitor +2. Initialize and begin DHT sensor +3. Continuously read the DHT sensor's temperature value +4. Print temperature to the serial monitor in the following format: "Current temperature: {temperature value}", for example: "Current temperature: 40" + +## Success Criteria +The test is successful when: +1. Correct temperature value in celsius is printed in the serial monitor. + +## Notes for Implementation \ No newline at end of file diff --git a/arduino/level1/temperature_sensor_basic/diagram.json b/arduino/level1/temperature_sensor_basic/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..618a2605a2ac47104e1cafe5e0bc7c8b747f823b --- /dev/null +++ b/arduino/level1/temperature_sensor_basic/diagram.json @@ -0,0 +1,57 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read temperature sensor value", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-dht22", + "id": "dht22 sensor1", + "top": -201.3, + "left": 100.2, + "attrs": { + "humidity": "64.5" + } + } + ], + "connections": [ + [ + "dht22 sensor1:VCC", + "arduino uno1:5V", + "red", + [ + "v48", + "h-134.4", + "v259.2", + "h182.4" + ] + ], + [ + "dht22 sensor1:GND", + "arduino uno1:GND.2", + "black", + [ + "v48", + "h144", + "v268.8", + "h19.2" + ] + ], + [ + "dht22 sensor1:SDA", + "arduino uno1:2", + "green", + [ + "v76.8", + "h115.3" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level1/temperature_sensor_basic/diagram_breadboard.json b/arduino/level1/temperature_sensor_basic/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..d818b24aa9d8a3859b7c0ced81033d79de371eb1 --- /dev/null +++ b/arduino/level1/temperature_sensor_basic/diagram_breadboard.json @@ -0,0 +1,109 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read temperature sensor value", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -223.8, + "left": -93.2, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-dht22", + "id": "dht22 sensor1", + "top": -210.9, + "left": 100.2, + "attrs": { + "humidity": "64.5" + } + } + ], + "connections": [ + [ + "dht22 sensor1:VCC", + "breadboard1:20b.g", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:SDA", + "breadboard1:21b.g", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:NC", + "breadboard1:22b.g", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:GND", + "breadboard1:23b.g", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:20b.h", + "breadboard1:bp.16", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:21b.h", + "arduino uno1:2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:23b.h", + "breadboard1:bn.18", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:bn.1", + "arduino uno1:GND.2", + "green", + [ + "v238.7", + "h210.4" + ] + ], + [ + "breadboard1:bp.1", + "arduino uno1:5V", + "green", + [ + "v-0.9", + "h-20", + "v259.2", + "h230.4" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level1/temperature_sensor_basic/platformio.ini b/arduino/level1/temperature_sensor_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..598164a9e2d3c7598b562fda5974537e4ca29102 --- /dev/null +++ b/arduino/level1/temperature_sensor_basic/platformio.ini @@ -0,0 +1,22 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + DHT sensor library + DHT22 \ No newline at end of file diff --git a/arduino/level1/temperature_sensor_basic/scenario.yaml b/arduino/level1/temperature_sensor_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1c2cce6ce9a1b1f14c704ccc0827d32ee030fea7 --- /dev/null +++ b/arduino/level1/temperature_sensor_basic/scenario.yaml @@ -0,0 +1,11 @@ +author: Blind Author +description: Measure distance with Ultrasonic distance sensor +name: Distance Sensor +test-values: + - part-type: wokwi-ntc-temperature-sensor + attr-name: temperature + value: "24" +steps: + - delay: 10ms + - wait-serial: 'Current temperature: 24' +version: 1.0 diff --git a/arduino/level1/temperature_sensor_basic/src/main.ino b/arduino/level1/temperature_sensor_basic/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..b8e717ab160a3eb7e5240194a4baac659406cc77 --- /dev/null +++ b/arduino/level1/temperature_sensor_basic/src/main.ino @@ -0,0 +1,30 @@ +/** + Measure temperature with analog temperature sensor. + 3 APR 2025 by Blind Author +*/ + +#include "DHT.h" + +#define DHTPIN 2 +#define DHTTYPE DHT22 + +DHT dht(DHTPIN, DHTTYPE); + +void setup() { + Serial.begin(9600); + dht.begin(); +} + +void loop() { + delay(2000); + + float temperature = dht.readTemperature(); + + if (isnan(temperature)) { + Serial.println("Failed to read from DHT sensor!"); + return; + } + + Serial.print("Current temperature: "); + Serial.println(temperature); +} diff --git a/arduino/level1/temperature_sensor_basic/wokwi.toml b/arduino/level1/temperature_sensor_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level1/temperature_sensor_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level2/7_segment_display_counter/description.md b/arduino/level2/7_segment_display_counter/description.md new file mode 100644 index 0000000000000000000000000000000000000000..fddcff1188d6428f74fe509a9c2814191af622fa --- /dev/null +++ b/arduino/level2/7_segment_display_counter/description.md @@ -0,0 +1,28 @@ +# One Digit 7-segment Display Counter + +## Project Description +This is an Arduino project that show a counter with digit 7-segment display. + +## Hardware Components +- Arduino Uno +- 330Ω resistor * 8 +- 7-segment display + +## Circuit Description +Circuit is designed to use a 7-segment display. The 7-segment display is a common anode type, so the common pin is connected to 5V. The A to G and DP pins are connected to Arduino digital pins 2 to 9 through 330-ohm resistors. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set 2~9 pin as an output. +2. Taking into account that the display is common anode, set the corresponding pins to HIGH or LOW so that the elapsed time in seconds is shown on the 7-segment display. + +## Success Criteria +The test is successful when: +1. The numbers 1, 2, and 3 appear according to the elapsed seconds. + +## Notes for Implementation +- The 7-segment display is a common anode type. +- Display 1 between 1–2 seconds, 2 between 2–3 seconds, and 3 between 3–4 seconds. + +## Variants +This project may have different variants with the segment pins connected to the different pins. \ No newline at end of file diff --git a/arduino/level2/7_segment_display_counter/description_no_pin.md b/arduino/level2/7_segment_display_counter/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..6fd0d4d37f461fb78e5db5ed3f670caab200de09 --- /dev/null +++ b/arduino/level2/7_segment_display_counter/description_no_pin.md @@ -0,0 +1,28 @@ +# One Digit 7-segment Display Counter + +## Project Description +This is an Arduino project that show a counter with digit 7-segment display. + +## Hardware Components +- Arduino Uno +- 330Ω resistor * 8 +- 7-segment display + +## Circuit Description +Circuit is designed to use a 7-segment display. The 7-segment display is a common anode type. The A to G and DP pins are connected to Arduino digital pins through 330-ohm resistors. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set segment pins as an output. +2. Taking into account that the display is common anode, set the corresponding pins to HIGH or LOW so that the elapsed time in seconds is shown on the 7-segment display. + +## Success Criteria +The test is successful when: +1. The numbers 1, 2, and 3 appear according to the elapsed seconds. + +## Notes for Implementation +- The 7-segment display is a common anode type. +- Display 1 between 1–2 seconds, 2 between 2–3 seconds, and 3 between 3–4 seconds. + +## Variants +This project may have different variants with the segment pins connected to the different pins. \ No newline at end of file diff --git a/arduino/level2/7_segment_display_counter/diagram.json b/arduino/level2/7_segment_display_counter/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..2452874c0d411705e210d6ccac84e25505c271bd --- /dev/null +++ b/arduino/level2/7_segment_display_counter/diagram.json @@ -0,0 +1,242 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Use one digit 7-segment display", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-7segment", + "id": "7-segment display1", + "top": 24.18, + "left": 408.28, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 128.75, + "left": 451.2, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -15.25, + "left": 451.2, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 109.55, + "left": 441.6, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 128.75, + "left": 355.2, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": 109.55, + "left": 364.8, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -15.25, + "left": 345.6, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": 3.95, + "left": 364.8, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": 3.95, + "left": 441.6, + "attrs": { + "value": "330" + } + } + ], + "connections": [ + [ + "7-segment display1:F", + "resistor7:2", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:A", + "resistor8:1", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:G", + "resistor6:2", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:B", + "resistor2:1", + "green", + [ + "v0" + ] + ], + [ + "resistor5:2", + "7-segment display1:D", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:C", + "resistor3:1", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:E", + "resistor4:2", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:DP", + "resistor1:1", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:COM.1", + "arduino uno1:5V", + "green", + [ + "h0", + "v124.8" + ] + ], + [ + "resistor8:2", + "arduino uno1:2", + "green", + [ + "v-19.2", + "h-260.4" + ] + ], + [ + "resistor2:2", + "arduino uno1:3", + "green", + [ + "v-9.6", + "h-279.6" + ] + ], + [ + "resistor3:2", + "arduino uno1:4", + "green", + [ + "v0", + "h27.6", + "v-144", + "h-307.2" + ] + ], + [ + "resistor5:1", + "arduino uno1:5", + "green", + [ + "v-153.6", + "h-153.6" + ] + ], + [ + "resistor4:1", + "arduino uno1:6", + "green", + [ + "v-182.4", + "h-153.6" + ] + ], + [ + "resistor7:1", + "arduino uno1:7", + "green", + [ + "v-67.2", + "h-172.8" + ] + ], + [ + "resistor6:1", + "arduino uno1:8", + "green", + [ + "v-57.6", + "h-172.8" + ] + ], + [ + "resistor1:2", + "arduino uno1:9", + "green", + [ + "v-211.2", + "h-346.8" + ] + ] + ] +} \ No newline at end of file diff --git a/arduino/level2/7_segment_display_counter/diagram_breadboard.json b/arduino/level2/7_segment_display_counter/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..fbc2cb0839292f885a433da678f0a918a88070c5 --- /dev/null +++ b/arduino/level2/7_segment_display_counter/diagram_breadboard.json @@ -0,0 +1,399 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Use one digit 7-segment display", + "config": { + "button_pin": 4, + "gnd_pin": "GND.3" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -127.8, + "left": 338.8, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 115.8, + "left": 527.4, + "attrs": {} + }, + { + "type": "wokwi-7segment", + "id": "7-segment display1", + "top": -62.22, + "left": 629.08, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 23.15, + "left": 672, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -72.85, + "left": 662.4, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 13.55, + "left": 662.4, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 23.15, + "left": 576, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": 13.55, + "left": 585.6, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -82.45, + "left": 576, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": -72.85, + "left": 585.6, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": -82.45, + "left": 672, + "attrs": { + "value": "330" + } + } + ], + "connections": [ + [ + "7-segment display1:COM.1", + "breadboard1:31b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:COM.2", + "breadboard1:31t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:A", + "breadboard1:32t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:B", + "breadboard1:33t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:C", + "breadboard1:32b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:D", + "breadboard1:30b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:E", + "breadboard1:29b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:F", + "breadboard1:30t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:G", + "breadboard1:29t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:DP", + "breadboard1:33b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:33b.j", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:39b.j", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:32t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:38t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:32b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:38b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor4:1", + "breadboard1:23b.j", + "", + [ + "$bb" + ] + ], + [ + "resistor4:2", + "breadboard1:29b.j", + "", + [ + "$bb" + ] + ], + [ + "resistor5:1", + "breadboard1:24b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor5:2", + "breadboard1:30b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor6:1", + "breadboard1:23t.a", + "", + [ + "$bb" + ] + ], + [ + "resistor6:2", + "breadboard1:29t.a", + "", + [ + "$bb" + ] + ], + [ + "resistor7:1", + "breadboard1:24t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor7:2", + "breadboard1:30t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor8:1", + "breadboard1:33t.a", + "", + [ + "$bb" + ] + ], + [ + "resistor8:2", + "breadboard1:39t.a", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:38t.d", + "arduino uno1:2", + "green", + [ + "v134.4", + "h48" + ] + ], + [ + "breadboard1:39t.d", + "arduino uno1:3", + "green", + [ + "v144", + "h19.2" + ] + ], + [ + "breadboard1:38b.g", + "arduino uno1:4", + "green", + [ + "v105.6", + "h28.8" + ] + ], + [ + "breadboard1:24b.g", + "arduino uno1:5", + "green", + [ + "v0", + "h-57.6", + "v76.8", + "h201.6" + ] + ], + [ + "breadboard1:23b.h", + "arduino uno1:6", + "green", + [ + "v0", + "h-38.4", + "v76.8", + "h182.4" + ] + ], + [ + "breadboard1:24t.d", + "arduino uno1:7", + "green", + [ + "v144", + "h124.8" + ] + ], + [ + "breadboard1:23t.d", + "arduino uno1:8", + "green", + [ + "v153.6", + "h124.8" + ] + ], + [ + "breadboard1:39b.h", + "arduino uno1:9", + "green", + [ + "v38.4", + "h-38.4" + ] + ], + [ + "breadboard1:31b.j", + "arduino uno1:5V", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/7_segment_display_counter/diagram_breadboard_shdf.json b/arduino/level2/7_segment_display_counter/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..ea1ce66bc88f27b19e335f7033e2808c1caba741 --- /dev/null +++ b/arduino/level2/7_segment_display_counter/diagram_breadboard_shdf.json @@ -0,0 +1,214 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "sevseg1", + "type": "7-segment display" + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r2", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r3", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r4", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r5", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r6", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r7", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r8", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + } + ], + "connections": [ + [ + "sevseg1.com.1", + "bb1.pin31b.h" + ], + [ + "sevseg1.com.2", + "bb1.pin31t.c" + ], + [ + "sevseg1.a", + "bb1.pin32t.c" + ], + [ + "sevseg1.b", + "bb1.pin33t.c" + ], + [ + "sevseg1.c", + "bb1.pin32b.h" + ], + [ + "sevseg1.d", + "bb1.pin30b.h" + ], + [ + "sevseg1.e", + "bb1.pin29b.h" + ], + [ + "sevseg1.f", + "bb1.pin30t.c" + ], + [ + "sevseg1.g", + "bb1.pin29t.c" + ], + [ + "sevseg1.dp", + "bb1.pin33b.h" + ], + [ + "r1.1", + "bb1.pin33b.j" + ], + [ + "r1.2", + "bb1.pin39b.j" + ], + [ + "r2.1", + "bb1.pin32t.b" + ], + [ + "r2.2", + "bb1.pin38t.b" + ], + [ + "r3.1", + "bb1.pin32b.i" + ], + [ + "r3.2", + "bb1.pin38b.i" + ], + [ + "r4.1", + "bb1.pin23b.j" + ], + [ + "r4.2", + "bb1.pin29b.j" + ], + [ + "r5.1", + "bb1.pin24b.i" + ], + [ + "r5.2", + "bb1.pin30b.i" + ], + [ + "r6.1", + "bb1.pin23t.a" + ], + [ + "r6.2", + "bb1.pin29t.a" + ], + [ + "r7.1", + "bb1.pin24t.b" + ], + [ + "r7.2", + "bb1.pin30t.b" + ], + [ + "r8.1", + "bb1.pin33t.a" + ], + [ + "r8.2", + "bb1.pin39t.a" + ], + [ + "bb1.pin38t.d", + "uno.2" + ], + [ + "bb1.pin39t.d", + "uno.3" + ], + [ + "bb1.pin38b.g", + "uno.4" + ], + [ + "bb1.pin24b.g", + "uno.5" + ], + [ + "bb1.pin23b.h", + "uno.6" + ], + [ + "bb1.pin24t.d", + "uno.7" + ], + [ + "bb1.pin23t.d", + "uno.8" + ], + [ + "bb1.pin39b.h", + "uno.9" + ], + [ + "bb1.pin31b.j", + "uno.5v" + ] + ] +} \ No newline at end of file diff --git a/arduino/level2/7_segment_display_counter/diagram_shdf.json b/arduino/level2/7_segment_display_counter/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..4ee472d9c581b65e0b50aaa3ba1508687eebdd94 --- /dev/null +++ b/arduino/level2/7_segment_display_counter/diagram_shdf.json @@ -0,0 +1,138 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "sevseg1", + "type": "7-segment display" + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r2", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r3", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r4", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r5", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r6", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r7", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r8", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + } + ], + "connections": [ + [ + "sevseg1.f", + "r7.2" + ], + [ + "sevseg1.a", + "r8.1" + ], + [ + "sevseg1.g", + "r6.2" + ], + [ + "sevseg1.b", + "r2.1" + ], + [ + "r5.2", + "sevseg1.d" + ], + [ + "sevseg1.c", + "r3.1" + ], + [ + "sevseg1.e", + "r4.2" + ], + [ + "sevseg1.dp", + "r1.1" + ], + [ + "sevseg1.com.1", + "uno.5v" + ], + [ + "r8.2", + "uno.2" + ], + [ + "r2.2", + "uno.3" + ], + [ + "r3.2", + "uno.4" + ], + [ + "r5.1", + "uno.5" + ], + [ + "r4.1", + "uno.6" + ], + [ + "r7.1", + "uno.7" + ], + [ + "r6.1", + "uno.8" + ], + [ + "r1.2", + "uno.9" + ] + ] +} \ No newline at end of file diff --git a/arduino/level2/7_segment_display_counter/platformio.ini b/arduino/level2/7_segment_display_counter/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level2/7_segment_display_counter/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level2/7_segment_display_counter/scenario.yaml b/arduino/level2/7_segment_display_counter/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..886b14d534de869eaa1d746a55b483aca073d657 --- /dev/null +++ b/arduino/level2/7_segment_display_counter/scenario.yaml @@ -0,0 +1,101 @@ +author: Blind Author +description: Determine how long a switch is pressed +name: One Digit 7-segment Display Counter +steps: +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + interval: 200 + pins: + - part-id: 7-segment display1 + pin: COM + value: 1 + - part-id: 7-segment display1 + pin: A + value: 1 + - part-id: 7-segment display1 + pin: B + value: 0 + - part-id: 7-segment display1 + pin: C + value: 0 + - part-id: 7-segment display1 + pin: D + value: 1 + - part-id: 7-segment display1 + pin: E + value: 1 + - part-id: 7-segment display1 + pin: F + value: 1 + - part-id: 7-segment display1 + pin: G + value: 1 + - part-id: 7-segment display1 + pin: DP + value: 1 +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + interval: 200 + pins: + - part-id: 7-segment display1 + pin: COM + value: 1 + - part-id: 7-segment display1 + pin: A + value: 0 + - part-id: 7-segment display1 + pin: B + value: 0 + - part-id: 7-segment display1 + pin: C + value: 1 + - part-id: 7-segment display1 + pin: D + value: 0 + - part-id: 7-segment display1 + pin: E + value: 0 + - part-id: 7-segment display1 + pin: F + value: 1 + - part-id: 7-segment display1 + pin: G + value: 0 + - part-id: 7-segment display1 + pin: DP + value: 1 +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + interval: 200 + pins: + - part-id: 7-segment display1 + pin: COM + value: 1 + - part-id: 7-segment display1 + pin: A + value: 0 + - part-id: 7-segment display1 + pin: B + value: 0 + - part-id: 7-segment display1 + pin: C + value: 0 + - part-id: 7-segment display1 + pin: D + value: 0 + - part-id: 7-segment display1 + pin: E + value: 1 + - part-id: 7-segment display1 + pin: F + value: 1 + - part-id: 7-segment display1 + pin: G + value: 0 + - part-id: 7-segment display1 + pin: DP + value: 1 +version: 1.0 diff --git a/arduino/level2/7_segment_display_counter/src/main.ino b/arduino/level2/7_segment_display_counter/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..c8edc9b3a1a954ca585fc279b786aea57fd8e1d4 --- /dev/null +++ b/arduino/level2/7_segment_display_counter/src/main.ino @@ -0,0 +1,62 @@ +/** + Use one digit 7-segment display to make a counter + 7 APR 2025 by Blind Author +*/ + +const int segA = 2; +const int segB = 3; +const int segC = 4; +const int segD = 5; +const int segE = 6; +const int segF = 7; +const int segG = 8; +const int segDP = 9; + +unsigned long startTime; + +void setup() { + pinMode(segA, OUTPUT); + pinMode(segB, OUTPUT); + pinMode(segC, OUTPUT); + pinMode(segD, OUTPUT); + pinMode(segE, OUTPUT); + pinMode(segF, OUTPUT); + pinMode(segG, OUTPUT); + pinMode(segDP, OUTPUT); + + startTime = millis(); +} + +void loop() { + unsigned long currentTime = millis() - startTime; + + if (currentTime >= 1000 && currentTime < 2000) { + digitalWrite(segA, HIGH); + digitalWrite(segB, LOW); + digitalWrite(segC, LOW); + digitalWrite(segD, HIGH); + digitalWrite(segE, HIGH); + digitalWrite(segF, HIGH); + digitalWrite(segG, HIGH); + digitalWrite(segDP, HIGH); + } else if (currentTime >= 2000 && currentTime < 3000) { + digitalWrite(segA, LOW); + digitalWrite(segB, LOW); + digitalWrite(segC, HIGH); + digitalWrite(segD, LOW); + digitalWrite(segE, LOW); + digitalWrite(segF, HIGH); + digitalWrite(segG, LOW); + digitalWrite(segDP, HIGH); + } else if (currentTime >= 3000 && currentTime < 4000) { + digitalWrite(segA, LOW); + digitalWrite(segB, LOW); + digitalWrite(segC, LOW); + digitalWrite(segD, LOW); + digitalWrite(segE, HIGH); + digitalWrite(segF, HIGH); + digitalWrite(segG, LOW); + digitalWrite(segDP, HIGH); + } +} + diff --git a/arduino/level2/7_segment_display_counter/wokwi.toml b/arduino/level2/7_segment_display_counter/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level2/7_segment_display_counter/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level2/accelerometer/description.md b/arduino/level2/accelerometer/description.md new file mode 100644 index 0000000000000000000000000000000000000000..c9499d12a26160056f483d255b2cb085be0ef208 --- /dev/null +++ b/arduino/level2/accelerometer/description.md @@ -0,0 +1,30 @@ +# Accelerometer + +## Project Description +This is an Arduino project that uses MPU6050 6-axis accelerometer & gyro sensor to measure the acceleration. + +## Hardware Components +- Arduino Uno +- MPU6050 6-axis Accel & Gyro Sensor + +## Circuit Description +The MPU6050 sensor is connected to the Arduino. The VCC pin is connected to 3.3V, the GND pin to gnd3, the SCL pin to A5, and the SDA pin to A4. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Check if the MPU sensor can be initialized successfully, and print 'MPU6050 ready!' to the serial monitor +3. Continuously read the accelerometer data from the MPU6050 sensor +4. Print the X, Y, and Z axis acceleration values in m/s² to the serial monitor, for example: 'X: 2.45, Y: 1.96, Z: 3.43 m/s^2' + +## Success Criteria +The test is successful when: +1. Correct X, Y, Z accelerometer result is printed to the serial monitor. + +## Notes for Implementation +- Use Adafruit_MPU6050.h, Adafruit_Sensor.h, Wire.h libraries. +- Delay 500ms in every loop. +- MPU6050 has I2C interface. + +## Variants +There may be variants with GND connected to different pin. \ No newline at end of file diff --git a/arduino/level2/accelerometer/description_no_pin.md b/arduino/level2/accelerometer/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..0fbe9780c51d2d4b7d9aa7fed6d0f298eaeceb62 --- /dev/null +++ b/arduino/level2/accelerometer/description_no_pin.md @@ -0,0 +1,30 @@ +# Accelerometer + +## Project Description +This is an Arduino project that uses MPU6050 6-axis accelerometer & gyro sensor to measure the acceleration. + +## Hardware Components +- Arduino Uno +- MPU6050 6-axis Accel & Gyro Sensor + +## Circuit Description +The MPU6050 sensor is connected to the Arduino. It follows the standard wiring conventions defined by the I2C protocol. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Check if the MPU sensor can be initialized successfully, and print 'MPU6050 ready!' to the serial monitor +3. Continuously read the accelerometer data from the MPU6050 sensor +4. Print the X, Y, and Z axis acceleration values in m/s² to the serial monitor, for example: 'X: 2.45, Y: 1.96, Z: 3.43 m/s^2' + +## Success Criteria +The test is successful when: +1. Correct X, Y, Z accelerometer result is printed to the serial monitor. + +## Notes for Implementation +- Use Adafruit_MPU6050.h, Adafruit_Sensor.h, Wire.h libraries. +- Delay 500ms in every loop. +- MPU6050 has I2C interface. + +## Variants +There may be variants with GND connected to different pin. \ No newline at end of file diff --git a/arduino/level2/accelerometer/diagram.json b/arduino/level2/accelerometer/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..862c8c9c3638b78ca53aa9d92e170d41828c17cd --- /dev/null +++ b/arduino/level2/accelerometer/diagram.json @@ -0,0 +1,65 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read value of MPU6050", + "config": { + "scl_pin": "A5", + "sda_pin": "A4", + "gnd_pin": "GND.3" + }, + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-mpu6050", + "id": "mpu6050 6-axis accel & gyro sensor1", + "top": 234.22, + "left": 117.52, + "attrs": {} + } + ], + "connections": [ + [ + "arduino uno1:GND.2", + "mpu6050 6-axis accel & gyro sensor1:GND", + "black", + [ + "v38.3", + "h32.7" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:VCC", + "arduino uno1:3.3V", + "red", + [ + "v-38.4", + "h-67.12" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SCL", + "arduino uno1:A5", + "green", + [ + "v-28.8", + "h67.28" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SDA", + "arduino uno1:A4", + "green", + [ + "v-38.4", + "h67.28" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/accelerometer/diagram_breadboard.json b/arduino/level2/accelerometer/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..a6bbd75086b7f48b8bc1e13d6e151d53fd2ab9cf --- /dev/null +++ b/arduino/level2/accelerometer/diagram_breadboard.json @@ -0,0 +1,148 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read value of MPU6050", + "config": { + "scl_pin": "A5", + "sda_pin": "A4", + "gnd_pin": "GND.3" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": 208.2, + "left": -189.2, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-mpu6050", + "id": "mpu6050 6-axis accel & gyro sensor1", + "top": 291.82, + "left": 117.52, + "attrs": {} + } + ], + "connections": [ + [ + "mpu6050 6-axis accel & gyro sensor1:INT", + "breadboard1:31t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:AD0", + "breadboard1:32t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:XCL", + "breadboard1:33t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:XDA", + "breadboard1:34t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SDA", + "breadboard1:35t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SCL", + "breadboard1:36t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:GND", + "breadboard1:37t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:VCC", + "breadboard1:38t.e", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:38t.c", + "breadboard1:tp.30", + "green", + [ + "v0" + ] + ], + [ + "arduino uno1:3.3V", + "breadboard1:tp.25", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:37t.d", + "breadboard1:tn.29", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:36t.d", + "arduino uno1:A5", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:35t.d", + "arduino uno1:A4", + "green", + [ + "v0" + ] + ], + [ + "arduino uno1:GND.3", + "breadboard1:tn.27", + "black", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/accelerometer/platformio.ini b/arduino/level2/accelerometer/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..96e95c2771d078f5c3c3f639952b01cef4460722 --- /dev/null +++ b/arduino/level2/accelerometer/platformio.ini @@ -0,0 +1,21 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + Adafruit MPU6050 \ No newline at end of file diff --git a/arduino/level2/accelerometer/scenario.yaml b/arduino/level2/accelerometer/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..25d55bd871207e58068e05777754d5428982a6f4 --- /dev/null +++ b/arduino/level2/accelerometer/scenario.yaml @@ -0,0 +1,45 @@ +author: Blind Author +description: Measure 3-axis acceleration with accelerometer +name: Accelerometer +steps: +- wait-serial: MPU6050 ready! +- set-control: + control: accelX + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 0.25 +- set-control: + control: accelY + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 0.2 +- set-control: + control: accelZ + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 0.35 +- wait-serial: 'X: 2.45, Y: 1.96, Z: 3.43 m/s^2' +- set-control: + control: accelX + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 1.35 +- set-control: + control: accelY + part-id: mpu6050 6-axis accel & gyro sensor1 + value: -1.15 +- set-control: + control: accelZ + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 2 +- wait-serial: 'X: 13.24, Y: -11.28, Z: 19.61 m/s^2' +- set-control: + control: accelX + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 2 +- set-control: + control: accelY + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 0.95 +- set-control: + control: accelZ + part-id: mpu6050 6-axis accel & gyro sensor1 + value: -0.85 +- wait-serial: 'X: 19.61, Y: 9.32, Z: -8.34 m/s^2' +version: 1.0 diff --git a/arduino/level2/accelerometer/src/main.ino b/arduino/level2/accelerometer/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..d854b53965f4eebadf4d24d9105069e1f850101e --- /dev/null +++ b/arduino/level2/accelerometer/src/main.ino @@ -0,0 +1,35 @@ +/** + Measure 3-axis acceleration with accelerometer + 10 APR 2025 by Blind Author +*/ + +#include +#include +#include + +Adafruit_MPU6050 mpu; + +void setup(void) { + Serial.begin(115200); + + while (!mpu.begin()) { + Serial.println("MPU6050 not connected!"); + delay(1000); + } + Serial.println("MPU6050 ready!"); +} + +sensors_event_t event; + +void loop() { + mpu.getAccelerometerSensor()->getEvent(&event); + + Serial.print("X: "); + Serial.print(event.acceleration.x); + Serial.print(", Y: "); + Serial.print(event.acceleration.y); + Serial.print(", Z: "); + Serial.print(event.acceleration.z); + Serial.println(" m/s^2"); + delay(500); +} \ No newline at end of file diff --git a/arduino/level2/accelerometer/wokwi.toml b/arduino/level2/accelerometer/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level2/accelerometer/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level2/button_duration/description.md b/arduino/level2/button_duration/description.md new file mode 100644 index 0000000000000000000000000000000000000000..9212e542b5ce8cf07acfafa65264fa67acc20aff --- /dev/null +++ b/arduino/level2/button_duration/description.md @@ -0,0 +1,33 @@ +# Button Duration + +## Project Description +This is an Arduino project that determines how long a switch is pressed + +## Hardware Components +- Arduino Uno +- 10kΩ resistor +- Push Button + +## Circuit Description +Circuit is designed to use a pull-up resistor. When the button is not pressed, the pin4 pin is connected to 5V through a 10kΩ resistor. When the button is pressed, the pin4 pin is connected to gnd2. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Configure the specified button pin as INPUT +3. Continuously monitor the button state and measure how long it is pressed +4. Print the duration in second, in the following format: "Button pressed duration: {duration}s" + +## Success Criteria +The test is successful when: +1. The pressed duration in seconds is correctly printed in the given format + +## Notes for Implementation +- Include a short delay in the loop to handle switch bouncing +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Variants +This project may have different variants with the pushbutton connected to different pins. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level2/button_duration/description_no_pin.md b/arduino/level2/button_duration/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..a804d7314c99edfebca2f3f82a0c84081be7e39d --- /dev/null +++ b/arduino/level2/button_duration/description_no_pin.md @@ -0,0 +1,33 @@ +# Button Duration + +## Project Description +This is an Arduino project that determines how long a switch is pressed + +## Hardware Components +- Arduino Uno +- 10kΩ resistor +- Push Button + +## Circuit Description +Circuit is designed to use a pull-up resistor. Button is connected to power through a 10kΩ resistor. Also, the button is connected to ground. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Configure the specified button pin as INPUT +3. Continuously monitor the button state and measure how long it is pressed +4. Print the duration in second, in the following format: "Button pressed duration: {duration}s" + +## Success Criteria +The test is successful when: +1. The pressed duration in seconds is correctly printed in the given format + +## Notes for Implementation +- Include a short delay in the loop to handle switch bouncing +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Variants +This project may have different variants with the pushbutton connected to different pins. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level2/button_duration/diagram.json b/arduino/level2/button_duration/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..e7aa47c2f795e8ca1682fc4577617e3b0d04d42c --- /dev/null +++ b/arduino/level2/button_duration/diagram.json @@ -0,0 +1,74 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Manage pull up registor button input", + "config": { + "button_pin": 4, + "gnd_pin": "GND.2" + }, + "editor": "wokwi", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -163.8, + "left": 79.8, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -92.05, + "left": 48, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "resistor1:2", + "push button1:2.r", + "green", + [ + "v0" + ] + ], + [ + "resistor1:1", + "arduino uno1:5V", + "green", + [ + "v0" + ] + ], + [ + "push button1:2.l", + "arduino uno1:4", + "green", + [ + "v0" + ] + ], + [ + "push button1:1.r", + "arduino uno1:GND.2", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/button_duration/diagram_breadboard.json b/arduino/level2/button_duration/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..d6d2f4ce05a029d676fe230d1282db47b25a1a4e --- /dev/null +++ b/arduino/level2/button_duration/diagram_breadboard.json @@ -0,0 +1,120 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Manage pull up registor button input", + "config": { + "button_pin": 4, + "gnd_pin": "GND.3" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -223.8, + "left": -35.6, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -144.6, + "left": 118.2, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -82.45, + "left": 86.4, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "push button1:1.l", + "breadboard1:19t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.l", + "breadboard1:17t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.r", + "breadboard1:19b.h", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.r", + "breadboard1:17b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:11b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:17b.i", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:11b.j", + "arduino uno1:5V", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:17t.b", + "arduino uno1:4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:19b.i", + "arduino uno1:GND.3", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/button_duration/diagram_breadboard_shdf.json b/arduino/level2/button_duration/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..f532bb40055470a8c27eb69ec1703d8452ed3bdc --- /dev/null +++ b/arduino/level2/button_duration/diagram_breadboard_shdf.json @@ -0,0 +1,64 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "btn1", + "type": "push button", + "properties": { + "color": "green" + } + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "10000 ohm" + } + } + ], + "connections": [ + [ + "btn1.pin1.l", + "bb1.pin19t.c" + ], + [ + "btn1.pin2.l", + "bb1.pin17t.c" + ], + [ + "btn1.pin1.r", + "bb1.pin19b.h" + ], + [ + "btn1.pin2.r", + "bb1.pin17b.h" + ], + [ + "r1.1", + "bb1.pin11b.i" + ], + [ + "r1.2", + "bb1.pin17b.i" + ], + [ + "bb1.pin11b.j", + "uno.5v" + ], + [ + "bb1.pin17t.b", + "uno.4" + ], + [ + "bb1.pin19b.i", + "uno.gnd.3" + ] + ] +} \ No newline at end of file diff --git a/arduino/level2/button_duration/diagram_shdf.json b/arduino/level2/button_duration/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..3a9f545faaddef06a47cce2ce05707807af7a9ea --- /dev/null +++ b/arduino/level2/button_duration/diagram_shdf.json @@ -0,0 +1,40 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "btn1", + "type": "push button", + "properties": { + "color": "green" + } + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "10000 ohm" + } + } + ], + "connections": [ + [ + "r1.2", + "btn1.pin2.r" + ], + [ + "r1.1", + "uno.5v" + ], + [ + "btn1.pin2.l", + "uno.4" + ], + [ + "btn1.pin1.r", + "uno.gnd.2" + ] + ] +} \ No newline at end of file diff --git a/arduino/level2/button_duration/platformio.ini b/arduino/level2/button_duration/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level2/button_duration/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level2/button_duration/scenario.yaml b/arduino/level2/button_duration/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e983d2b2acfe7941a8cc376ebc7ad58b58b29321 --- /dev/null +++ b/arduino/level2/button_duration/scenario.yaml @@ -0,0 +1,26 @@ +author: Blind Author +description: Determine how long a switch is pressed +name: Button Duration +steps: +- delay: 300ms +- set-control: + control: pressed + part-id: push button1 + value: 1 +- delay: 1000ms +- set-control: + control: pressed + part-id: push button1 + value: 0 +- wait-serial: 'Button pressed duration: 1s' +- set-control: + control: pressed + part-id: push button1 + value: 1 +- delay: 3000ms +- set-control: + control: pressed + part-id: push button1 + value: 0 +- wait-serial: 'Button pressed duration: 3s' +version: 1.0 diff --git a/arduino/level2/button_duration/src/main.ino b/arduino/level2/button_duration/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..94034f4a984f29666597880fe07eb16f4afb5d57 --- /dev/null +++ b/arduino/level2/button_duration/src/main.ino @@ -0,0 +1,34 @@ +/** + Determine how long a switch is pressed + 6 APR 2025 by Blind Author +*/ + +const int inPin = 4; + +bool prevButtonState = HIGH; +unsigned long pressStartTime = 0; +unsigned long pressDuration = 0; + +void setup() { + pinMode(inPin, INPUT); + Serial.begin(9600); +} + +void loop() { + bool buttonState = digitalRead(inPin); + + if (prevButtonState == HIGH && buttonState == LOW) { + pressStartTime = millis(); + } + + if (prevButtonState == LOW && buttonState == HIGH) { + pressDuration = (millis() - pressStartTime) / 1000; + Serial.print("Button pressed duration: "); + Serial.print(pressDuration); + Serial.println("s"); + } + + prevButtonState = buttonState; + + delay(10); +} diff --git a/arduino/level2/button_duration/wokwi.toml b/arduino/level2/button_duration/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level2/button_duration/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level2/button_pulldown/description.md b/arduino/level2/button_pulldown/description.md new file mode 100644 index 0000000000000000000000000000000000000000..58ff56d0c04be079bb0196820938eb7fc49b9c40 --- /dev/null +++ b/arduino/level2/button_pulldown/description.md @@ -0,0 +1,33 @@ +# Button Pulldown + +## Project Description +This is a simple Arduino project that prints whether the button is pressed. + +## Hardware Components +- Arduino Uno +- 10kΩ resistor +- Push Button + +## Circuit Description +Circuit is designed to use a pull-down resistor. When the button is not pressed, the pin4 pin is connected to gnd2 through a 10kΩ resistor. When the button is pressed, the pin4 pin is connected to 5V. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Configure the specified button pin as INPUT +3. Continuously check the button value, and print "Button pressed" if the value is HIGH, or print "Button not pressed" if the value is LOW. + +## Success Criteria +The test is successful when: +1. "Button pressed" is printed when the button is pressed +2. "Button not pressed" is printed when the button is not pressed + +## Notes for Implementation +- The pin number used should match the circuit diagram +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Variants +This project may have different variants with the pushbutton connected to different pins. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level2/button_pulldown/description_no_pin.md b/arduino/level2/button_pulldown/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..01047b090d6419155a89d540263d6e81058edc82 --- /dev/null +++ b/arduino/level2/button_pulldown/description_no_pin.md @@ -0,0 +1,33 @@ +# Button Pulldown + +## Project Description +This is a simple Arduino project that prints whether the button is pressed. + +## Hardware Components +- Arduino Uno +- 10kΩ resistor +- Push Button + +## Circuit Description +Circuit is designed to use a pull-down resistor. The button is connected to ground through a 10kΩ resistor. Also, the button is connected to power. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Configure the specified button pin as INPUT +3. Continuously check the button value, and print "Button pressed" if the value is HIGH, or print "Button not pressed" if the value is LOW. + +## Success Criteria +The test is successful when: +1. "Button pressed" is printed when the button is pressed +2. "Button not pressed" is printed when the button is not pressed + +## Notes for Implementation +- The pin number used should match the circuit diagram +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Variants +This project may have different variants with the pushbutton connected to different pins. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level2/button_pulldown/diagram.json b/arduino/level2/button_pulldown/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..d023e14cf99ea0167b1731e602edd351b0eac6ee --- /dev/null +++ b/arduino/level2/button_pulldown/diagram.json @@ -0,0 +1,73 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Manage pull down registor button input", + "config": { + "button_pin": 4, + "gnd_pin": "GND.2" + }, + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -144.6, + "left": 70.2, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -63.25, + "left": 38.4, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "resistor1:2", + "push button1:2.r", + "green", + [ + "v0" + ] + ], + [ + "resistor1:1", + "arduino uno1:GND.2", + "green", + [ + "v0" + ] + ], + [ + "push button1:2.l", + "arduino uno1:4", + "green", + [ + "v0" + ] + ], + [ + "push button1:1.r", + "arduino uno1:5V", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/button_pulldown/diagram_breadboard.json b/arduino/level2/button_pulldown/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..796d827fa69f7ce96cd7a86ee16cac11815038a8 --- /dev/null +++ b/arduino/level2/button_pulldown/diagram_breadboard.json @@ -0,0 +1,120 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Manage pull down registor button input", + "config": { + "button_pin": 4, + "gnd_pin": "GND.2" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -223.8, + "left": -35.6, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -144.6, + "left": 118.2, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -82.45, + "left": 86.4, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "breadboard1:17t.b", + "arduino uno1:4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:19b.i", + "arduino uno1:5V", + "green", + [ + "v0" + ] + ], + [ + "push button1:1.l", + "breadboard1:19t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.l", + "breadboard1:17t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.r", + "breadboard1:19b.h", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.r", + "breadboard1:17b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:11b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:17b.i", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:11b.j", + "arduino uno1:GND.2", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/button_pulldown/diagram_breadboard_shdf.json b/arduino/level2/button_pulldown/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..a77c8bfb059f073cf48f34cb157229538996b4cb --- /dev/null +++ b/arduino/level2/button_pulldown/diagram_breadboard_shdf.json @@ -0,0 +1,64 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "btn1", + "type": "push button", + "properties": { + "color": "green" + } + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "10000 ohm" + } + } + ], + "connections": [ + [ + "bb1.pin17t.b", + "uno.4" + ], + [ + "bb1.pin19b.i", + "uno.5v" + ], + [ + "btn1.pin1.l", + "bb1.pin19t.c" + ], + [ + "btn1.pin2.l", + "bb1.pin17t.c" + ], + [ + "btn1.pin1.r", + "bb1.pin19b.h" + ], + [ + "btn1.pin2.r", + "bb1.pin17b.h" + ], + [ + "r1.1", + "bb1.pin11b.i" + ], + [ + "r1.2", + "bb1.pin17b.i" + ], + [ + "bb1.pin11b.j", + "uno.gnd.2" + ] + ] +} \ No newline at end of file diff --git a/arduino/level2/button_pulldown/diagram_copy.json b/arduino/level2/button_pulldown/diagram_copy.json new file mode 100644 index 0000000000000000000000000000000000000000..fdcb6b638d1f64f2e81d2ca0089f8a61870c6136 --- /dev/null +++ b/arduino/level2/button_pulldown/diagram_copy.json @@ -0,0 +1,58 @@ +{ + "version": 1, + "author": "Arduino-LLM", + "editor": "Blind Author and Blind Author", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 200, + "left": 20, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": 150, + "left": 200, + "rotate": 90, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 100, + "left": 250, + "attrs": { + "value": "10k" + }, + "rotate": 90 + } + ], + "connections": [ + [ + "arduino uno1:4", + "push button1:1.l", + "yellow", + [] + ], + [ + "push button1:1.r", + "arduino uno1:5v", + "red", + [] + ], + [ + "push button1:1.l", + "resistor1:1", + "blue", + [] + ], + [ + "resistor1:2", + "arduino uno1:GND.1", + "black", + [] + ] + ] +} \ No newline at end of file diff --git a/arduino/level2/button_pulldown/diagram_shdf.json b/arduino/level2/button_pulldown/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..2f6706c2fb2fba33282de7b4a03a1c4295cfe97b --- /dev/null +++ b/arduino/level2/button_pulldown/diagram_shdf.json @@ -0,0 +1,40 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "btn1", + "type": "push button", + "properties": { + "color": "green" + } + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "10000 ohm" + } + } + ], + "connections": [ + [ + "r1.2", + "btn1.pin2.r" + ], + [ + "r1.1", + "uno.gnd.2" + ], + [ + "btn1.pin2.l", + "uno.4" + ], + [ + "btn1.pin1.r", + "uno.5v" + ] + ] +} \ No newline at end of file diff --git a/arduino/level2/button_pulldown/platformio.ini b/arduino/level2/button_pulldown/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level2/button_pulldown/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level2/button_pulldown/scenario.yaml b/arduino/level2/button_pulldown/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..93e9a4c1f0fd5ab2208a7046ff53a720d438a200 --- /dev/null +++ b/arduino/level2/button_pulldown/scenario.yaml @@ -0,0 +1,17 @@ +author: Blind Author +description: Manage pull down registor button input +name: Serial Monitor +steps: +- delay: 10ms +- set-control: + control: pressed + part-id: push button1 + value: 1 +- wait-serial: Button pressed +- delay: 1000ms +- set-control: + control: pressed + part-id: push button1 + value: 0 +- wait-serial: Button not pressed +version: 1.0 diff --git a/arduino/level2/button_pulldown/src/main.ino b/arduino/level2/button_pulldown/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..d1c87723cd3f9e5790e1583f81cc9d466f451ec8 --- /dev/null +++ b/arduino/level2/button_pulldown/src/main.ino @@ -0,0 +1,26 @@ +/** + Manage pull down registor button input + 1 APR 2025 by Blind Author +*/ + +const int inputPin = 4; + +void setup() +{ + Serial.begin(9600); + pinMode(inputPin, INPUT); +} + +void loop() +{ + int val = digitalRead(inputPin); + + if (val == HIGH) { + Serial.println("Button pressed"); + } else + { + Serial.println("Button not pressed"); + } + + delay(1000); +} \ No newline at end of file diff --git a/arduino/level2/button_pulldown/wokwi.toml b/arduino/level2/button_pulldown/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level2/button_pulldown/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level2/button_pullup/description.md b/arduino/level2/button_pullup/description.md new file mode 100644 index 0000000000000000000000000000000000000000..406de4ac7b2cf60744907b7cffeedfdba7e225a9 --- /dev/null +++ b/arduino/level2/button_pullup/description.md @@ -0,0 +1,33 @@ +# Button Pullup + +## Project Description +This is a simple Arduino project that prints whether the button is pressed. + +## Hardware Components +- Arduino Uno +- 10kΩ resistor +- Push Button + +## Circuit Description +Circuit is designed to use a pull-up resistor. When the button is not pressed, the pin4 pin is connected to 5V through a 10kΩ resistor. When the button is pressed, the pin4 pin is connected to gnd2. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Configure the specified button pin as INPUT +3. Continuously check the button value, and print "Button pressed" if the value is LOW, or print "Button not pressed" if the value is HIGH. + +## Success Criteria +The test is successful when: +1. "Button pressed" is printed when the button is pressed +2. "Button not pressed" is printed when the button is not pressed + +## Notes for Implementation +- The pin number used should match the circuit diagram +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Variants +This project may have different variants with the pushbutton connected to different pins. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level2/button_pullup/description_no_pin.md b/arduino/level2/button_pullup/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..77043db98e1f4d6b3c89d6317868cba252753c90 --- /dev/null +++ b/arduino/level2/button_pullup/description_no_pin.md @@ -0,0 +1,33 @@ +# Button Pullup + +## Project Description +This is a simple Arduino project that prints whether the button is pressed. + +## Hardware Components +- Arduino Uno +- 10kΩ resistor +- Push Button + +## Circuit Description +Circuit is designed to use a pull-up resistor. The button is connected to 5V through a 10kΩ resistor. Also, the button is connected to ground. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Configure the specified button pin as INPUT +3. Continuously check the button value, and print "Button pressed" if the value is LOW, or print "Button not pressed" if the value is HIGH. + +## Success Criteria +The test is successful when: +1. "Button pressed" is printed when the button is pressed +2. "Button not pressed" is printed when the button is not pressed + +## Notes for Implementation +- The pin number used should match the circuit diagram +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Variants +This project may have different variants with the pushbutton connected to different pins. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level2/button_pullup/diagram.json b/arduino/level2/button_pullup/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..e7aa47c2f795e8ca1682fc4577617e3b0d04d42c --- /dev/null +++ b/arduino/level2/button_pullup/diagram.json @@ -0,0 +1,74 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Manage pull up registor button input", + "config": { + "button_pin": 4, + "gnd_pin": "GND.2" + }, + "editor": "wokwi", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -163.8, + "left": 79.8, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -92.05, + "left": 48, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "resistor1:2", + "push button1:2.r", + "green", + [ + "v0" + ] + ], + [ + "resistor1:1", + "arduino uno1:5V", + "green", + [ + "v0" + ] + ], + [ + "push button1:2.l", + "arduino uno1:4", + "green", + [ + "v0" + ] + ], + [ + "push button1:1.r", + "arduino uno1:GND.2", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/button_pullup/diagram_breadboard.json b/arduino/level2/button_pullup/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..d6d2f4ce05a029d676fe230d1282db47b25a1a4e --- /dev/null +++ b/arduino/level2/button_pullup/diagram_breadboard.json @@ -0,0 +1,120 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Manage pull up registor button input", + "config": { + "button_pin": 4, + "gnd_pin": "GND.3" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -223.8, + "left": -35.6, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -144.6, + "left": 118.2, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -82.45, + "left": 86.4, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "push button1:1.l", + "breadboard1:19t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.l", + "breadboard1:17t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.r", + "breadboard1:19b.h", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.r", + "breadboard1:17b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:11b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:17b.i", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:11b.j", + "arduino uno1:5V", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:17t.b", + "arduino uno1:4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:19b.i", + "arduino uno1:GND.3", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/button_pullup/diagram_breadboard_shdf.json b/arduino/level2/button_pullup/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..f532bb40055470a8c27eb69ec1703d8452ed3bdc --- /dev/null +++ b/arduino/level2/button_pullup/diagram_breadboard_shdf.json @@ -0,0 +1,64 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "btn1", + "type": "push button", + "properties": { + "color": "green" + } + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "10000 ohm" + } + } + ], + "connections": [ + [ + "btn1.pin1.l", + "bb1.pin19t.c" + ], + [ + "btn1.pin2.l", + "bb1.pin17t.c" + ], + [ + "btn1.pin1.r", + "bb1.pin19b.h" + ], + [ + "btn1.pin2.r", + "bb1.pin17b.h" + ], + [ + "r1.1", + "bb1.pin11b.i" + ], + [ + "r1.2", + "bb1.pin17b.i" + ], + [ + "bb1.pin11b.j", + "uno.5v" + ], + [ + "bb1.pin17t.b", + "uno.4" + ], + [ + "bb1.pin19b.i", + "uno.gnd.3" + ] + ] +} \ No newline at end of file diff --git a/arduino/level2/button_pullup/diagram_shdf.json b/arduino/level2/button_pullup/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..3a9f545faaddef06a47cce2ce05707807af7a9ea --- /dev/null +++ b/arduino/level2/button_pullup/diagram_shdf.json @@ -0,0 +1,40 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "btn1", + "type": "push button", + "properties": { + "color": "green" + } + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "10000 ohm" + } + } + ], + "connections": [ + [ + "r1.2", + "btn1.pin2.r" + ], + [ + "r1.1", + "uno.5v" + ], + [ + "btn1.pin2.l", + "uno.4" + ], + [ + "btn1.pin1.r", + "uno.gnd.2" + ] + ] +} \ No newline at end of file diff --git a/arduino/level2/button_pullup/platformio.ini b/arduino/level2/button_pullup/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level2/button_pullup/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level2/button_pullup/scenario.yaml b/arduino/level2/button_pullup/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..93e9a4c1f0fd5ab2208a7046ff53a720d438a200 --- /dev/null +++ b/arduino/level2/button_pullup/scenario.yaml @@ -0,0 +1,17 @@ +author: Blind Author +description: Manage pull down registor button input +name: Serial Monitor +steps: +- delay: 10ms +- set-control: + control: pressed + part-id: push button1 + value: 1 +- wait-serial: Button pressed +- delay: 1000ms +- set-control: + control: pressed + part-id: push button1 + value: 0 +- wait-serial: Button not pressed +version: 1.0 diff --git a/arduino/level2/button_pullup/src/main.ino b/arduino/level2/button_pullup/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..778eb5e2af4751d30579860fa75d163670d5a93f --- /dev/null +++ b/arduino/level2/button_pullup/src/main.ino @@ -0,0 +1,27 @@ +/** + Manage pull up registor button input + 1 APR 2025 by Blind Author +*/ + +const int inputPin = 4; + +void setup() +{ + Serial.begin(9600); + pinMode(inputPin, INPUT); +} + +void loop() +{ + int val = digitalRead(inputPin); + + if (val == LOW) + { + Serial.println("Button pressed"); + } else + { + Serial.println("Button not pressed"); + } + + delay(1000); +} \ No newline at end of file diff --git a/arduino/level2/button_pullup/wokwi.toml b/arduino/level2/button_pullup/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level2/button_pullup/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level2/distance_sensor/description.md b/arduino/level2/distance_sensor/description.md new file mode 100644 index 0000000000000000000000000000000000000000..38bfe27466b8757abe142cac80fcdb3800bc26d6 --- /dev/null +++ b/arduino/level2/distance_sensor/description.md @@ -0,0 +1,32 @@ +# Distance Sensor + +## Project Description +This is an Arduino project that uses Ultrasonic distance sensor to measure the distance, and compare with the input distance. + +## Hardware Components +- Arduino Uno +- HC-SR04 Ultrasonic Distance Sensor + +## Circuit Description +The ultrasonic distance sensor is connected to the Arduino. The VCC pin is connected to 5V, the GND pin to gnd3, the TRIG pin to pin3, and the ECHO pin to pin2. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Continuously trigger and read the Ultrasonic distance sensor +3. Print "Enter a distance in cm to compare: " and read the serial input +4. Change the measured value to the integer centimeter, compare with the input value, and print one of these: "Measured distance is greater", "Measured distance is equal to the target", "Measured distance is less" + +## Success Criteria +The test is successful when: +1. Measured distance is correctly calculated, compared, and correct result is printed to serial monitor. + +## Notes for Implementation +- In the loop function, trigger and read the distance sensor, read the serial input, compare, and print result to the serial monitor. +- Distance is calculated by dividing the duration by 58. + +## Variants +There may be variants with ECHO, TRIG, GND pin number. + +## Test Inputs +Test input values are: 200, 400, 403, 500, 600 \ No newline at end of file diff --git a/arduino/level2/distance_sensor/description_no_pin.md b/arduino/level2/distance_sensor/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..00a0fb8fb7e718f18bc022d43ad1d9240546b5cc --- /dev/null +++ b/arduino/level2/distance_sensor/description_no_pin.md @@ -0,0 +1,32 @@ +# Distance Sensor + +## Project Description +This is an Arduino project that uses Ultrasonic distance sensor to measure the distance, and compare with the input distance. + +## Hardware Components +- Arduino Uno +- HC-SR04 Ultrasonic Distance Sensor + +## Circuit Description +The ultrasonic distance sensor is connected to the Arduino. The TRIG pin and the ECHO pin is connected to arduino digital pin. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Continuously trigger and read the Ultrasonic distance sensor +3. Print "Enter a distance in cm to compare: " and read the serial input +4. Change the measured value to the integer centimeter, compare with the input value, and print one of these: "Measured distance is greater", "Measured distance is equal to the target", "Measured distance is less" + +## Success Criteria +The test is successful when: +1. Measured distance is correctly calculated, compared, and correct result is printed to serial monitor. + +## Notes for Implementation +- In the loop function, trigger and read the distance sensor, read the serial input, compare, and print result to the serial monitor. +- Distance is calculated by dividing the duration by 58. + +## Variants +There may be variants with ECHO, TRIG, GND pin number. + +## Test Inputs +Test input values are: 200, 400, 403, 500, 600 \ No newline at end of file diff --git a/arduino/level2/distance_sensor/diagram.json b/arduino/level2/distance_sensor/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..6aba5d9a4051d62402bc00c135fe05ba0bbdb9e7 --- /dev/null +++ b/arduino/level2/distance_sensor/diagram.json @@ -0,0 +1,65 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read value of distance sensor", + "config": { + "distance_echo_pin": "2", + "distance_trig_pin": "3", + "gnd_pin": "GND.3", + "distance_init": "400" + }, + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-hc-sr04", + "id": "ultrasonic distance sensor1", + "top": 43.5, + "left": 288.9, + "rotate": 90, + "attrs": { + "distance": "400" + } + } + ], + "connections": [ + [ + "ultrasonic distance sensor1:VCC", + "arduino uno1:5V", + "red", + [ + "h0" + ] + ], + [ + "ultrasonic distance sensor1:GND", + "arduino uno1:GND.3", + "black", + [ + "h0" + ] + ], + [ + "ultrasonic distance sensor1:TRIG", + "arduino uno1:3", + "green", + [ + "h0" + ] + ], + [ + "ultrasonic distance sensor1:ECHO", + "arduino uno1:2", + "green", + [ + "h0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/distance_sensor/diagram_breadboard.json b/arduino/level2/distance_sensor/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..e690e163c6f1abc5b175cf38151e1ac0f3637b1b --- /dev/null +++ b/arduino/level2/distance_sensor/diagram_breadboard.json @@ -0,0 +1,103 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read value of distance sensor", + "config": { + "distance_echo_pin": "2", + "distance_trig_pin": "3", + "gnd_pin": "GND.3", + "distance_init": "400" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -252.6, + "left": -64.4, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-hc-sr04", + "id": "ultrasonic distance sensor1", + "top": -228.9, + "left": 178.3, + "attrs": { + "distance": "400" + } + } + ], + "connections": [ + [ + "ultrasonic distance sensor1:VCC", + "breadboard1:31b.f", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:TRIG", + "breadboard1:32b.f", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:ECHO", + "breadboard1:33b.f", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:GND", + "breadboard1:34b.f", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:34b.g", + "arduino uno1:GND.3", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:31b.g", + "arduino uno1:5V", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:32b.g", + "arduino uno1:3", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:33b.g", + "arduino uno1:2", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/distance_sensor/diagram_breadboard_shdf.json b/arduino/level2/distance_sensor/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..d93278b034afcbfedaeb41d0fb658d9d64eb1e70 --- /dev/null +++ b/arduino/level2/distance_sensor/diagram_breadboard_shdf.json @@ -0,0 +1,50 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "ultrasonic1", + "type": "ultrasonic distance sensor" + } + ], + "connections": [ + [ + "ultrasonic1.vcc", + "bb1.pin31b.f" + ], + [ + "ultrasonic1.trig", + "bb1.pin32b.f" + ], + [ + "ultrasonic1.echo", + "bb1.pin33b.f" + ], + [ + "ultrasonic1.gnd", + "bb1.pin34b.f" + ], + [ + "bb1.pin34b.g", + "uno.gnd.3" + ], + [ + "bb1.pin31b.g", + "uno.5v" + ], + [ + "bb1.pin32b.g", + "uno.3" + ], + [ + "bb1.pin33b.g", + "uno.2" + ] + ] +} \ No newline at end of file diff --git a/arduino/level2/distance_sensor/diagram_shdf.json b/arduino/level2/distance_sensor/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..4ebed208df8ae49a8027670f9d713b2fa40aedc5 --- /dev/null +++ b/arduino/level2/distance_sensor/diagram_shdf.json @@ -0,0 +1,30 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "ultrasonic1", + "type": "ultrasonic distance sensor" + } + ], + "connections": [ + [ + "ultrasonic1.vcc", + "uno.5v" + ], + [ + "ultrasonic1.gnd", + "uno.gnd.3" + ], + [ + "ultrasonic1.trig", + "uno.3" + ], + [ + "ultrasonic1.echo", + "uno.2" + ] + ] +} \ No newline at end of file diff --git a/arduino/level2/distance_sensor/platformio.ini b/arduino/level2/distance_sensor/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level2/distance_sensor/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level2/distance_sensor/scenario.yaml b/arduino/level2/distance_sensor/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..14ace1a0e7b72a5ed195bdf9e0b01c8d7703d334 --- /dev/null +++ b/arduino/level2/distance_sensor/scenario.yaml @@ -0,0 +1,24 @@ +author: Blind Author +description: Measure distance with Ultrasonic distance sensor +name: Distance Sensor +steps: +- delay: 10ms +- set-control: + - part-id: ultrasonic distance sensor1 + control: distance + value: "200" +- write-serial: '200' +- wait-serial: Measured distance is greater +- delay: 50ms +- write-serial: '400' +- wait-serial: Measured distance is greater +- delay: 50ms +- write-serial: '403' +- wait-serial: Measured distance is equal to the target +- delay: 50ms +- write-serial: '500' +- wait-serial: Measured distance is less +- delay: 50ms +- write-serial: '600' +- wait-serial: Measured distance is less +version: 1.0 diff --git a/arduino/level2/distance_sensor/src/main.ino b/arduino/level2/distance_sensor/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..913e8c2f9e0d24fc1a89089b348f27c3de0e7ac7 --- /dev/null +++ b/arduino/level2/distance_sensor/src/main.ino @@ -0,0 +1,35 @@ +/** + Measure distance with Ultrasonic distance sensor. + 3 APR 2025 by Blind Author +*/ + +#define PIN_TRIG 3 +#define PIN_ECHO 2 + +void setup() { + Serial.begin(9600); + pinMode(PIN_TRIG, OUTPUT); + pinMode(PIN_ECHO, INPUT); +} + +void loop() { + digitalWrite(PIN_TRIG, HIGH); + delayMicroseconds(10); + digitalWrite(PIN_TRIG, LOW); + + int duration = pulseIn(PIN_ECHO, HIGH); + int centimeter = duration / 58; + + Serial.println("Enter a distance in cm to compare: "); + delay(200); + if (Serial.available() > 0) { + int inputNumber = Serial.parseInt(); + if (inputNumber > centimeter) { + Serial.println("Measured distance is less"); + } else if (inputNumber < centimeter) { + Serial.println("Measured distance is greater"); + } else { + Serial.println("Measured distance is equal to the target"); + } + } +} \ No newline at end of file diff --git a/arduino/level2/distance_sensor/wokwi.toml b/arduino/level2/distance_sensor/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level2/distance_sensor/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level2/gyroscope/description.md b/arduino/level2/gyroscope/description.md new file mode 100644 index 0000000000000000000000000000000000000000..2630df9968ea87e0d6fdf6e1779cef8f4cf8fee6 --- /dev/null +++ b/arduino/level2/gyroscope/description.md @@ -0,0 +1,30 @@ +# Gyroscope + +## Project Description +This is an Arduino project that uses MPU6050 6-axis accelerometer & gyro sensor to measure the rotation. + +## Hardware Components +- Arduino Uno +- MPU6050 6-axis Accel & Gyro Sensor + +## Circuit Description +The MPU6050 sensor is connected to the Arduino. The VCC pin is connected to 3.3V, the GND pin to gnd3, the SCL pin to A5, and the SDA pin to A4. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Check if the MPU sensor can be initialized successfully, and print 'MPU6050 ready!' to the serial monitor +3. Continuously read the gryoscope data from the MPU6050 sensor +4. Print the X, Y, and Z axis rotation values in rad/s to the serial monitor, for example: 'X: 1.13, Y: 2.97, Z: -2.01 rad/s' + +## Success Criteria +The test is successful when: +1. Correct X, Y, Z gyroscope result is printed to the serial monitor. + +## Notes for Implementation +- Use Adafruit_MPU6050.h, Adafruit_Sensor.h, Wire.h libraries. +- Delay 500ms in every loop. +- MPU6050 has I2C interface. + +## Variants +There may be variants with GND connected to different pin. \ No newline at end of file diff --git a/arduino/level2/gyroscope/description_no_pin.md b/arduino/level2/gyroscope/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..9fbfed898ac7662b1f01810aad9062dfe6a15b62 --- /dev/null +++ b/arduino/level2/gyroscope/description_no_pin.md @@ -0,0 +1,30 @@ +# Gyroscope + +## Project Description +This is an Arduino project that uses MPU6050 6-axis accelerometer & gyro sensor to measure the rotation. + +## Hardware Components +- Arduino Uno +- MPU6050 6-axis Accel & Gyro Sensor + +## Circuit Description +The MPU6050 sensor is connected to the Arduino. It follows the standard wiring conventions defined by the I2C protocol. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Check if the MPU sensor can be initialized successfully, and print 'MPU6050 ready!' to the serial monitor +3. Continuously read the gryoscope data from the MPU6050 sensor +4. Print the X, Y, and Z axis rotation values in rad/s to the serial monitor, for example: 'X: 1.13, Y: 2.97, Z: -2.01 rad/s' + +## Success Criteria +The test is successful when: +1. Correct X, Y, Z gyroscope result is printed to the serial monitor. + +## Notes for Implementation +- Use Adafruit_MPU6050.h, Adafruit_Sensor.h, Wire.h libraries. +- Delay 500ms in every loop. +- MPU6050 has I2C interface. + +## Variants +There may be variants with GND connected to different pin. \ No newline at end of file diff --git a/arduino/level2/gyroscope/diagram.json b/arduino/level2/gyroscope/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..862c8c9c3638b78ca53aa9d92e170d41828c17cd --- /dev/null +++ b/arduino/level2/gyroscope/diagram.json @@ -0,0 +1,65 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read value of MPU6050", + "config": { + "scl_pin": "A5", + "sda_pin": "A4", + "gnd_pin": "GND.3" + }, + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-mpu6050", + "id": "mpu6050 6-axis accel & gyro sensor1", + "top": 234.22, + "left": 117.52, + "attrs": {} + } + ], + "connections": [ + [ + "arduino uno1:GND.2", + "mpu6050 6-axis accel & gyro sensor1:GND", + "black", + [ + "v38.3", + "h32.7" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:VCC", + "arduino uno1:3.3V", + "red", + [ + "v-38.4", + "h-67.12" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SCL", + "arduino uno1:A5", + "green", + [ + "v-28.8", + "h67.28" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SDA", + "arduino uno1:A4", + "green", + [ + "v-38.4", + "h67.28" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/gyroscope/diagram_breadboard.json b/arduino/level2/gyroscope/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..a6bbd75086b7f48b8bc1e13d6e151d53fd2ab9cf --- /dev/null +++ b/arduino/level2/gyroscope/diagram_breadboard.json @@ -0,0 +1,148 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read value of MPU6050", + "config": { + "scl_pin": "A5", + "sda_pin": "A4", + "gnd_pin": "GND.3" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": 208.2, + "left": -189.2, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-mpu6050", + "id": "mpu6050 6-axis accel & gyro sensor1", + "top": 291.82, + "left": 117.52, + "attrs": {} + } + ], + "connections": [ + [ + "mpu6050 6-axis accel & gyro sensor1:INT", + "breadboard1:31t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:AD0", + "breadboard1:32t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:XCL", + "breadboard1:33t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:XDA", + "breadboard1:34t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SDA", + "breadboard1:35t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SCL", + "breadboard1:36t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:GND", + "breadboard1:37t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:VCC", + "breadboard1:38t.e", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:38t.c", + "breadboard1:tp.30", + "green", + [ + "v0" + ] + ], + [ + "arduino uno1:3.3V", + "breadboard1:tp.25", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:37t.d", + "breadboard1:tn.29", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:36t.d", + "arduino uno1:A5", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:35t.d", + "arduino uno1:A4", + "green", + [ + "v0" + ] + ], + [ + "arduino uno1:GND.3", + "breadboard1:tn.27", + "black", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/gyroscope/platformio.ini b/arduino/level2/gyroscope/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..96e95c2771d078f5c3c3f639952b01cef4460722 --- /dev/null +++ b/arduino/level2/gyroscope/platformio.ini @@ -0,0 +1,21 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + Adafruit MPU6050 \ No newline at end of file diff --git a/arduino/level2/gyroscope/scenario.yaml b/arduino/level2/gyroscope/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ffbb1cd31258c74ec3f879a7ee2eda9dcaea4dd9 --- /dev/null +++ b/arduino/level2/gyroscope/scenario.yaml @@ -0,0 +1,45 @@ +author: Blind Author +description: Measure 3-axis rotation with gyroscope +name: Gyroscope +steps: +- wait-serial: MPU6050 ready! +- set-control: + control: rotationX + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 65 +- set-control: + control: rotationY + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 170 +- set-control: + control: rotationZ + part-id: mpu6050 6-axis accel & gyro sensor1 + value: -115 +- wait-serial: 'X: 1.13, Y: 2.97, Z: -2.01 rad/s' +- set-control: + control: rotationX + part-id: mpu6050 6-axis accel & gyro sensor1 + value: -105 +- set-control: + control: rotationY + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 35 +- set-control: + control: rotationZ + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 205 +- wait-serial: 'X: -1.83, Y: 0.61, Z: 3.58 rad/s' +- set-control: + control: rotationX + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 220 +- set-control: + control: rotationY + part-id: mpu6050 6-axis accel & gyro sensor1 + value: -215 +- set-control: + control: rotationZ + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 15 +- wait-serial: 'X: 3.84, Y: -3.75, Z: 0.26 rad/s' +version: 1.0 diff --git a/arduino/level2/gyroscope/src/main.ino b/arduino/level2/gyroscope/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..c8e920f4ce61cfd63aa3a0e5594b271e6f9d5e39 --- /dev/null +++ b/arduino/level2/gyroscope/src/main.ino @@ -0,0 +1,35 @@ +/** + Measure 3-axis rotation with gyroscope + 10 APR 2025 by Blind Author +*/ + +#include +#include +#include + +Adafruit_MPU6050 mpu; + +void setup(void) { + Serial.begin(115200); + + while (!mpu.begin()) { + Serial.println("MPU6050 not connected!"); + delay(1000); + } + Serial.println("MPU6050 ready!"); +} + +sensors_event_t event; + +void loop() { + mpu.getGyroSensor()->getEvent(&event); + + Serial.print("X: "); + Serial.print(event.gyro.x); + Serial.print(", Y: "); + Serial.print(event.gyro.y); + Serial.print(", Z: "); + Serial.print(event.gyro.z); + Serial.println(" rad/s"); + delay(500); +} \ No newline at end of file diff --git a/arduino/level2/gyroscope/wokwi.toml b/arduino/level2/gyroscope/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level2/gyroscope/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level2/humidity_sensor/description.md b/arduino/level2/humidity_sensor/description.md new file mode 100644 index 0000000000000000000000000000000000000000..a5ee36973da24d016677664349f99b738320e0e8 --- /dev/null +++ b/arduino/level2/humidity_sensor/description.md @@ -0,0 +1,26 @@ +# Humidity Sensor + +## Project Description +This is a simple Arduino project that reads humidity sensor value and check if it is above the threshold. + +## Hardware Components +- Arduino Uno +- DHT22 sensor + +## Circuit Description +The DHT22 sensor is connected to an Arduino Uno. The VCC pin is connected to the 5V pin on the Arduino, and the GND pin is connected to the GND2 pin. The data pin is connected to digital pin 2 on the Arduino. + +## Expected Behavior +When the Arduino powers up, it should: +1. Declare the threshold value, which is 50.0 +2. Initialize serial communication +3. Continuously read the DHT sensor's humidity value +4. Compare the humidity sensor value with the threshold, and print one of these: 'Humidity is below the threshold', 'Humidity is above the threshold' + +## Success Criteria +The test is successful when: +1. The correct compare result is printed to the serial monitor. + +## Notes for Implementation +- Serial input is always a float value. +- Threshold is 50.0. diff --git a/arduino/level2/humidity_sensor/description_no_pin.md b/arduino/level2/humidity_sensor/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..c0269ec33397bf7dcd3dc1216f3500d89759fb32 --- /dev/null +++ b/arduino/level2/humidity_sensor/description_no_pin.md @@ -0,0 +1,26 @@ +# Humidity Sensor + +## Project Description +This is a simple Arduino project that reads humidity sensor value and check if it is above the threshold. + +## Hardware Components +- Arduino Uno +- DHT22 sensor + +## Circuit Description +The DHT22 sensor is connected to an Arduino Uno. The data pin is connected to digital pin on the Arduino. + +## Expected Behavior +When the Arduino powers up, it should: +1. Declare the threshold value, which is 50.0 +2. Initialize serial communication +3. Continuously read the DHT sensor's humidity value +4. Compare the humidity sensor value with the threshold, and print one of these: 'Humidity is below the threshold', 'Humidity is above the threshold' + +## Success Criteria +The test is successful when: +1. The correct compare result is printed to the serial monitor. + +## Notes for Implementation +- Serial input is always a float value. +- Threshold is 50.0. diff --git a/arduino/level2/humidity_sensor/diagram.json b/arduino/level2/humidity_sensor/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..20cfeb45d6e47ccdb6a50691e4cdc500be2cff4b --- /dev/null +++ b/arduino/level2/humidity_sensor/diagram.json @@ -0,0 +1,57 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read humidity sensor value", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-dht22", + "id": "dht22 sensor1", + "top": -201.3, + "left": 100.2, + "attrs": { + "humidity": "64.5" + } + } + ], + "connections": [ + [ + "dht22 sensor1:VCC", + "arduino uno1:5V", + "red", + [ + "v48", + "h-134.4", + "v259.2", + "h182.4" + ] + ], + [ + "dht22 sensor1:GND", + "arduino uno1:GND.2", + "black", + [ + "v48", + "h144", + "v268.8", + "h19.2" + ] + ], + [ + "dht22 sensor1:SDA", + "arduino uno1:2", + "green", + [ + "v76.8", + "h115.3" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/humidity_sensor/diagram_breadboard.json b/arduino/level2/humidity_sensor/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..a02cc67f74cf91a80f0ddce36538652e336b20cc --- /dev/null +++ b/arduino/level2/humidity_sensor/diagram_breadboard.json @@ -0,0 +1,109 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read humidity sensor value", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -223.8, + "left": -93.2, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-dht22", + "id": "dht22 sensor1", + "top": -210.9, + "left": 100.2, + "attrs": { + "humidity": "64.5" + } + } + ], + "connections": [ + [ + "dht22 sensor1:VCC", + "breadboard1:20b.g", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:SDA", + "breadboard1:21b.g", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:NC", + "breadboard1:22b.g", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:GND", + "breadboard1:23b.g", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:20b.h", + "breadboard1:bp.16", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:21b.h", + "arduino uno1:2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:23b.h", + "breadboard1:bn.18", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:bn.1", + "arduino uno1:GND.2", + "green", + [ + "v238.7", + "h210.4" + ] + ], + [ + "breadboard1:bp.1", + "arduino uno1:5V", + "green", + [ + "v-0.9", + "h-20", + "v259.2", + "h230.4" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/humidity_sensor/platformio.ini b/arduino/level2/humidity_sensor/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..598164a9e2d3c7598b562fda5974537e4ca29102 --- /dev/null +++ b/arduino/level2/humidity_sensor/platformio.ini @@ -0,0 +1,22 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + DHT sensor library + DHT22 \ No newline at end of file diff --git a/arduino/level2/humidity_sensor/scenario.yaml b/arduino/level2/humidity_sensor/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8ed362bc965ec4e7095012af1dbebe430ad7b419 --- /dev/null +++ b/arduino/level2/humidity_sensor/scenario.yaml @@ -0,0 +1,21 @@ +author: Blind Author +description: Read humidity sensor value +name: Humidity Sensor Basic +steps: + - delay: 100ms + - set-control: + part-id: dht22 sensor1 + control: humidity + value: 30.5 + - wait-serial: "Humidity is below the threshold" + - set-control: + part-id: dht22 sensor1 + control: humidity + value: 49.7 + - wait-serial: "Humidity is below the threshold" + - set-control: + part-id: dht22 sensor1 + control: humidity + value: 68.4 + - wait-serial: "Humidity is above the threshold" +version: 1.0 diff --git a/arduino/level2/humidity_sensor/src/main.ino b/arduino/level2/humidity_sensor/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..071547e7a245bc5d98da1c420743f07881d9a550 --- /dev/null +++ b/arduino/level2/humidity_sensor/src/main.ino @@ -0,0 +1,31 @@ +/** + Read humidity sensor value and compare with the input value + 03 MAY 2025 by Blind Author +*/ + +#include "DHT.h" + +#define DHTTYPE DHT22 + +#define DHTPIN 2 + +DHT dht(DHTPIN, DHTTYPE); + +float threshold = 50.0; + +void setup() { + Serial.begin(9600); + dht.begin(); +} + +void loop() { + float humidity = dht.readHumidity(); + + if (humidity < threshold) { + Serial.println("Humidity is below the threshold"); + } else { + Serial.println("Humidity is above the threshold"); + } + + delay(1000); +} \ No newline at end of file diff --git a/arduino/level2/humidity_sensor/wokwi.toml b/arduino/level2/humidity_sensor/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level2/humidity_sensor/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level2/serial_LCD_display/description.md b/arduino/level2/serial_LCD_display/description.md new file mode 100644 index 0000000000000000000000000000000000000000..b58e2b70d37d3c4949d19d08688e95f85c3eb8c9 --- /dev/null +++ b/arduino/level2/serial_LCD_display/description.md @@ -0,0 +1,28 @@ +# LCD Display with Serial Monitor + +## Project Description +This is an Arduino project that shows serial input to the ili9341 lcd display. + +## Hardware Components +- Arduino Uno +- Ili9341 LCD Display + +## Circuit Description +Ili9341 LCD Display is connected to the Arudino Uno board. D/C, CS, MOSI, MISO, SCK pin of LCD display is connected to arduino pin 9 to 13, respectively. GND pin of LCD display is connected to arduino pin gnd1. VCC pin of LCD display is connected to arduino pin 5v. + +## Expected Behavior +When the Arduino powers up, it should: +1. Declare Adafruit_ILI9341 object +2. Begin display and change it to landscape mode (rotation 1) +3. Initialize the serial monitor +4. Continuously read the serial monitor +5. If there is input from the Serial Monitor, clear the display with a black background and print the input string at position (0, 0) in white with text size 2 +6. Also print the input string to the serial monitor + +## Success Criteria +The test is successful when: +1. Input string is successfully printed to the display, with correct position, color, and size. +2. Input string is successfully printed to the serial monitor. + +## Notes for Implementation +- Use the following libraries: , , and . diff --git a/arduino/level2/serial_LCD_display/description_no_pin.md b/arduino/level2/serial_LCD_display/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..8caccdd8f4383224198686e04a457bc0a7ee5eae --- /dev/null +++ b/arduino/level2/serial_LCD_display/description_no_pin.md @@ -0,0 +1,28 @@ +# LCD Display with Serial Monitor + +## Project Description +This is an Arduino project that shows serial input to the ili9341 lcd display. + +## Hardware Components +- Arduino Uno +- Ili9341 LCD Display + +## Circuit Description +Ili9341 LCD Display is connected to the Arudino Uno board. D/C, CS, MOSI, MISO, SCK pin of LCD display is connected to arduino digital pins. + +## Expected Behavior +When the Arduino powers up, it should: +1. Declare Adafruit_ILI9341 object +2. Begin display and change it to landscape mode (rotation 1) +3. Initialize the serial monitor +4. Continuously read the serial monitor +5. If there is input from the Serial Monitor, clear the display with a black background and print the input string at position (0, 0) in white with text size 2 +6. Also print the input string to the serial monitor + +## Success Criteria +The test is successful when: +1. Input string is successfully printed to the display, with correct position, color, and size. +2. Input string is successfully printed to the serial monitor. + +## Notes for Implementation +- Use the following libraries: , , and . diff --git a/arduino/level2/serial_LCD_display/diagram.json b/arduino/level2/serial_LCD_display/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..839860f2c914b150f24c2d948eae4febe1ebe3e0 --- /dev/null +++ b/arduino/level2/serial_LCD_display/diagram.json @@ -0,0 +1,89 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Show serial input with lcd display", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 331.89, + "left": 1.49, + "attrs": {} + }, + { + "type": "wokwi-ili9341", + "id": "ili9341 lcd display1", + "top": 5.51, + "left": 40.77, + "attrs": {} + } + ], + "connections": [ + [ + "ili9341 lcd display1:GND", + "arduino uno1:GND.1", + "black", + [ + "v22", + "h-46" + ] + ], + [ + "ili9341 lcd display1:SCK", + "arduino uno1:13", + "green", + [ + "v16", + "h-75" + ] + ], + [ + "ili9341 lcd display1:MISO", + "arduino uno1:12", + "limegreen", + [ + "v20", + "h-78" + ] + ], + [ + "ili9341 lcd display1:MOSI", + "arduino uno1:11", + "green", + [ + "v24", + "h-75" + ] + ], + [ + "ili9341 lcd display1:CS", + "arduino uno1:10", + "orange", + [ + "v32", + "h-64" + ] + ], + [ + "ili9341 lcd display1:D/C", + "arduino uno1:9", + "purple", + [ + "v36", + "h-84" + ] + ], + [ + "ili9341 lcd display1:VCC", + "arduino uno1:5V", + "red", + [ + "v24.09", + "h-98.67", + "v230.4", + "h172.8" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/serial_LCD_display/diagram_breadboard.json b/arduino/level2/serial_LCD_display/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..4bcca2a48f7916db7724fbb81a8e612fbd957fa1 --- /dev/null +++ b/arduino/level2/serial_LCD_display/diagram_breadboard.json @@ -0,0 +1,191 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Show serial input with lcd display", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": 45, + "left": -160.4, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 331.89, + "left": 1.49, + "attrs": {} + }, + { + "type": "wokwi-ili9341", + "id": "ili9341 lcd display1", + "top": -124, + "left": 47.7, + "attrs": {} + } + ], + "connections": [ + [ + "ili9341 lcd display1:VCC", + "breadboard1:25b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:GND", + "breadboard1:26b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:CS", + "breadboard1:27b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:RST", + "breadboard1:28b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:D/C", + "breadboard1:29b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:MOSI", + "breadboard1:30b.f", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:28b.j", + "arduino uno1:8", + "green", + [ + "v105.6", + "h57.6", + "v28.8" + ] + ], + [ + "ili9341 lcd display1:SCK", + "breadboard1:31b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:LED", + "breadboard1:32b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:MISO", + "breadboard1:33b.f", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:25b.i", + "breadboard1:bp.20", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:26b.i", + "breadboard1:bn.20", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:27b.j", + "arduino uno1:10", + "orange", + [ + "v105.6", + "h38.4" + ] + ], + [ + "breadboard1:29b.j", + "arduino uno1:9", + "green", + [ + "v96", + "h28.8" + ] + ], + [ + "breadboard1:30b.j", + "arduino uno1:11", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:31b.j", + "arduino uno1:13", + "green", + [ + "v67.2", + "h-28.8" + ] + ], + [ + "breadboard1:33b.j", + "arduino uno1:12", + "green", + [ + "v48", + "h-38.4" + ] + ], + [ + "breadboard1:bp.8", + "arduino uno1:5V", + "red", + [ + "v306.3", + "h191.2" + ] + ], + [ + "breadboard1:bn.12", + "arduino uno1:GND.1", + "black", + [ + "v75.5", + "h104.8" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/serial_LCD_display/platformio.ini b/arduino/level2/serial_LCD_display/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..b50154ebd53c2b66823f9f470aba4ff925f6d00a --- /dev/null +++ b/arduino/level2/serial_LCD_display/platformio.ini @@ -0,0 +1,21 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + Adafruit ILI9341 \ No newline at end of file diff --git a/arduino/level2/serial_LCD_display/scenario.yaml b/arduino/level2/serial_LCD_display/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6bc6f9029a1341b66f69d238524884ccf306e13c --- /dev/null +++ b/arduino/level2/serial_LCD_display/scenario.yaml @@ -0,0 +1,16 @@ +author: Blind Author +description: Use LCD display +name: LCD Display Basic +steps: +- delay: 4000ms +- write-serial: Hello +- wait-serial: Hello +- take-screenshot: + part-id: ili9341 lcd display1 + compare-with: screenshots/0.png +- write-serial: How are you? +- wait-serial: How are you? +- take-screenshot: + part-id: ili9341 lcd display1 + compare-with: screenshots/1.png +version: 1.0 diff --git a/arduino/level2/serial_LCD_display/screenshots/0.png b/arduino/level2/serial_LCD_display/screenshots/0.png new file mode 100644 index 0000000000000000000000000000000000000000..0bf01a3bfbc183b3154130513b6d288ba9872a44 --- /dev/null +++ b/arduino/level2/serial_LCD_display/screenshots/0.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:41878e8d1f076baaab5f873437d68a830ef349802822f7592398d8c470ce5d2b +size 1082 diff --git a/arduino/level2/serial_LCD_display/screenshots/1.png b/arduino/level2/serial_LCD_display/screenshots/1.png new file mode 100644 index 0000000000000000000000000000000000000000..d2140495423367af7bc2763a648d697239d640c2 --- /dev/null +++ b/arduino/level2/serial_LCD_display/screenshots/1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c6430d69e81d8c0f51f82d8656ede154d1c6636c52d59a9f7b7a6e73c3cbe309 +size 1361 diff --git a/arduino/level2/serial_LCD_display/src/main.ino b/arduino/level2/serial_LCD_display/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..79342ccb34f9fd95f9c34241ae5799a9d883ba47 --- /dev/null +++ b/arduino/level2/serial_LCD_display/src/main.ino @@ -0,0 +1,37 @@ +/** + Show serial input in ili9431 lcd display + 05 MAY 2025 by Blind Author +*/ + +#include +#include +#include + +#define TFT_CS 10 +#define TFT_DC 9 +#define TFT_RST 8 + +Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); + +void setup() { + Serial.begin(9600); + + tft.begin(); + tft.setRotation(1); +} + +void loop() { + if (Serial.available() > 0) { + tft.fillScreen(ILI9341_BLACK); + + String input = Serial.readString(); + input.trim(); + Serial.println(input); + + tft.setCursor(0, 0); + tft.setTextColor(ILI9341_WHITE); + tft.setTextSize(2); + tft.println(input); + } + +} \ No newline at end of file diff --git a/arduino/level2/serial_LCD_display/wokwi.toml b/arduino/level2/serial_LCD_display/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level2/serial_LCD_display/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level2/serial_RGB_led/description.md b/arduino/level2/serial_RGB_led/description.md new file mode 100644 index 0000000000000000000000000000000000000000..f7c4f3ad0cb80619c0778eb5e8d5fe8d4555d78e --- /dev/null +++ b/arduino/level2/serial_RGB_led/description.md @@ -0,0 +1,33 @@ +# Serial RGB LED + +## Project Description +This is a simple Arduino project that control RGB LED with serial monitor. + +## Hardware Components +- Arduino Uno +- RGB LED +- 220Ω resistor * 3 + +## Circuit Description +The R, G, B pin of the RGB LED is connected to the pin4, pin3, pin2 of the Arduino Uno through a 220Ω current-limiting resistor. The common pin of the RGB LED is connected to 5V. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set LED pins to OUTPUT +2. Initialize serial monitor +3. Continuously check if the serial monitor is available, and read until '\n' appears. +4. Check if the input contains "Red", "Green", or "Blue", and fully turn on the corresponding color on the RGB LED if it does. + +## Success Criteria +The test is successful when: +1. The input colors and the corresponding RGB LED pin state line up perfectly. + +## Notes for Implementation +- The common pin of the RGB LED is an anode. +- The input is given as a comma-separated list, such as "Red, Green". + +## Variants +This project may have different variants with the LED conntected to different pins. + +## Test Inputs +Test input values are: "Red", "Red, Green", "Green, Blue" \ No newline at end of file diff --git a/arduino/level2/serial_RGB_led/description_no_pin.md b/arduino/level2/serial_RGB_led/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..91157cc7fc283d813378f41b2a27a4a5ec1a3e23 --- /dev/null +++ b/arduino/level2/serial_RGB_led/description_no_pin.md @@ -0,0 +1,33 @@ +# Serial RGB LED + +## Project Description +This is a simple Arduino project that control RGB LED with serial monitor. + +## Hardware Components +- Arduino Uno +- RGB LED +- 220Ω resistor * 3 + +## Circuit Description +The R, G, B pin of the RGB LED is connected to the arduino digital pins through a 220Ω current-limiting resistor. RGB LED has common anode configuration. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set LED pins to OUTPUT +2. Initialize serial monitor +3. Continuously check if the serial monitor is available, and read until '\n' appears. +4. Check if the input contains "Red", "Green", or "Blue", and fully turn on the corresponding color on the RGB LED if it does. + +## Success Criteria +The test is successful when: +1. The input colors and the corresponding RGB LED pin state line up perfectly. + +## Notes for Implementation +- The common pin of the RGB LED is an anode. +- The input is given as a comma-separated list, such as "Red, Green". + +## Variants +This project may have different variants with the LED conntected to different pins. + +## Test Inputs +Test input values are: "Red", "Red, Green", "Green, Blue" \ No newline at end of file diff --git a/arduino/level2/serial_RGB_led/diagram.json b/arduino/level2/serial_RGB_led/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..fc3cbe386b986a1312346c2a9df9d8255faf604f --- /dev/null +++ b/arduino/level2/serial_RGB_led/diagram.json @@ -0,0 +1,120 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Control RGB LED with serial monitor", + "config": { + "R_pin": 4, + "G_pin": 3, + "B_pin": 2 + }, + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 115.8, + "left": 527.4, + "attrs": {} + }, + { + "type": "wokwi-rgb-led", + "id": "rgb led1", + "top": -92, + "left": 644.3, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 4.8, + "left": 623.45, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": 4.8, + "left": 642.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 4.8, + "left": 661.85, + "rotate": 90, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "rgb led1:COM", + "arduino uno1:5V", + "green", + [ + "v0" + ] + ], + [ + "rgb led1:R", + "resistor1:1", + "green", + [ + "v19.2" + ] + ], + [ + "resistor2:1", + "rgb led1:G", + "green", + [ + "h0" + ] + ], + [ + "resistor3:1", + "rgb led1:B", + "green", + [ + "h0" + ] + ], + [ + "resistor1:2", + "arduino uno1:4", + "green", + [ + "h0", + "v66", + "h86.4" + ] + ], + [ + "resistor2:2", + "arduino uno1:3", + "green", + [ + "h0", + "v56.4", + "h76.8" + ] + ], + [ + "resistor3:2", + "arduino uno1:2", + "green", + [ + "h0", + "v46.8", + "h76.8" + ] + ] + ] +} \ No newline at end of file diff --git a/arduino/level2/serial_RGB_led/diagram_breadboard.json b/arduino/level2/serial_RGB_led/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..1e4bd7ddfcca9f4e6d0a551b86e31ac5b8e17204 --- /dev/null +++ b/arduino/level2/serial_RGB_led/diagram_breadboard.json @@ -0,0 +1,179 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Control RGB LED with serial monitor", + "config": { + "R_pin": 4, + "G_pin": 3, + "B_pin": 2 + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -137.4, + "left": 502, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 115.8, + "left": 527.4, + "attrs": {} + }, + { + "type": "wokwi-rgb-led", + "id": "rgb led1", + "top": -120.8, + "left": 653.9, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -33.6, + "left": 633.05, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -33.6, + "left": 652.25, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -33.6, + "left": 661.85, + "rotate": 90, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "rgb led1:R", + "breadboard1:15t.b", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:COM", + "breadboard1:16t.c", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:G", + "breadboard1:17t.b", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:B", + "breadboard1:18t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:15t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:15b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:17t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:17b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:18t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:18b.h", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:17b.j", + "arduino uno1:3", + "green", + [ + "v86.4", + "h76.8" + ] + ], + [ + "breadboard1:16t.e", + "arduino uno1:5V", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:15b.j", + "arduino uno1:4", + "green", + [ + "v0" + ] + ], + [ + "arduino uno1:2", + "breadboard1:18b.j", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/serial_RGB_led/platformio.ini b/arduino/level2/serial_RGB_led/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level2/serial_RGB_led/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level2/serial_RGB_led/scenario.yaml b/arduino/level2/serial_RGB_led/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b85783fb3f5524151e10ad36969d18d74831db3b --- /dev/null +++ b/arduino/level2/serial_RGB_led/scenario.yaml @@ -0,0 +1,60 @@ +author: Blind Author +description: Control RGB LED with serial monitor +name: Serial RGB LED +steps: +- delay: 10ms +- write-serial: Red +- delay: 1000ms +- expect-pin: + part-id: rgb led1 + pin: R + value: 0 +- expect-pin: + part-id: rgb led1 + pin: G + value: 1 +- expect-pin: + part-id: rgb led1 + pin: B + value: 1 +- expect-pin: + part-id: rgb led1 + pin: COM + value: 1 +- write-serial: Red, Green +- delay: 1000ms +- expect-pin: + part-id: rgb led1 + pin: R + value: 0 +- expect-pin: + part-id: rgb led1 + pin: G + value: 0 +- expect-pin: + part-id: rgb led1 + pin: B + value: 1 +- expect-pin: + part-id: rgb led1 + pin: COM + value: 1 +- write-serial: Green, Blue +- delay: 1000ms +- expect-pin: + part-id: rgb led1 + pin: R + value: 1 +- expect-pin: + part-id: rgb led1 + pin: G + value: 0 +- expect-pin: + part-id: rgb led1 + pin: B + value: 0 +- expect-pin: + part-id: rgb led1 + pin: COM + value: 1 +version: 1.0 diff --git a/arduino/level2/serial_RGB_led/src/main.ino b/arduino/level2/serial_RGB_led/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..d1404e72809f19a6dac2e27f67d408c7bf32a538 --- /dev/null +++ b/arduino/level2/serial_RGB_led/src/main.ino @@ -0,0 +1,34 @@ +/** + Control RGB LED with serial monitor + 10 APR 2025 by Blind Author +*/ +const int LED_R = 4; +const int LED_G = 3; +const int LED_B = 2; + +void setup() { + pinMode(LED_B, OUTPUT); + pinMode(LED_G, OUTPUT); + pinMode(LED_R, OUTPUT); + + Serial.begin(9600); +} + +void loop() { + if (Serial.available() > 0) { + String input = Serial.readStringUntil('\n'); + input.trim(); + + if (input.indexOf("Red") != -1) { + analogWrite(LED_R, 0); + } else analogWrite(LED_R, 255); + + if (input.indexOf("Green") != -1) { + analogWrite(LED_G, 0); + } else analogWrite(LED_G, 255); + + if (input.indexOf("Blue") != -1) { + analogWrite(LED_B, 0); + } else analogWrite(LED_B, 255); + } +} \ No newline at end of file diff --git a/arduino/level2/serial_RGB_led/wokwi.toml b/arduino/level2/serial_RGB_led/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level2/serial_RGB_led/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level2/serial_bar_led/description.md b/arduino/level2/serial_bar_led/description.md new file mode 100644 index 0000000000000000000000000000000000000000..86c4492d8182f46c1812d34abbb7bd460a4cf55c --- /dev/null +++ b/arduino/level2/serial_bar_led/description.md @@ -0,0 +1,35 @@ +# Serial Bar LED + +## Project Description +This is a simple Arduino project that controls bar graph LED with serial monitor. + +## Hardware Components +- Arduino Uno +- bar graph LED +- 220Ω resistor * 10 + +## Circuit Description +Anode pins 1~10 of bar graph LED are connected to pin2, pin3, pin4, pin5, pin6, pin7, pin8, pin9, pin10, pin11, respectively. The cathode pins 1 through 10 of the bar graph LED are connected to gnd1 through 220kΩ resistors. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set pin2, pin3, pin4, pin5, pin6, pin7, pin8, pin9, pin10, pin11 pin mode as OUTPUT +2. Configure serial monitor +3. Continuously read the serial input, which is the threshold +4. Turn on the LEDs only up to the threshold + +## Success Criteria +The test is successful when: +1. Anode of the bar LED pins whose number is smaller than the threshold receive HIGH signals, while greater pins receive LOW signals. + +## Notes for Implementation +- Serial input is an integer. + +## Variants +This project may have different variants with the LED connected to different pins or using LEDs of different colors. + +## Test Inputs +Test input values are: 6, 3, 9 + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level2/serial_bar_led/description_no_pin.md b/arduino/level2/serial_bar_led/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..24f062a02742677b6af186f2a6979ab070afbda6 --- /dev/null +++ b/arduino/level2/serial_bar_led/description_no_pin.md @@ -0,0 +1,35 @@ +# Serial Bar LED + +## Project Description +This is a simple Arduino project that controls bar graph LED with serial monitor. + +## Hardware Components +- Arduino Uno +- bar graph LED +- 220Ω resistor * 10 + +## Circuit Description +Anode pins 1~10 of bar graph LED are connected to arduino digital pins. The cathode pins 1 through 10 of the bar graph LED are connected to ground through 220kΩ resistors. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set digital pin modes as OUTPUT +2. Configure serial monitor +3. Continuously read the serial input, which is the threshold +4. Turn on the LEDs only up to the threshold + +## Success Criteria +The test is successful when: +1. Anode of the bar LED pins whose number is smaller than the threshold receive HIGH signals, while greater pins receive LOW signals. + +## Notes for Implementation +- Serial input is an integer. + +## Variants +This project may have different variants with the LED connected to different pins or using LEDs of different colors. + +## Test Inputs +Test input values are: 6, 3, 9 + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level2/serial_bar_led/diagram.json b/arduino/level2/serial_bar_led/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..a26433bfc66a96cb2402dc997efed0a3b56ce94a --- /dev/null +++ b/arduino/level2/serial_bar_led/diagram.json @@ -0,0 +1,400 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Control bar LED with serial monitor", + "config": { + "1_pin": 2, + "2_pin": 3, + "3_pin": 4, + "4_pin": 5, + "5_pin": 6, + "6_pin": 7, + "7_pin": 8, + "8_pin": 9, + "9_pin": 10, + "10_pin": 11, + "led_color": "lime", + "gnd_pin": "GND.1" + }, + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 67.8, + "left": 517.8, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 109.85, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": 129.05, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 119.45, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-led-bar-graph", + "id": "bar graph led1", + "top": 110.4, + "left": 849.6, + "attrs": { + "color": "lime" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 138.65, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": 148.25, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": 157.85, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": 167.45, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": 177.05, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor9", + "top": 186.65, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor10", + "top": 196.25, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "resistor1:2", + "bar graph led1:C1", + "green", + [ + "v0" + ] + ], + [ + "resistor3:2", + "bar graph led1:C2", + "green", + [ + "v0" + ] + ], + [ + "resistor2:2", + "bar graph led1:C3", + "green", + [ + "v0" + ] + ], + [ + "resistor4:2", + "bar graph led1:C4", + "green", + [ + "v0" + ] + ], + [ + "resistor5:2", + "bar graph led1:C5", + "green", + [ + "v0" + ] + ], + [ + "resistor6:2", + "bar graph led1:C6", + "green", + [ + "v0" + ] + ], + [ + "resistor7:2", + "bar graph led1:C7", + "green", + [ + "v0" + ] + ], + [ + "resistor8:2", + "bar graph led1:C8", + "green", + [ + "v0" + ] + ], + [ + "resistor9:2", + "bar graph led1:C9", + "green", + [ + "v0" + ] + ], + [ + "resistor10:2", + "bar graph led1:C10", + "green", + [ + "v0" + ] + ], + [ + "arduino uno1:GND.1", + "resistor10:1", + "black", + [ + "v-28.8", + "h365.1", + "v153.6" + ] + ], + [ + "arduino uno1:GND.1", + "resistor9:1", + "black", + [ + "v-28.8", + "h365.1", + "v144" + ] + ], + [ + "arduino uno1:GND.1", + "resistor8:1", + "black", + [ + "v-28.8", + "h365.1", + "v134.4" + ] + ], + [ + "arduino uno1:GND.1", + "resistor7:1", + "black", + [ + "v-28.8", + "h365.1", + "v124.8" + ] + ], + [ + "arduino uno1:GND.1", + "resistor6:1", + "black", + [ + "v-28.8", + "h365.1", + "v115.2" + ] + ], + [ + "arduino uno1:GND.1", + "resistor5:1", + "black", + [ + "v-28.8", + "h365.1", + "v105.6" + ] + ], + [ + "arduino uno1:GND.1", + "resistor4:1", + "black", + [ + "v-28.8", + "h365.1", + "v96" + ] + ], + [ + "arduino uno1:GND.1", + "resistor2:1", + "black", + [ + "v-28.8", + "h365.1", + "v86.4" + ] + ], + [ + "arduino uno1:GND.1", + "resistor3:1", + "black", + [ + "v-28.8", + "h365.1", + "v76.8" + ] + ], + [ + "arduino uno1:GND.1", + "resistor1:1", + "black", + [ + "v-28.8", + "h365.1", + "v67.2" + ] + ], + [ + "bar graph led1:A1", + "arduino uno1:2", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A2", + "arduino uno1:3", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A3", + "arduino uno1:4", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A4", + "arduino uno1:5", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A5", + "arduino uno1:6", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A6", + "arduino uno1:7", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A7", + "arduino uno1:8", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A8", + "arduino uno1:9", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A9", + "arduino uno1:10", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A10", + "arduino uno1:11", + "green", + [ + "h0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/serial_bar_led/diagram_breadboard.json b/arduino/level2/serial_bar_led/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..76bdc1af2e708a417f271c6771814d3a27492cc2 --- /dev/null +++ b/arduino/level2/serial_bar_led/diagram_breadboard.json @@ -0,0 +1,608 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Control bar LED with serial monitor", + "config": { + "1_pin": 2, + "2_pin": 3, + "3_pin": 4, + "4_pin": 5, + "5_pin": 6, + "6_pin": 7, + "7_pin": 8, + "8_pin": 9, + "9_pin": 10, + "10_pin": 11, + "led_color": "lime", + "gnd_pin": "GND.1" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -156.6, + "left": 406, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 67.8, + "left": 623.4, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -34.45, + "left": 652.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-led-bar-graph", + "id": "bar graph led1", + "top": -101, + "left": 734.6, + "rotate": 90, + "attrs": { + "color": "lime" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -24.85, + "left": 662.4, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -15.25, + "left": 672, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 4.8, + "left": 709.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": -34.45, + "left": 796.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -24.85, + "left": 787.2, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": -15.25, + "left": 777.6, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": 4.8, + "left": 738.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor9", + "top": 4.8, + "left": 719.45, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor10", + "top": 4.8, + "left": 729.05, + "rotate": 90, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "bar graph led1:A1", + "breadboard1:39t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A2", + "breadboard1:38t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A3", + "breadboard1:37t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A4", + "breadboard1:36t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A5", + "breadboard1:35t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A6", + "breadboard1:34t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A7", + "breadboard1:33t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A8", + "breadboard1:32t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A9", + "breadboard1:31t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A10", + "breadboard1:30t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C1", + "breadboard1:39b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C2", + "breadboard1:38b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C3", + "breadboard1:37b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C4", + "breadboard1:36b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C5", + "breadboard1:35b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C6", + "breadboard1:34b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C7", + "breadboard1:33b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C8", + "breadboard1:32b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C9", + "breadboard1:31b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C10", + "breadboard1:30b.f", + "", + [ + "$bb" + ] + ], + [ + "resistor5:1", + "breadboard1:39b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor5:2", + "breadboard1:45b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor6:1", + "breadboard1:38b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor6:2", + "breadboard1:44b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor7:1", + "breadboard1:37b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor7:2", + "breadboard1:43b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:26b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:32b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:25b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:31b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:24b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:30b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor9:1", + "breadboard1:34b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor9:2", + "breadboard1:bn.27", + "", + [ + "$bb" + ] + ], + [ + "resistor10:1", + "breadboard1:35b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor10:2", + "breadboard1:bn.28", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:43b.j", + "breadboard1:bn.35", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:44b.i", + "breadboard1:bn.36", + "green", + [ + "v0" + ] + ], + [ + "resistor8:1", + "breadboard1:36b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor8:2", + "breadboard1:bn.29", + "", + [ + "$bb" + ] + ], + [ + "resistor4:1", + "breadboard1:33b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor4:2", + "breadboard1:bn.26", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:45b.h", + "breadboard1:bn.37", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:26b.j", + "breadboard1:bn.21", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:25b.i", + "breadboard1:bn.20", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:24b.h", + "breadboard1:bn.19", + "green", + [ + "v0" + ] + ], + [ + "arduino uno1:GND.1", + "breadboard1:bn.24", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:30t.d", + "arduino uno1:11", + "green", + [ + "v-105.6", + "h48" + ] + ], + [ + "breadboard1:31t.d", + "arduino uno1:10", + "green", + [ + "v-115.2", + "h57.6" + ] + ], + [ + "breadboard1:32t.d", + "arduino uno1:9", + "green", + [ + "v-124.8", + "h57.6" + ] + ], + [ + "breadboard1:33t.d", + "arduino uno1:8", + "green", + [ + "v-134.4", + "h57.6" + ] + ], + [ + "breadboard1:34t.d", + "arduino uno1:7", + "green", + [ + "v-96", + "h57.6" + ] + ], + [ + "breadboard1:35t.d", + "arduino uno1:6", + "green", + [ + "v-105.6", + "h57.6" + ] + ], + [ + "breadboard1:36t.d", + "arduino uno1:5", + "green", + [ + "v-115.2", + "h67.2" + ] + ], + [ + "breadboard1:37t.d", + "arduino uno1:4", + "green", + [ + "v-86.4", + "h67.2" + ] + ], + [ + "breadboard1:38t.d", + "arduino uno1:3", + "green", + [ + "v-76.8", + "h67.2" + ] + ], + [ + "breadboard1:39t.d", + "arduino uno1:2", + "green", + [ + "v-96", + "h67.2" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/serial_bar_led/platformio.ini b/arduino/level2/serial_bar_led/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level2/serial_bar_led/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level2/serial_bar_led/scenario.yaml b/arduino/level2/serial_bar_led/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d0ae78ab45e5ac1834f16ccab202b873cf65329b --- /dev/null +++ b/arduino/level2/serial_bar_led/scenario.yaml @@ -0,0 +1,252 @@ +author: Blind Author +description: Control bar LED with serial monitor +name: Serial bar LED +steps: +- delay: 10ms +- write-serial: '6' +- delay: 1000ms +- expect-pin: + part-id: bar graph led1 + pin: C1 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C2 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C3 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C4 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C5 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C6 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C7 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C8 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C9 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C10 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A1 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A2 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A3 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A4 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A5 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A6 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A7 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A8 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A9 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A10 + value: 0 +- write-serial: '3' +- delay: 1000ms +- expect-pin: + part-id: bar graph led1 + pin: C1 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C2 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C3 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C4 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C5 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C6 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C7 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C8 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C9 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C10 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A1 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A2 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A3 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A4 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A5 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A6 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A7 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A8 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A9 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A10 + value: 0 +- write-serial: '9' +- delay: 1000ms +- expect-pin: + part-id: bar graph led1 + pin: C1 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C2 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C3 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C4 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C5 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C6 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C7 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C8 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C9 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C10 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A1 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A2 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A3 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A4 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A5 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A6 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A7 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A8 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A9 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A10 + value: 0 +version: 1.0 diff --git a/arduino/level2/serial_bar_led/src/main.ino b/arduino/level2/serial_bar_led/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..523be105948705f19d32f2f5684e6babad35c0bf --- /dev/null +++ b/arduino/level2/serial_bar_led/src/main.ino @@ -0,0 +1,31 @@ +/** + Control bar LED with serial monitor + 10 APR 2025 by Blind Author +*/ + +int pinList[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; + +int threshold = 0; + +void setup() { + for (int i=0; i<10; i++) { + pinMode(pinList[i], OUTPUT); + } + + Serial.begin(9600); +} + +void loop() { + if (Serial.available()) { + threshold = Serial.parseInt(); + } + + for (int i=0; i<10; i++) { + if (i < threshold) { + digitalWrite(pinList[i], HIGH); + } else { + digitalWrite(pinList[i], LOW); + } + } + delay(100); +} \ No newline at end of file diff --git a/arduino/level2/serial_bar_led/wokwi.toml b/arduino/level2/serial_bar_led/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level2/serial_bar_led/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level2/serial_monitor/description.md b/arduino/level2/serial_monitor/description.md new file mode 100644 index 0000000000000000000000000000000000000000..a152ea562d890936e1287456d0aa22cf2778da7a --- /dev/null +++ b/arduino/level2/serial_monitor/description.md @@ -0,0 +1,25 @@ +# Serial Monitor + +## Project Description +This is a simple Arduino project that read and write with serial monitor. + +## Hardware Components +- Arduino Uno + +## Circuit Description +There is no extra circuit. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Continuously read the serial monitor, and print back the value in the format: "Received: {value}". + +## Success Criteria +The test is successful when: +1. The displayed serial message is same with the written value. + +## Notes for Implementation +- In the loop function, read the serial monitor if it is available, and print it back to the serial monitor. + +## Variants +This project dosen't have any variants. \ No newline at end of file diff --git a/arduino/level2/serial_monitor/description_no_pin.md b/arduino/level2/serial_monitor/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..a152ea562d890936e1287456d0aa22cf2778da7a --- /dev/null +++ b/arduino/level2/serial_monitor/description_no_pin.md @@ -0,0 +1,25 @@ +# Serial Monitor + +## Project Description +This is a simple Arduino project that read and write with serial monitor. + +## Hardware Components +- Arduino Uno + +## Circuit Description +There is no extra circuit. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Continuously read the serial monitor, and print back the value in the format: "Received: {value}". + +## Success Criteria +The test is successful when: +1. The displayed serial message is same with the written value. + +## Notes for Implementation +- In the loop function, read the serial monitor if it is available, and print it back to the serial monitor. + +## Variants +This project dosen't have any variants. \ No newline at end of file diff --git a/arduino/level2/serial_monitor/diagram.json b/arduino/level2/serial_monitor/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..3faff40bf7d65024e436ebfce3a11829830c91fd --- /dev/null +++ b/arduino/level2/serial_monitor/diagram.json @@ -0,0 +1,15 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read and write serial monitor", + "config": {}, + "parts": [ + { + "id": "arduino uno1", + "type": "wokwi-arduino-uno", + "top": 120, + "left": 20 + } + ], + "connections": [] +} \ No newline at end of file diff --git a/arduino/level2/serial_monitor/diagram_breadboard.json b/arduino/level2/serial_monitor/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..7414e549260da8629b078d2578ac6ef8ff7fe1c3 --- /dev/null +++ b/arduino/level2/serial_monitor/diagram_breadboard.json @@ -0,0 +1,22 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read and write serial monitor", + "config": {}, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -300.6, + "left": 214, + "attrs": {} + }, + { + "id": "arduino uno1", + "type": "wokwi-arduino-uno", + "top": 120, + "left": 20 + } + ], + "connections": [] +} \ No newline at end of file diff --git a/arduino/level2/serial_monitor/diagram_breadboard_shdf.json b/arduino/level2/serial_monitor/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..551aa77698e511cd00142bb2f3e21d36f11df355 --- /dev/null +++ b/arduino/level2/serial_monitor/diagram_breadboard_shdf.json @@ -0,0 +1,13 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + } + ], + "connections": [] +} \ No newline at end of file diff --git a/arduino/level2/serial_monitor/diagram_shdf.json b/arduino/level2/serial_monitor/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..24d181878a2d2c0464e4dc210190823c31d6e9d8 --- /dev/null +++ b/arduino/level2/serial_monitor/diagram_shdf.json @@ -0,0 +1,9 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + } + ], + "connections": [] +} \ No newline at end of file diff --git a/arduino/level2/serial_monitor/platformio.ini b/arduino/level2/serial_monitor/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level2/serial_monitor/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level2/serial_monitor/scenario.yaml b/arduino/level2/serial_monitor/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1b07ec500f488cda7a74af904f890aed5523b587 --- /dev/null +++ b/arduino/level2/serial_monitor/scenario.yaml @@ -0,0 +1,26 @@ +author: Blind Author +description: Read and write to serial monitor +name: Serial Monitor +steps: +- delay: 10ms +- write-serial: A +- wait-serial: 'Received: A' +- delay: 50ms +- write-serial: R +- wait-serial: 'Received: R' +- delay: 50ms +- write-serial: D +- wait-serial: 'Received: D' +- delay: 50ms +- write-serial: U +- wait-serial: 'Received: U' +- delay: 50ms +- write-serial: I +- wait-serial: 'Received: I' +- delay: 50ms +- write-serial: N +- wait-serial: 'Received: N' +- delay: 50ms +- write-serial: O +- wait-serial: 'Received: O' +version: 1.0 diff --git a/arduino/level2/serial_monitor/src/main.ino b/arduino/level2/serial_monitor/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..acdd13f2cad3fc7af5c0b01dddae08843de02c77 --- /dev/null +++ b/arduino/level2/serial_monitor/src/main.ino @@ -0,0 +1,18 @@ +/** + Read and write to serial monitor + 1 APR 2025 by Blind Author +*/ + +void setup() +{ + Serial.begin(9600); +} + +void loop() +{ + if (Serial.available()) { + char ch = Serial.read(); + Serial.print("Received: "); + Serial.println(ch); + } +} \ No newline at end of file diff --git a/arduino/level2/serial_monitor/wokwi.toml b/arduino/level2/serial_monitor/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level2/serial_monitor/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level2/temperature_sensor/description.md b/arduino/level2/temperature_sensor/description.md new file mode 100644 index 0000000000000000000000000000000000000000..2b084b3ee2c5bec9a59cc300407ef853e8619f50 --- /dev/null +++ b/arduino/level2/temperature_sensor/description.md @@ -0,0 +1,26 @@ +# Temperature Sensor + +## Project Description +This is a simple Arduino project that reads temperature sensor value and check if it is above the threshold. + +## Hardware Components +- Arduino Uno +- DHT22 sensor + +## Circuit Description +The DHT22 sensor is connected to an Arduino Uno. The VCC pin is connected to the 5V pin on the Arduino, and the GND pin is connected to the GND2 pin. The data pin is connected to digital pin 2 on the Arduino. + +## Expected Behavior +When the Arduino powers up, it should: +1. Declare the threshold value, which is 30.0 +2. Initialize serial communication +3. Continuously read the DHT sensor's temperature value +4. Compare the temperature sensor value with the threshold, and print one of these: 'Temperature is below the threshold', 'Temperature is above the threshold' + +## Success Criteria +The test is successful when: +1. The correct compare result is printed to the serial monitor. + +## Notes for Implementation +- Serial input is always a float value. +- Threshold is 30.0. diff --git a/arduino/level2/temperature_sensor/description_no_pin.md b/arduino/level2/temperature_sensor/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..b7319c769460bacf039913bba495ff11bd02333b --- /dev/null +++ b/arduino/level2/temperature_sensor/description_no_pin.md @@ -0,0 +1,26 @@ +# Temperature Sensor + +## Project Description +This is a simple Arduino project that reads temperature sensor value and check if it is above the threshold. + +## Hardware Components +- Arduino Uno +- DHT22 sensor + +## Circuit Description +The DHT22 sensor is connected to an Arduino Uno. The data pin is connected to digital pin on the Arduino. + +## Expected Behavior +When the Arduino powers up, it should: +1. Declare the threshold value, which is 30.0 +2. Initialize serial communication +3. Continuously read the DHT sensor's temperature value +4. Compare the temperature sensor value with the threshold, and print one of these: 'Temperature is below the threshold', 'Temperature is above the threshold' + +## Success Criteria +The test is successful when: +1. The correct compare result is printed to the serial monitor. + +## Notes for Implementation +- Serial input is always a float value. +- Threshold is 30.0. diff --git a/arduino/level2/temperature_sensor/diagram.json b/arduino/level2/temperature_sensor/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..618a2605a2ac47104e1cafe5e0bc7c8b747f823b --- /dev/null +++ b/arduino/level2/temperature_sensor/diagram.json @@ -0,0 +1,57 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read temperature sensor value", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-dht22", + "id": "dht22 sensor1", + "top": -201.3, + "left": 100.2, + "attrs": { + "humidity": "64.5" + } + } + ], + "connections": [ + [ + "dht22 sensor1:VCC", + "arduino uno1:5V", + "red", + [ + "v48", + "h-134.4", + "v259.2", + "h182.4" + ] + ], + [ + "dht22 sensor1:GND", + "arduino uno1:GND.2", + "black", + [ + "v48", + "h144", + "v268.8", + "h19.2" + ] + ], + [ + "dht22 sensor1:SDA", + "arduino uno1:2", + "green", + [ + "v76.8", + "h115.3" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/temperature_sensor/diagram_breadboard.json b/arduino/level2/temperature_sensor/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..d818b24aa9d8a3859b7c0ced81033d79de371eb1 --- /dev/null +++ b/arduino/level2/temperature_sensor/diagram_breadboard.json @@ -0,0 +1,109 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read temperature sensor value", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -223.8, + "left": -93.2, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-dht22", + "id": "dht22 sensor1", + "top": -210.9, + "left": 100.2, + "attrs": { + "humidity": "64.5" + } + } + ], + "connections": [ + [ + "dht22 sensor1:VCC", + "breadboard1:20b.g", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:SDA", + "breadboard1:21b.g", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:NC", + "breadboard1:22b.g", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:GND", + "breadboard1:23b.g", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:20b.h", + "breadboard1:bp.16", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:21b.h", + "arduino uno1:2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:23b.h", + "breadboard1:bn.18", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:bn.1", + "arduino uno1:GND.2", + "green", + [ + "v238.7", + "h210.4" + ] + ], + [ + "breadboard1:bp.1", + "arduino uno1:5V", + "green", + [ + "v-0.9", + "h-20", + "v259.2", + "h230.4" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level2/temperature_sensor/platformio.ini b/arduino/level2/temperature_sensor/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..598164a9e2d3c7598b562fda5974537e4ca29102 --- /dev/null +++ b/arduino/level2/temperature_sensor/platformio.ini @@ -0,0 +1,22 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + DHT sensor library + DHT22 \ No newline at end of file diff --git a/arduino/level2/temperature_sensor/scenario.yaml b/arduino/level2/temperature_sensor/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..92a9c25b648f2276bc2219de90f52a9eec1c0fbd --- /dev/null +++ b/arduino/level2/temperature_sensor/scenario.yaml @@ -0,0 +1,21 @@ +author: Blind Author +description: Read temperature sensor value +name: Temperature Sensor Basic +steps: + - delay: 100ms + - set-control: + part-id: dht22 sensor1 + control: temperature + value: 1.5 + - wait-serial: "Temperature is below the threshold" + - set-control: + part-id: dht22 sensor1 + control: temperature + value: 22.5 + - wait-serial: "Temperature is below the threshold" + - set-control: + part-id: dht22 sensor1 + control: temperature + value: 39.5 + - wait-serial: "Temperature is above the threshold" +version: 1.0 diff --git a/arduino/level2/temperature_sensor/src/main.ino b/arduino/level2/temperature_sensor/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..fc1d16c17821913fc518f44857a87a01568e31e4 --- /dev/null +++ b/arduino/level2/temperature_sensor/src/main.ino @@ -0,0 +1,31 @@ +/** + Read temperature sensor value and compare with the input value + 03 MAY 2025 by Blind Author +*/ + +#include "DHT.h" + +#define DHTTYPE DHT22 + +#define DHTPIN 2 + +DHT dht(DHTPIN, DHTTYPE); + +float threshold = 30.0; + +void setup() { + Serial.begin(9600); + dht.begin(); +} + +void loop() { + float temperature = dht.readTemperature(); + + if (temperature < threshold) { + Serial.println("Temperature is below the threshold"); + } else { + Serial.println("Temperature is above the threshold"); + } + + delay(1000); +} \ No newline at end of file diff --git a/arduino/level2/temperature_sensor/wokwi.toml b/arduino/level2/temperature_sensor/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level2/temperature_sensor/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level3/4_digit_7_segment_display/description.md b/arduino/level3/4_digit_7_segment_display/description.md new file mode 100644 index 0000000000000000000000000000000000000000..c19383ad36943e93e32ab8e00ac9f287613f8607 --- /dev/null +++ b/arduino/level3/4_digit_7_segment_display/description.md @@ -0,0 +1,26 @@ +# 4-digit 7-segment Display + +## Project Description +This is an Arduino project that show numbers with 4-digit 7-segment display. + +## Hardware Components +- Arduino Uno +- 4-digit 7-segment display + +## Circuit Description +Circuit is designed to use a 4-digit 7-segment display. The 4-digit 7-segment display is a common anode type, so the common pin is connected to 5V. The A to G and DP pins are connected to Arduino digital pins 2 to 9. The DIG1 to DIG4 pins are connected to Arduino digital pins 10 to 13. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set 2~13 pin as an output. +2. Taking into account that the display is common anode, display the number 1 on digit1, 2 on digit2, 3 on digit3, and 4 on digit4, in order, with an 1000ms delay between each step. + +## Success Criteria +The test is successful when: +1. The 4-digit 7-segment display shows 1, 2, 3, and 4 in order. + +## Notes for Implementation +- The 4-digit 7-segment display is a common anode type. + +## Variants +This project may have different variants with the segment pins connected to the different pins. \ No newline at end of file diff --git a/arduino/level3/4_digit_7_segment_display/description_no_pin.md b/arduino/level3/4_digit_7_segment_display/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..12927b0952bcd27e4e39c8486342b1b04d4cce23 --- /dev/null +++ b/arduino/level3/4_digit_7_segment_display/description_no_pin.md @@ -0,0 +1,26 @@ +# 4-digit 7-segment Display + +## Project Description +This is an Arduino project that show numbers with 4-digit 7-segment display. + +## Hardware Components +- Arduino Uno +- 4-digit 7-segment display + +## Circuit Description +Circuit is designed to use a 4-digit 7-segment display. The 4-digit 7-segment display is a common anode type. The A to G and DP, and DIG1 to DIG4 pins are connected to arduino digital pins. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set segment pins and digit pins as an output. +2. Taking into account that the display is common anode, display the number 1 on digit1, 2 on digit2, 3 on digit3, and 4 on digit4, in order, with an 1000ms delay between each step. + +## Success Criteria +The test is successful when: +1. The 4-digit 7-segment display shows 1, 2, 3, and 4 in order. + +## Notes for Implementation +- The 4-digit 7-segment display is a common anode type. + +## Variants +This project may have different variants with the segment pins connected to the different pins. \ No newline at end of file diff --git a/arduino/level3/4_digit_7_segment_display/diagram.json b/arduino/level3/4_digit_7_segment_display/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..0047c205ed22d72153bef909dc22a55fe7e70125 --- /dev/null +++ b/arduino/level3/4_digit_7_segment_display/diagram.json @@ -0,0 +1,166 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Use 4 digit 7-segment display", + "config": { + "display_A_pin": "2", + "display_B_pin": "3", + "display_C_pin": "4", + "display_D_pin": "5", + "display_E_pin": "6", + "display_F_pin": "7", + "display_G_pin": "8", + "display_DP_pin": "9", + "display_DIG1_pin": "10", + "display_DIG2_pin": "11", + "display_DIG3_pin": "12", + "display_DIG4_pin": "13" + }, + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 128, + "left": 20, + "attrs": {} + }, + { + "type": "wokwi-7segment", + "id": "7-segment display1", + "top": -51.78, + "left": 58.72, + "attrs": { + "digits": "4" + } + } + ], + "connections": [ + [ + "7-segment display1:COM", + "arduino uno1:5V", + "green", + [ + "v8.76", + "h-57.6" + ] + ], + [ + "7-segment display1:A", + "arduino uno1:2", + "green", + [ + "v-9.6", + "h134.4" + ] + ], + [ + "7-segment display1:B", + "arduino uno1:3", + "green", + [ + "v-19.2", + "h96", + "v182.4", + "h-28.8" + ] + ], + [ + "7-segment display1:C", + "arduino uno1:4", + "green", + [ + "v18.36", + "h86.4" + ] + ], + [ + "7-segment display1:D", + "arduino uno1:5", + "green", + [ + "v27.96", + "h86.4" + ] + ], + [ + "7-segment display1:E", + "arduino uno1:6", + "green", + [ + "v37.56", + "h96.01" + ] + ], + [ + "7-segment display1:F", + "arduino uno1:7", + "green", + [ + "v-28.8", + "h134.4", + "v182.4", + "h-67.2" + ] + ], + [ + "7-segment display1:G", + "arduino uno1:8", + "green", + [ + "v85.56", + "h28.8" + ] + ], + [ + "7-segment display1:DP", + "arduino uno1:9", + "green", + [ + "v95.16", + "h38.4" + ] + ], + [ + "7-segment display1:DIG1", + "arduino uno1:10", + "green", + [ + "v-9.6", + "h-67.19", + "v124.8", + "h-9.6" + ] + ], + [ + "7-segment display1:DIG2", + "arduino uno1:11", + "green", + [ + "v-38.4", + "h-115.2", + "v163.2", + "h9.6" + ] + ], + [ + "7-segment display1:DIG3", + "arduino uno1:12", + "green", + [ + "v-48", + "h-134.4", + "v182.4", + "h124.8" + ] + ], + [ + "7-segment display1:DIG4", + "arduino uno1:13", + "green", + [ + "v75.96", + "h-28.8" + ] + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/4_digit_7_segment_display/diagram_breadboard.json b/arduino/level3/4_digit_7_segment_display/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..b39d64835105a8a18c4895fc893ed83bacaaac73 --- /dev/null +++ b/arduino/level3/4_digit_7_segment_display/diagram_breadboard.json @@ -0,0 +1,287 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Use 4 digit 7-segment display", + "config": { + "display_A_pin": "2", + "display_B_pin": "3", + "display_C_pin": "4", + "display_D_pin": "5", + "display_E_pin": "6", + "display_F_pin": "7", + "display_G_pin": "8", + "display_DP_pin": "9", + "display_DIG1_pin": "10", + "display_DIG2_pin": "11", + "display_DIG3_pin": "12", + "display_DIG4_pin": "13" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -147, + "left": -93.2, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 128, + "left": 20, + "attrs": {} + }, + { + "type": "wokwi-7segment", + "id": "7-segment display1", + "top": -80.58, + "left": 97.12, + "attrs": { + "digits": "4", + "common": "cathode" + } + } + ], + "connections": [ + [ + "7-segment display1:A", + "breadboard1:26t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:B", + "breadboard1:30t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:C", + "breadboard1:28b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:D", + "breadboard1:26b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:E", + "breadboard1:25b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:F", + "breadboard1:27t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:G", + "breadboard1:29b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:DP", + "breadboard1:27b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:DIG1", + "breadboard1:25t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:DIG2", + "breadboard1:28t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:DIG3", + "breadboard1:29t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:DIG4", + "breadboard1:30b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:COM", + "breadboard1:31b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:CLN", + "breadboard1:31t.c", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:26t.b", + "arduino uno1:2", + "green", + [ + "v-9.6", + "h-86.4", + "v192", + "h163.2" + ] + ], + [ + "breadboard1:30t.b", + "arduino uno1:3", + "green", + [ + "v-9.6", + "h86.4", + "v182.4", + "h-48" + ] + ], + [ + "breadboard1:28b.j", + "arduino uno1:4", + "green", + [ + "v96", + "h48" + ] + ], + [ + "breadboard1:26b.j", + "arduino uno1:5", + "green", + [ + "v105.6", + "h57.6" + ] + ], + [ + "breadboard1:25b.j", + "arduino uno1:6", + "green", + [ + "v76.8", + "h57.6" + ] + ], + [ + "breadboard1:27t.b", + "arduino uno1:7", + "green", + [ + "v-19.2", + "h-105.6", + "v211.2", + "h134.4" + ] + ], + [ + "breadboard1:29b.j", + "arduino uno1:8", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:27b.j", + "arduino uno1:9", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:25t.b", + "arduino uno1:10", + "green", + [ + "v-28.8", + "h-96", + "v230.4", + "h105.6" + ] + ], + [ + "breadboard1:28t.b", + "arduino uno1:11", + "green", + [ + "v-19.2", + "h115.2", + "v182.4", + "h-144" + ] + ], + [ + "breadboard1:29t.b", + "arduino uno1:12", + "green", + [ + "v-28.8", + "h115.2", + "v201.6", + "h-163.2" + ] + ], + [ + "breadboard1:30b.j", + "arduino uno1:13", + "green", + [ + "v57.6", + "h-67.2" + ] + ], + [ + "breadboard1:31b.j", + "arduino uno1:GND.1", + "green", + [ + "v48", + "h-86.4" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/4_digit_7_segment_display/diagram_breadboard_shdf.json b/arduino/level3/4_digit_7_segment_display/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..6fadf2b5f35a5079ffd50c10fc279914320ec1f4 --- /dev/null +++ b/arduino/level3/4_digit_7_segment_display/diagram_breadboard_shdf.json @@ -0,0 +1,126 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "display", + "type": "7-segment display" + } + ], + "connections": [ + [ + "display.a", + "bb1.pin26t.c" + ], + [ + "display.b", + "bb1.pin30t.c" + ], + [ + "display.c", + "bb1.pin28b.h" + ], + [ + "display.d", + "bb1.pin26b.h" + ], + [ + "display.e", + "bb1.pin25b.h" + ], + [ + "display.f", + "bb1.pin27t.c" + ], + [ + "display.g", + "bb1.pin29b.h" + ], + [ + "display.dp", + "bb1.pin27b.h" + ], + [ + "display.dig1", + "bb1.pin25t.c" + ], + [ + "display.dig2", + "bb1.pin28t.c" + ], + [ + "display.dig3", + "bb1.pin29t.c" + ], + [ + "display.dig4", + "bb1.pin30b.h" + ], + [ + "display.com", + "bb1.pin31b.h" + ], + [ + "display.cln", + "bb1.pin31t.c" + ], + [ + "bb1.pin26t.b", + "uno.2" + ], + [ + "bb1.pin30t.b", + "uno.3" + ], + [ + "bb1.pin28b.j", + "uno.4" + ], + [ + "bb1.pin26b.j", + "uno.5" + ], + [ + "bb1.pin25b.j", + "uno.6" + ], + [ + "bb1.pin27t.b", + "uno.7" + ], + [ + "bb1.pin29b.j", + "uno.8" + ], + [ + "bb1.pin27b.j", + "uno.9" + ], + [ + "bb1.pin25t.b", + "uno.10" + ], + [ + "bb1.pin28t.b", + "uno.11" + ], + [ + "bb1.pin29t.b", + "uno.12" + ], + [ + "bb1.pin30b.j", + "uno.13" + ], + [ + "bb1.pin31b.j", + "uno.gnd.1" + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/4_digit_7_segment_display/diagram_shdf.json b/arduino/level3/4_digit_7_segment_display/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..a57a4b315a97d5f7baf437784044c5ebf4226f7b --- /dev/null +++ b/arduino/level3/4_digit_7_segment_display/diagram_shdf.json @@ -0,0 +1,66 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "display", + "type": "7-segment display" + } + ], + "connections": [ + [ + "display.com", + "uno.gnd.1" + ], + [ + "display.a", + "uno.2" + ], + [ + "display.b", + "uno.3" + ], + [ + "display.c", + "uno.4" + ], + [ + "display.d", + "uno.5" + ], + [ + "display.e", + "uno.6" + ], + [ + "display.f", + "uno.7" + ], + [ + "display.g", + "uno.8" + ], + [ + "display.dp", + "uno.9" + ], + [ + "display.dig1", + "uno.10" + ], + [ + "display.dig2", + "uno.11" + ], + [ + "display.dig3", + "uno.12" + ], + [ + "display.dig4", + "uno.13" + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/4_digit_7_segment_display/platformio.ini b/arduino/level3/4_digit_7_segment_display/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level3/4_digit_7_segment_display/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level3/4_digit_7_segment_display/scenario.yaml b/arduino/level3/4_digit_7_segment_display/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..38f5d9ad394175c8b91603b42e969ef549fe2412 --- /dev/null +++ b/arduino/level3/4_digit_7_segment_display/scenario.yaml @@ -0,0 +1,173 @@ +author: Blind Author +description: Show 1, 2, 3, and 4 with 4 digit 7-segment display +name: 4 Digit 7-segment Display +steps: +- delay: 10ms +- wait-multi-pin: + timeout: 1000 + interval: 200 + pins: + - part-id: '7-segment display1' + pin: 'COM' + value: 1 + - part-id: '7-segment display1' + pin: 'DIG1' + value: 1 + - part-id: '7-segment display1' + pin: 'DIG2' + value: 0 + - part-id: '7-segment display1' + pin: 'DIG3' + value: 0 + - part-id: '7-segment display1' + pin: 'DIG4' + value: 0 + - part-id: '7-segment display1' + pin: 'A' + value: 1 + - part-id: '7-segment display1' + pin: 'B' + value: 0 + - part-id: '7-segment display1' + pin: 'C' + value: 0 + - part-id: '7-segment display1' + pin: 'D' + value: 1 + - part-id: '7-segment display1' + pin: 'E' + value: 1 + - part-id: '7-segment display1' + pin: 'F' + value: 1 + - part-id: '7-segment display1' + pin: 'G' + value: 1 + - part-id: '7-segment display1' + pin: 'DP' + value: 1 + +- delay: 300ms +- wait-multi-pin: + timeout: 1000 + interval: 200 + pins: + - part-id: '7-segment display1' + pin: 'DIG1' + value: 0 + - part-id: '7-segment display1' + pin: 'DIG2' + value: 1 + - part-id: '7-segment display1' + pin: 'DIG3' + value: 0 + - part-id: '7-segment display1' + pin: 'DIG4' + value: 0 + - part-id: '7-segment display1' + pin: 'A' + value: 0 + - part-id: '7-segment display1' + pin: 'B' + value: 0 + - part-id: '7-segment display1' + pin: 'C' + value: 1 + - part-id: '7-segment display1' + pin: 'D' + value: 0 + - part-id: '7-segment display1' + pin: 'E' + value: 0 + - part-id: '7-segment display1' + pin: 'F' + value: 1 + - part-id: '7-segment display1' + pin: 'G' + value: 0 + - part-id: '7-segment display1' + pin: 'DP' + value: 1 +- delay: 300ms +- wait-multi-pin: + timeout: 1000 + interval: 200 + pins: + - part-id: '7-segment display1' + pin: 'DIG1' + value: 0 + - part-id: '7-segment display1' + pin: 'DIG2' + value: 0 + - part-id: '7-segment display1' + pin: 'DIG3' + value: 1 + - part-id: '7-segment display1' + pin: 'DIG4' + value: 0 + - part-id: '7-segment display1' + pin: 'A' + value: 0 + - part-id: '7-segment display1' + pin: 'B' + value: 0 + - part-id: '7-segment display1' + pin: 'C' + value: 0 + - part-id: '7-segment display1' + pin: 'D' + value: 0 + - part-id: '7-segment display1' + pin: 'E' + value: 1 + - part-id: '7-segment display1' + pin: 'F' + value: 1 + - part-id: '7-segment display1' + pin: 'G' + value: 0 + - part-id: '7-segment display1' + pin: 'DP' + value: 1 +- delay: 300ms +- wait-multi-pin: + timeout: 1000 + interval: 200 + pins: + - part-id: '7-segment display1' + pin: 'DIG1' + value: 0 + - part-id: '7-segment display1' + pin: 'DIG2' + value: 0 + - part-id: '7-segment display1' + pin: 'DIG3' + value: 0 + - part-id: '7-segment display1' + pin: 'DIG4' + value: 1 + - part-id: '7-segment display1' + pin: 'A' + value: 1 + - part-id: '7-segment display1' + pin: 'B' + value: 0 + - part-id: '7-segment display1' + pin: 'C' + value: 0 + - part-id: '7-segment display1' + pin: 'D' + value: 1 + - part-id: '7-segment display1' + pin: 'E' + value: 1 + - part-id: '7-segment display1' + pin: 'F' + value: 0 + - part-id: '7-segment display1' + pin: 'G' + value: 0 + - part-id: '7-segment display1' + pin: 'DP' + value: 1 +version: 1.0 diff --git a/arduino/level3/4_digit_7_segment_display/src/main.ino b/arduino/level3/4_digit_7_segment_display/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..cdae5ed0e7d1ca524ad65950b71ba594faff6906 --- /dev/null +++ b/arduino/level3/4_digit_7_segment_display/src/main.ino @@ -0,0 +1,39 @@ +/** + Show 1, 2, 3, and 4 with 4 digit 7-segment display + 7 APR 2025 by Blind Author +*/ + +const int segmentPins[8] = {2, 3, 4, 5, 6, 7, 8, 9}; +const int digitPins[4] = {10, 11, 12, 13}; + +const byte digits[10][8] = { + {1,1,1,1,1,1,0,0}, + {0,1,1,0,0,0,0,0}, + {1,1,0,1,1,0,1,0}, + {1,1,1,1,0,0,1,0}, + {0,1,1,0,0,1,1,0}, + {1,0,1,1,0,1,1,0}, + {1,0,1,1,1,1,1,0}, + {1,1,1,0,0,0,0,0}, + {1,1,1,1,1,1,1,0}, + {1,1,1,1,0,1,1,0} +}; + +void setup() { + for (int i = 0; i < 8; i++) pinMode(segmentPins[i], OUTPUT); + for (int i = 0; i < 4; i++) { + pinMode(digitPins[i], OUTPUT); + digitalWrite(digitPins[i], LOW); + } +} + +void loop() { + int nums[4] = {1, 2, 3, 4}; + + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 8; j++) digitalWrite(segmentPins[j], digits[nums[i]][j] ? LOW : HIGH); + digitalWrite(digitPins[i], HIGH); + delay(800); + digitalWrite(digitPins[i], LOW); + } +} \ No newline at end of file diff --git a/arduino/level3/4_digit_7_segment_display/wokwi.toml b/arduino/level3/4_digit_7_segment_display/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level3/4_digit_7_segment_display/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level3/7_segment_display_serial/description.md b/arduino/level3/7_segment_display_serial/description.md new file mode 100644 index 0000000000000000000000000000000000000000..f3617ce78251f734dd34c0e6974d54b30891bf4c --- /dev/null +++ b/arduino/level3/7_segment_display_serial/description.md @@ -0,0 +1,31 @@ +# One Digit 7-segment Display With Serial Input + +## Project Description +This is an Arduino project that show the serial input with digit 7-segment display. + +## Hardware Components +- Arduino Uno +- 330Ω resistor * 8 +- 7-segment display + +## Circuit Description +Circuit is designed to use a 7-segment display. The 7-segment display is a common anode type, so the common pin is connected to 5V. The A to G and DP pins are connected to Arduino digital pins 2 to 9 through 330-ohm resistors. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set 2~9 pin as an output. +2. Continuously check if the serial is available. +3. Taking into account that the display is common anode, set the corresponding pins to HIGH or LOW so that the serial input is shown on the 7-segment display. + +## Success Criteria +The test is successful when: +1. The 7-segment display shows the same value as the serial input. + +## Notes for Implementation +- The 7-segment display is a common anode type. + +## Variants +This project may have different variants with the segment pins connected to the different pins. + +## Attributes +- To use 330Ω resistor, set the property name "value" to "330 ohm". \ No newline at end of file diff --git a/arduino/level3/7_segment_display_serial/description_no_pin.md b/arduino/level3/7_segment_display_serial/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..be3f9fa6b9ca3af447f047866f747866f8365458 --- /dev/null +++ b/arduino/level3/7_segment_display_serial/description_no_pin.md @@ -0,0 +1,31 @@ +# One Digit 7-segment Display With Serial Input + +## Project Description +This is an Arduino project that show the serial input with digit 7-segment display. + +## Hardware Components +- Arduino Uno +- 330Ω resistor * 8 +- 7-segment display + +## Circuit Description +Circuit is designed to use a 7-segment display. The 7-segment display is a common anode type. The A to G and DP pins are connected to Arduino digital pins through 330-ohm resistors. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set segment pins as an output. +2. Continuously check if the serial is available. +3. Taking into account that the display is common anode, set the corresponding pins to HIGH or LOW so that the serial input is shown on the 7-segment display. + +## Success Criteria +The test is successful when: +1. The 7-segment display shows the same value as the serial input. + +## Notes for Implementation +- The 7-segment display is a common anode type. + +## Variants +This project may have different variants with the segment pins connected to the different pins. + +## Attributes +- To use 330Ω resistor, set the property name "value" to "330 ohm". \ No newline at end of file diff --git a/arduino/level3/7_segment_display_serial/diagram.json b/arduino/level3/7_segment_display_serial/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..5039449841a212077aaa69674d446c09fb02525f --- /dev/null +++ b/arduino/level3/7_segment_display_serial/diagram.json @@ -0,0 +1,252 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Use one digit 7-segment display", + "config": { + "display_A_pin": "2", + "display_B_pin": "3", + "display_C_pin": "4", + "display_D_pin": "5", + "display_E_pin": "6", + "display_F_pin": "7", + "display_G_pin": "8", + "display_DP_pin": "9" + }, + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-7segment", + "id": "7-segment display1", + "top": 24.18, + "left": 408.28, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 128.75, + "left": 451.2, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -15.25, + "left": 451.2, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 109.55, + "left": 441.6, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 128.75, + "left": 355.2, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": 109.55, + "left": 364.8, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -15.25, + "left": 345.6, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": 3.95, + "left": 364.8, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": 3.95, + "left": 441.6, + "attrs": { + "value": "330" + } + } + ], + "connections": [ + [ + "7-segment display1:F", + "resistor7:2", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:A", + "resistor8:1", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:G", + "resistor6:2", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:B", + "resistor2:1", + "green", + [ + "v0" + ] + ], + [ + "resistor5:2", + "7-segment display1:D", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:C", + "resistor3:1", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:E", + "resistor4:2", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:DP", + "resistor1:1", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:COM.1", + "arduino uno1:5V", + "green", + [ + "h0", + "v124.8" + ] + ], + [ + "resistor8:2", + "arduino uno1:2", + "green", + [ + "v-19.2", + "h-260.4" + ] + ], + [ + "resistor2:2", + "arduino uno1:3", + "green", + [ + "v-9.6", + "h-279.6" + ] + ], + [ + "resistor3:2", + "arduino uno1:4", + "green", + [ + "v0", + "h27.6", + "v-144", + "h-307.2" + ] + ], + [ + "resistor5:1", + "arduino uno1:5", + "green", + [ + "v-153.6", + "h-153.6" + ] + ], + [ + "resistor4:1", + "arduino uno1:6", + "green", + [ + "v-182.4", + "h-153.6" + ] + ], + [ + "resistor7:1", + "arduino uno1:7", + "green", + [ + "v-67.2", + "h-172.8" + ] + ], + [ + "resistor6:1", + "arduino uno1:8", + "green", + [ + "v-57.6", + "h-172.8" + ] + ], + [ + "resistor1:2", + "arduino uno1:9", + "green", + [ + "v-211.2", + "h-346.8" + ] + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/7_segment_display_serial/diagram_breadboard.json b/arduino/level3/7_segment_display_serial/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..294cd11b417c12ab2f3c386029c216cd5bf709da --- /dev/null +++ b/arduino/level3/7_segment_display_serial/diagram_breadboard.json @@ -0,0 +1,405 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Use one digit 7-segment display", + "config": { + "display_A_pin": "2", + "display_B_pin": "3", + "display_C_pin": "4", + "display_D_pin": "5", + "display_E_pin": "6", + "display_F_pin": "7", + "display_G_pin": "8", + "display_DP_pin": "9" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -127.8, + "left": 338.8, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 115.8, + "left": 527.4, + "attrs": {} + }, + { + "type": "wokwi-7segment", + "id": "7-segment display1", + "top": -62.22, + "left": 629.08, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 23.15, + "left": 672, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -72.85, + "left": 662.4, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 13.55, + "left": 662.4, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 23.15, + "left": 576, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": 13.55, + "left": 585.6, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -82.45, + "left": 576, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": -72.85, + "left": 585.6, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": -82.45, + "left": 672, + "attrs": { + "value": "330" + } + } + ], + "connections": [ + [ + "7-segment display1:COM.1", + "breadboard1:31b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:COM.2", + "breadboard1:31t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:A", + "breadboard1:32t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:B", + "breadboard1:33t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:C", + "breadboard1:32b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:D", + "breadboard1:30b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:E", + "breadboard1:29b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:F", + "breadboard1:30t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:G", + "breadboard1:29t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:DP", + "breadboard1:33b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:33b.j", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:39b.j", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:32t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:38t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:32b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:38b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor4:1", + "breadboard1:23b.j", + "", + [ + "$bb" + ] + ], + [ + "resistor4:2", + "breadboard1:29b.j", + "", + [ + "$bb" + ] + ], + [ + "resistor5:1", + "breadboard1:24b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor5:2", + "breadboard1:30b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor6:1", + "breadboard1:23t.a", + "", + [ + "$bb" + ] + ], + [ + "resistor6:2", + "breadboard1:29t.a", + "", + [ + "$bb" + ] + ], + [ + "resistor7:1", + "breadboard1:24t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor7:2", + "breadboard1:30t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor8:1", + "breadboard1:33t.a", + "", + [ + "$bb" + ] + ], + [ + "resistor8:2", + "breadboard1:39t.a", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:38t.d", + "arduino uno1:2", + "green", + [ + "v134.4", + "h48" + ] + ], + [ + "breadboard1:39t.d", + "arduino uno1:3", + "green", + [ + "v144", + "h19.2" + ] + ], + [ + "breadboard1:38b.g", + "arduino uno1:4", + "green", + [ + "v105.6", + "h28.8" + ] + ], + [ + "breadboard1:24b.g", + "arduino uno1:5", + "green", + [ + "v0", + "h-57.6", + "v76.8", + "h201.6" + ] + ], + [ + "breadboard1:23b.h", + "arduino uno1:6", + "green", + [ + "v0", + "h-38.4", + "v76.8", + "h182.4" + ] + ], + [ + "breadboard1:24t.d", + "arduino uno1:7", + "green", + [ + "v144", + "h124.8" + ] + ], + [ + "breadboard1:23t.d", + "arduino uno1:8", + "green", + [ + "v153.6", + "h124.8" + ] + ], + [ + "breadboard1:39b.h", + "arduino uno1:9", + "green", + [ + "v38.4", + "h-38.4" + ] + ], + [ + "breadboard1:31b.j", + "arduino uno1:5V", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/7_segment_display_serial/diagram_breadboard_shdf.json b/arduino/level3/7_segment_display_serial/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..ea1ce66bc88f27b19e335f7033e2808c1caba741 --- /dev/null +++ b/arduino/level3/7_segment_display_serial/diagram_breadboard_shdf.json @@ -0,0 +1,214 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "sevseg1", + "type": "7-segment display" + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r2", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r3", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r4", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r5", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r6", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r7", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r8", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + } + ], + "connections": [ + [ + "sevseg1.com.1", + "bb1.pin31b.h" + ], + [ + "sevseg1.com.2", + "bb1.pin31t.c" + ], + [ + "sevseg1.a", + "bb1.pin32t.c" + ], + [ + "sevseg1.b", + "bb1.pin33t.c" + ], + [ + "sevseg1.c", + "bb1.pin32b.h" + ], + [ + "sevseg1.d", + "bb1.pin30b.h" + ], + [ + "sevseg1.e", + "bb1.pin29b.h" + ], + [ + "sevseg1.f", + "bb1.pin30t.c" + ], + [ + "sevseg1.g", + "bb1.pin29t.c" + ], + [ + "sevseg1.dp", + "bb1.pin33b.h" + ], + [ + "r1.1", + "bb1.pin33b.j" + ], + [ + "r1.2", + "bb1.pin39b.j" + ], + [ + "r2.1", + "bb1.pin32t.b" + ], + [ + "r2.2", + "bb1.pin38t.b" + ], + [ + "r3.1", + "bb1.pin32b.i" + ], + [ + "r3.2", + "bb1.pin38b.i" + ], + [ + "r4.1", + "bb1.pin23b.j" + ], + [ + "r4.2", + "bb1.pin29b.j" + ], + [ + "r5.1", + "bb1.pin24b.i" + ], + [ + "r5.2", + "bb1.pin30b.i" + ], + [ + "r6.1", + "bb1.pin23t.a" + ], + [ + "r6.2", + "bb1.pin29t.a" + ], + [ + "r7.1", + "bb1.pin24t.b" + ], + [ + "r7.2", + "bb1.pin30t.b" + ], + [ + "r8.1", + "bb1.pin33t.a" + ], + [ + "r8.2", + "bb1.pin39t.a" + ], + [ + "bb1.pin38t.d", + "uno.2" + ], + [ + "bb1.pin39t.d", + "uno.3" + ], + [ + "bb1.pin38b.g", + "uno.4" + ], + [ + "bb1.pin24b.g", + "uno.5" + ], + [ + "bb1.pin23b.h", + "uno.6" + ], + [ + "bb1.pin24t.d", + "uno.7" + ], + [ + "bb1.pin23t.d", + "uno.8" + ], + [ + "bb1.pin39b.h", + "uno.9" + ], + [ + "bb1.pin31b.j", + "uno.5v" + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/7_segment_display_serial/diagram_shdf.json b/arduino/level3/7_segment_display_serial/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..4ee472d9c581b65e0b50aaa3ba1508687eebdd94 --- /dev/null +++ b/arduino/level3/7_segment_display_serial/diagram_shdf.json @@ -0,0 +1,138 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "sevseg1", + "type": "7-segment display" + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r2", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r3", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r4", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r5", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r6", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r7", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + }, + { + "id": "r8", + "type": "resistor", + "properties": { + "value": "330 ohm" + } + } + ], + "connections": [ + [ + "sevseg1.f", + "r7.2" + ], + [ + "sevseg1.a", + "r8.1" + ], + [ + "sevseg1.g", + "r6.2" + ], + [ + "sevseg1.b", + "r2.1" + ], + [ + "r5.2", + "sevseg1.d" + ], + [ + "sevseg1.c", + "r3.1" + ], + [ + "sevseg1.e", + "r4.2" + ], + [ + "sevseg1.dp", + "r1.1" + ], + [ + "sevseg1.com.1", + "uno.5v" + ], + [ + "r8.2", + "uno.2" + ], + [ + "r2.2", + "uno.3" + ], + [ + "r3.2", + "uno.4" + ], + [ + "r5.1", + "uno.5" + ], + [ + "r4.1", + "uno.6" + ], + [ + "r7.1", + "uno.7" + ], + [ + "r6.1", + "uno.8" + ], + [ + "r1.2", + "uno.9" + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/7_segment_display_serial/platformio.ini b/arduino/level3/7_segment_display_serial/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level3/7_segment_display_serial/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level3/7_segment_display_serial/scenario.yaml b/arduino/level3/7_segment_display_serial/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3f8228f5076e3bb159d25a4ec423e8401b4f03cf --- /dev/null +++ b/arduino/level3/7_segment_display_serial/scenario.yaml @@ -0,0 +1,72 @@ +author: Blind Author +description: Show the serial input with one digit 7-segment display +name: One Digit 7-segment Display With Serial Input +steps: +- delay: 100ms +- write-serial: '5' +- delay: 50ms +- wait-multi-pin: + timeout: 1000 + interval: 200 + pins: + - part-id: '7-segment display1' + pin: 'COM' + value: 1 + - part-id: '7-segment display1' + pin: 'A' + value: 0 + - part-id: '7-segment display1' + pin: 'B' + value: 1 + - part-id: '7-segment display1' + pin: 'C' + value: 0 + - part-id: '7-segment display1' + pin: 'D' + value: 0 + - part-id: '7-segment display1' + pin: 'E' + value: 1 + - part-id: '7-segment display1' + pin: 'F' + value: 0 + - part-id: '7-segment display1' + pin: 'G' + value: 0 + - part-id: '7-segment display1' + pin: 'DP' + value: 1 +- write-serial: '2' +- delay: 50ms +- wait-multi-pin: + timeout: 1000 + interval: 200 + pins: + - part-id: '7-segment display1' + pin: 'COM' + value: 1 + - part-id: '7-segment display1' + pin: 'A' + value: 0 + - part-id: '7-segment display1' + pin: 'B' + value: 0 + - part-id: '7-segment display1' + pin: 'C' + value: 1 + - part-id: '7-segment display1' + pin: 'D' + value: 0 + - part-id: '7-segment display1' + pin: 'E' + value: 0 + - part-id: '7-segment display1' + pin: 'F' + value: 1 + - part-id: '7-segment display1' + pin: 'G' + value: 0 + - part-id: '7-segment display1' + pin: 'DP' + value: 1 +version: 1.0 diff --git a/arduino/level3/7_segment_display_serial/src/main.ino b/arduino/level3/7_segment_display_serial/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..aa548090f033e2faa5192fa66476257e38bbb3c9 --- /dev/null +++ b/arduino/level3/7_segment_display_serial/src/main.ino @@ -0,0 +1,45 @@ +/** + Show the serial input with one digit 7-segment display + 7 APR 2025 by Blind Author +*/ + +const int segmentPins[8] = {2, 3, 4, 5, 6, 7, 8, 9}; + +const byte digits[10][8] = { + {0, 0, 0, 0, 0, 0, 1, 1}, + {1, 0, 0, 1, 1, 1, 1, 1}, + {0, 0, 1, 0, 0, 1, 0, 1}, + {0, 0, 0, 0, 1, 1, 0, 1}, + {1, 0, 0, 1, 1, 0, 0, 1}, + {0, 1, 0, 0, 1, 0, 0, 1}, + {0, 1, 0, 0, 0, 0, 0, 1}, + {0, 0, 0, 1, 1, 1, 1, 1}, + {0, 0, 0, 0, 0, 0, 0, 1}, + {0, 0, 0, 0, 1, 0, 0, 1} +}; + +void setup() { + for (int i = 0; i < 8; i++) { + pinMode(segmentPins[i], OUTPUT); + digitalWrite(segmentPins[i], HIGH); + } + Serial.begin(9600); +} + +void loop() { + if (Serial.available()) { + char input = Serial.read(); + if (input >= '0' && input <= '9') { + int num = input - '0'; + displayDigit(num); + } + } +} + +void displayDigit(int num) { + for (int i = 0; i < 8; i++) { + digitalWrite(segmentPins[i], digits[num][i] ? HIGH : LOW); + } +} + + diff --git a/arduino/level3/7_segment_display_serial/wokwi.toml b/arduino/level3/7_segment_display_serial/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level3/7_segment_display_serial/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level3/button_LCD_display/description.md b/arduino/level3/button_LCD_display/description.md new file mode 100644 index 0000000000000000000000000000000000000000..657a239c1b03d3fb354c6cebf1f19b4cfdba9922 --- /dev/null +++ b/arduino/level3/button_LCD_display/description.md @@ -0,0 +1,32 @@ +# LCD Display with Button + +## Project Description +This is an Arduino project that shows button state to the ili9341 lcd display. + +## Hardware Components +- Arduino Uno +- Ili9341 LCD Display +- Push Button +- 10kΩ resistor + +## Circuit Description +Ili9341 LCD Display and push button are connected to the Arudino Uno board. RST, D/C, CS, MOSI, MISO, SCK pin of LCD display is connected to arduino pin 8 to 13, respectively. GND pin of LCD display is connected to arduino pin gnd1. VCC pin of LCD display is connected to arduino pin 5v. The push button input is connected to pin 2. It is configured in a cathode-style circuit so that the input reads HIGH when pressed and LOW when released. + +## Expected Behavior +When the Arduino powers up, it should: +1. Declare Adafruit_ILI9341 object +2. Begin display and change it to landscape mode, and set the text color to white, and size to 2 +3. Set button pin as INPUT, and countinuosly read the button state +4. If the button is newly pressed, clear the display with a black background and print the test "Pressed! at position (0, 0) +5. ELse, clear the display with a black background and print the test "Not pressed! at position (0, 0) + +## Success Criteria +The test is successful when: +1. Button state is successfully printed to the display, with correct position, color, and size. + +## Notes for Implementation +- Use the following libraries: , , and . +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level3/button_LCD_display/description_no_pin.md b/arduino/level3/button_LCD_display/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..ab78f3e7ca58d5aab9a1f2d5f80e0b47ecf0dbb9 --- /dev/null +++ b/arduino/level3/button_LCD_display/description_no_pin.md @@ -0,0 +1,30 @@ +# LCD Display with Button + +## Project Description +This is an Arduino project that shows button state to the ili9341 lcd display. + +## Hardware Components +- Arduino Uno +- Ili9341 LCD Display +- Push Button +- 10kΩ resistor + +## Circuit Description +Ili9341 LCD Display and push button are connected to the Arudino Uno board. RST, D/C, CS, MOSI, MISO, SCK pin of LCD display is connected to arduino digital pins. The push button is configured in a cathode-style circuit. + +## Expected Behavior +When the Arduino powers up, it should: +1. Declare Adafruit_ILI9341 object +2. Begin display and change it to landscape mode, and set the text color to white, and size to 2 +3. Set button pin as INPUT, and countinuosly read the button state +4. If the button is newly pressed, clear the display with a black background and print the test "Pressed! at position (0, 0) +5. ELse, clear the display with a black background and print the test "Not pressed! at position (0, 0) + +## Success Criteria +The test is successful when: +1. Button state is successfully printed to the display, with correct position, color, and size. + +## Notes for Implementation +- Use the following libraries: , , and . +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + diff --git a/arduino/level3/button_LCD_display/diagram.json b/arduino/level3/button_LCD_display/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..69eb8382d707855dfac3e5c173a8eb1c11e0d1b7 --- /dev/null +++ b/arduino/level3/button_LCD_display/diagram.json @@ -0,0 +1,153 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Show button state with lcd display", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 331.89, + "left": 1.49, + "attrs": {} + }, + { + "type": "wokwi-ili9341", + "id": "ili9341 lcd display1", + "top": 5.51, + "left": 40.77, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": 198.2, + "left": 316.8, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 224.75, + "left": 403.2, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "ili9341 lcd display1:GND", + "arduino uno1:GND.1", + "black", + [ + "v22", + "h-46" + ] + ], + [ + "ili9341 lcd display1:SCK", + "arduino uno1:13", + "green", + [ + "v16", + "h-75" + ] + ], + [ + "ili9341 lcd display1:MISO", + "arduino uno1:12", + "limegreen", + [ + "v20", + "h-78" + ] + ], + [ + "ili9341 lcd display1:MOSI", + "arduino uno1:11", + "green", + [ + "v24", + "h-75" + ] + ], + [ + "ili9341 lcd display1:RST", + "arduino uno1:8", + "green", + [ + "v33.69", + "h54.93" + ] + ], + [ + "ili9341 lcd display1:CS", + "arduino uno1:10", + "orange", + [ + "v32", + "h-64" + ] + ], + [ + "ili9341 lcd display1:D/C", + "arduino uno1:9", + "purple", + [ + "v36", + "h-84" + ] + ], + [ + "ili9341 lcd display1:VCC", + "arduino uno1:5V", + "red", + [ + "v24.09", + "h-98.67", + "v230.4", + "h172.8" + ] + ], + [ + "push button1:2.r", + "resistor1:1", + "green", + [ + "h0" + ] + ], + [ + "resistor1:2", + "arduino uno1:GND.1", + "black", + [ + "v0", + "h27.6", + "v96", + "h-374.4" + ] + ], + [ + "push button1:2.l", + "arduino uno1:2", + "green", + [ + "h0" + ] + ], + [ + "push button1:1.r", + "arduino uno1:5V", + "red", + [ + "v336", + "h-220.6" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/button_LCD_display/diagram_breadboard.json b/arduino/level3/button_LCD_display/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..d5c481de6334f284125f5a005873ce20400c06c1 --- /dev/null +++ b/arduino/level3/button_LCD_display/diagram_breadboard.json @@ -0,0 +1,268 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Show button state with lcd display", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": 45, + "left": -160.4, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 331.89, + "left": 1.49, + "attrs": {} + }, + { + "type": "wokwi-ili9341", + "id": "ili9341 lcd display1", + "top": -114.4, + "left": 47.7, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": 124.2, + "left": 281.4, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 186.35, + "left": 326.4, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "breadboard1:25b.i", + "breadboard1:bp.20", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:26b.i", + "breadboard1:bn.20", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:27b.j", + "arduino uno1:10", + "orange", + [ + "v105.6", + "h38.4" + ] + ], + [ + "breadboard1:29b.j", + "arduino uno1:9", + "green", + [ + "v96", + "h28.8" + ] + ], + [ + "breadboard1:28b.j", + "arduino uno1:8", + "green", + [ + "v105.6", + "h57.6", + "v28.8" + ] + ], + [ + "breadboard1:30b.j", + "arduino uno1:11", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:31b.j", + "arduino uno1:13", + "green", + [ + "v67.2", + "h-28.8" + ] + ], + [ + "breadboard1:33b.j", + "arduino uno1:12", + "green", + [ + "v48", + "h-38.4" + ] + ], + [ + "breadboard1:bp.8", + "arduino uno1:5V", + "red", + [ + "v306.3", + "h191.2" + ] + ], + [ + "breadboard1:bn.12", + "arduino uno1:GND.1", + "black", + [ + "v75.5", + "h104.8" + ] + ], + [ + "breadboard1:55b.j", + "breadboard1:bn.45", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:49t.b", + "arduino uno1:2", + "green", + [ + "v-134.4", + "h-76.8" + ] + ], + [ + "breadboard1:47b.i", + "breadboard1:bp.38", + "red", + [ + "v0" + ] + ], + [ + "ili9341 lcd display1:VCC", + "breadboard1:25b.g", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:GND", + "breadboard1:26b.g", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:CS", + "breadboard1:27b.g", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:RST", + "breadboard1:28b.g", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:D/C", + "breadboard1:29b.g", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:MOSI", + "breadboard1:30b.g", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:SCK", + "breadboard1:31b.g", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:LED", + "breadboard1:32b.g", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:MISO", + "breadboard1:33b.g", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.l", + "breadboard1:49t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.l", + "breadboard1:47t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.r", + "breadboard1:49b.h", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.r", + "breadboard1:47b.h", + "", + [ + "$bb" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/button_LCD_display/platformio.ini b/arduino/level3/button_LCD_display/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..b50154ebd53c2b66823f9f470aba4ff925f6d00a --- /dev/null +++ b/arduino/level3/button_LCD_display/platformio.ini @@ -0,0 +1,21 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + Adafruit ILI9341 \ No newline at end of file diff --git a/arduino/level3/button_LCD_display/scenario.yaml b/arduino/level3/button_LCD_display/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6350e60cc5ad713e14e622e69e8bbb9ec1bea36e --- /dev/null +++ b/arduino/level3/button_LCD_display/scenario.yaml @@ -0,0 +1,17 @@ +author: Blind Author +description: Use LCD display +name: LCD Display Basic +steps: +- delay: 3000ms +- take-screenshot: + part-id: ili9341 lcd display1 + compare-with: screenshots/0.png +- set-control: + part-id: push button1 + control: pressed + value: 1 +- delay: 3000ms +- take-screenshot: + part-id: ili9341 lcd display1 + compare-with: screenshots/1.png +version: 1.0 diff --git a/arduino/level3/button_LCD_display/screenshots/0.png b/arduino/level3/button_LCD_display/screenshots/0.png new file mode 100644 index 0000000000000000000000000000000000000000..1fb5a50b83505df35575ecb3850763e1837f134a --- /dev/null +++ b/arduino/level3/button_LCD_display/screenshots/0.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:12cfd28a1678a21e3c4cfc60e54a3297993e4542215f59f8b7d1f0d583157e90 +size 1377 diff --git a/arduino/level3/button_LCD_display/screenshots/1.png b/arduino/level3/button_LCD_display/screenshots/1.png new file mode 100644 index 0000000000000000000000000000000000000000..c0e913ce2fe04b57906e7881414bba2c0f80a7cb --- /dev/null +++ b/arduino/level3/button_LCD_display/screenshots/1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:12f2ffdf60778b94eb69bb30c89a33c5a5613daab11ca765c87d55878df9c1d6 +size 1246 diff --git a/arduino/level3/button_LCD_display/src/main.ino b/arduino/level3/button_LCD_display/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..2403b4d3dd00a65fb5abab50a9064032bf77098b --- /dev/null +++ b/arduino/level3/button_LCD_display/src/main.ino @@ -0,0 +1,45 @@ +/** + Show button state in ili9431 lcd display + 05 MAY 2025 by Blind Author +*/ + +#include +#include +#include + +#define BUTTON_PIN 2 + +#define TFT_CS 10 +#define TFT_DC 9 +#define TFT_RST 8 + +Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); + +bool pressed = true; + +void setup() { + tft.begin(); + tft.setRotation(1); + tft.fillScreen(ILI9341_BLACK); + + tft.setTextColor(ILI9341_WHITE); + tft.setTextSize(2); + + pinMode(BUTTON_PIN, INPUT); +} + +void loop() { + if (digitalRead(BUTTON_PIN) == HIGH && !pressed) { + tft.fillScreen(ILI9341_BLACK); + tft.setCursor(0, 0); + tft.println("Pressed!"); + pressed = true; + } else if (digitalRead(BUTTON_PIN) == LOW && pressed) { + tft.fillScreen(ILI9341_BLACK); + tft.setCursor(0, 0); + tft.println("Not Pressed!"); + pressed = false; + } + + delay(100); +} \ No newline at end of file diff --git a/arduino/level3/button_LCD_display/wokwi.toml b/arduino/level3/button_LCD_display/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level3/button_LCD_display/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level3/button_RGB_led/description.md b/arduino/level3/button_RGB_led/description.md new file mode 100644 index 0000000000000000000000000000000000000000..db1b8dfa7b2a0fa3362ceaac7afedbb5b489010a --- /dev/null +++ b/arduino/level3/button_RGB_led/description.md @@ -0,0 +1,37 @@ +# Button RGB LED + +## Project Description +This is a simple Arduino project that turns on an LED connected to a specific pin. + +## Hardware Components +- Arduino Uno +- RGB LED +- 220Ω resistor * 3 +- Push Button * 3 +- 10kΩ resistor * 3 + +## Circuit Description +The R, G, B pin of the RGB LED is connected to the arduino digital pins through a 220Ω current-limiting resistor. +RGB LED has common cathode configuration. Push button uses pull-up resistor configuration. The three buttons correspond to R, G, and B respectively, and are connected to arduino pin4, pin3, and pin2 for input. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set LED pins to OUTPUT, and button pins to INPUT +2. Continuously read the button value +3. When a button is pressed, the corresponding color on the RGB LED lights up at full brightness. + +## Success Criteria +The test is successful when: +1. The pressed button and the corresponding RGB LED pin state line up perfectly. + +## Notes for Implementation +- Each button is configured with a pull-up resistor, resulting in a LOW signal when pressed. +- The RGB LED has a common cathode connected to GND, so a PWM value of 0 turns it off and 255 turns it fully on. +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Variants +This project may have different variants with the LED, button connected to different pins. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level3/button_RGB_led/description_no_pin.md b/arduino/level3/button_RGB_led/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..94d2782385e902bda4b30b7762536326d2cf5e29 --- /dev/null +++ b/arduino/level3/button_RGB_led/description_no_pin.md @@ -0,0 +1,37 @@ +# Button RGB LED + +## Project Description +This is a simple Arduino project that turns on an LED connected to a specific pin. + +## Hardware Components +- Arduino Uno +- RGB LED +- 220Ω resistor * 3 +- Push Button * 3 +- 10kΩ resistor * 3 + +## Circuit Description +The R, G, B pin of the RGB LED is connected to the arduino digital pins through a 220Ω current-limiting resistor. +RGB LED has common cathode configuration. Three push buttons use pull-up resistor configuration. Three buttons correspond to R, G, and B respectively, and are connected to arduino digital pins for input. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set LED pins to OUTPUT, and button pins to INPUT +2. Continuously read the button value +3. When a button is pressed, the corresponding color on the RGB LED lights up at full brightness. + +## Success Criteria +The test is successful when: +1. The pressed button and the corresponding RGB LED pin state line up perfectly. + +## Notes for Implementation +- Each button is configured with a pull-up resistor, resulting in a LOW signal when pressed. +- The RGB LED has a common cathode connected to GND, so a PWM value of 0 turns it off and 255 turns it fully on. +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Variants +This project may have different variants with the LED, button connected to different pins. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level3/button_RGB_led/diagram.json b/arduino/level3/button_RGB_led/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..20bda5401ec90f78c622c99e916265a18025769c --- /dev/null +++ b/arduino/level3/button_RGB_led/diagram.json @@ -0,0 +1,295 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Button RGB LED", + "config": { + "R_led_pin": 11, + "G_led_pin": 10, + "B_led_pin": 9, + "R_button_pin": 4, + "G_button_pin": 3, + "B_button_pin": 2 + }, + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 125.4, + "left": -0.6, + "attrs": {} + }, + { + "type": "wokwi-rgb-led", + "id": "rgb led1", + "top": -44, + "left": 135.5, + "attrs": { + "common": "cathode" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 57.4, + "left": 113, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": 57.4, + "left": 132.2, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 57.4, + "left": 151.4, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": 38.3, + "left": 243.5, + "rotate": 90, + "attrs": { + "color": "Red", + "key": "r" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button2", + "top": 38.3, + "left": 291.5, + "rotate": 90, + "attrs": { + "color": "LimeGreen", + "key": "g" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button3", + "top": 38.3, + "left": 339.5, + "rotate": 90, + "attrs": { + "color": "Blue", + "key": "b" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 153.4, + "left": 257, + "rotate": 90, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": 153.4, + "left": 305, + "rotate": 90, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": 153.4, + "left": 353, + "rotate": 90, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "arduino uno1:GND.1", + "rgb led1:COM", + "Black", + [ + "v-115.2", + "h38.1" + ] + ], + [ + "arduino uno1:GND.1", + "push button1:2.l", + "Black", + [ + "h-0.3", + "v-115.2", + "h154.4" + ] + ], + [ + "push button1:2.l", + "push button2:2.l", + "Black", + [ + "v-9.6", + "h48" + ] + ], + [ + "push button2:2.l", + "push button3:2.l", + "Black", + [ + "v-9.6", + "h48" + ] + ], + [ + "rgb led1:R", + "resistor1:1", + "Red", + [ + "v0", + "h0" + ] + ], + [ + "rgb led1:B", + "resistor3:1", + "Blue", + [ + "v1", + "h11.2" + ] + ], + [ + "rgb led1:G", + "resistor2:1", + "Green", + [ + "v0", + "h33" + ] + ], + [ + "arduino uno1:11", + "resistor1:2", + "Red", + [ + "v-19.2", + "h0.6" + ] + ], + [ + "arduino uno1:9", + "resistor3:2", + "Blue", + [ + "v-19.2", + "h20" + ] + ], + [ + "arduino uno1:10", + "resistor2:2", + "Green", + [ + "v-28.8", + "h10.3" + ] + ], + [ + "push button1:1.r", + "arduino uno1:4", + "DarkSlateBlue", + [ + "v9.8", + "h-71.1" + ] + ], + [ + "push button2:1.r", + "arduino uno1:3", + "DarkSlateBlue", + [ + "v19.4", + "h-109.6" + ] + ], + [ + "push button3:1.r", + "arduino uno1:2", + "DarkSlateBlue", + [ + "v29", + "h-148.1" + ] + ], + [ + "arduino uno1:5V", + "resistor4:2", + "Red", + [ + "v19.1", + "h128.6" + ] + ], + [ + "resistor4:2", + "resistor5:2", + "Red", + [ + "v17.8", + "h48" + ] + ], + [ + "resistor5:2", + "resistor6:2", + "Red", + [ + "v17.8", + "h48" + ] + ], + [ + "resistor4:1", + "push button1:1.r", + "DarkSlateBlue", + [ + "h0" + ] + ], + [ + "resistor5:1", + "push button2:1.r", + "DarkSlateBlue", + [ + "h0" + ] + ], + [ + "resistor6:1", + "push button3:1.r", + "DarkSlateBlue", + [ + "h0" + ] + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/button_RGB_led/diagram_breadboard.json b/arduino/level3/button_RGB_led/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..c45fac5da84cbe1dbadf49377ce9b021ca10c8f6 --- /dev/null +++ b/arduino/level3/button_RGB_led/diagram_breadboard.json @@ -0,0 +1,487 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Button RGB LED", + "config": { + "R_led_pin": 11, + "G_led_pin": 10, + "B_led_pin": 9, + "R_button_pin": 4, + "G_button_pin": 3, + "B_button_pin": 2 + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -195, + "left": -54.8, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 77.4, + "left": 85.8, + "attrs": {} + }, + { + "type": "wokwi-rgb-led", + "id": "rgb led1", + "top": -178.4, + "left": 125.9, + "attrs": { + "common": "cathode" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -91.2, + "left": 105.05, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -91.2, + "left": 124.25, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -91.2, + "left": 133.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -125.4, + "left": 262.2, + "rotate": 90, + "attrs": { + "color": "Red", + "key": "r" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button2", + "top": -125.4, + "left": 339, + "rotate": 90, + "attrs": { + "color": "LimeGreen", + "key": "g" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button3", + "top": -125.4, + "left": 415.8, + "rotate": 90, + "attrs": { + "color": "Blue", + "key": "b" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": -53.35, + "left": 248.2, + "rotate": 180, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": -53.35, + "left": 325, + "rotate": 180, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -53.35, + "left": 401.8, + "rotate": 180, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "resistor1:1", + "breadboard1:18t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:18b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:20t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:20b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:21t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:21b.h", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:18b.i", + "arduino uno1:11", + "green", + [ + "v76.8", + "h96" + ] + ], + [ + "breadboard1:20b.i", + "arduino uno1:10", + "green", + [ + "v67.2", + "h86.4" + ] + ], + [ + "breadboard1:21b.i", + "arduino uno1:9", + "green", + [ + "v57.6", + "h86.4" + ] + ], + [ + "breadboard1:19t.e", + "breadboard1:bn.15", + "green", + [ + "v0" + ] + ], + [ + "rgb led1:R", + "breadboard1:18t.b", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:COM", + "breadboard1:19t.c", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:G", + "breadboard1:20t.b", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:B", + "breadboard1:21t.b", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:bn.11", + "arduino uno1:GND.1", + "green", + [ + "v0" + ] + ], + [ + "push button1:1.l", + "breadboard1:36t.b", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.l", + "breadboard1:34t.b", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.r", + "breadboard1:36b.g", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.r", + "breadboard1:34b.g", + "", + [ + "$bb" + ] + ], + [ + "push button2:1.l", + "breadboard1:44t.b", + "", + [ + "$bb" + ] + ], + [ + "push button2:2.l", + "breadboard1:42t.b", + "", + [ + "$bb" + ] + ], + [ + "push button2:1.r", + "breadboard1:44b.g", + "", + [ + "$bb" + ] + ], + [ + "push button2:2.r", + "breadboard1:42b.g", + "", + [ + "$bb" + ] + ], + [ + "push button3:1.l", + "breadboard1:52t.b", + "", + [ + "$bb" + ] + ], + [ + "push button3:2.l", + "breadboard1:50t.b", + "", + [ + "$bb" + ] + ], + [ + "push button3:1.r", + "breadboard1:52b.g", + "", + [ + "$bb" + ] + ], + [ + "push button3:2.r", + "breadboard1:50b.g", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:34t.a", + "breadboard1:bn.21", + "green", + [ + "v-19.2", + "h-67.2" + ] + ], + [ + "breadboard1:42t.a", + "breadboard1:bn.20", + "green", + [ + "v-28.8", + "h-153.6" + ] + ], + [ + "breadboard1:50t.a", + "breadboard1:bn.46", + "green", + [ + "v-19.2", + "h67.2" + ] + ], + [ + "breadboard1:30b.j", + "breadboard1:bp.28", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:38b.j", + "breadboard1:bp.32", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:46b.j", + "breadboard1:bp.38", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:bp.40", + "arduino uno1:5V", + "green", + [ + "v296.7", + "h-183.2" + ] + ], + [ + "resistor4:1", + "breadboard1:36b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor4:2", + "breadboard1:30b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor5:1", + "breadboard1:44b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor5:2", + "breadboard1:38b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor6:1", + "breadboard1:52b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor6:2", + "breadboard1:46b.i", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:36b.h", + "arduino uno1:4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:44b.h", + "arduino uno1:3", + "green", + [ + "v115.2", + "h-67.2" + ] + ], + [ + "breadboard1:52b.h", + "arduino uno1:2", + "green", + [ + "v124.8", + "h-144" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/button_RGB_led/diagram_breadboard_shdf.json b/arduino/level3/button_RGB_led/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..8a980714e5ef7afc1652dc464765b27865cacbc3 --- /dev/null +++ b/arduino/level3/button_RGB_led/diagram_breadboard_shdf.json @@ -0,0 +1,253 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "led1", + "type": "rgb led" + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r2", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r3", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "btn1", + "type": "push button", + "properties": { + "color": "Red" + } + }, + { + "id": "btn2", + "type": "push button", + "properties": { + "color": "LimeGreen" + } + }, + { + "id": "btn3", + "type": "push button", + "properties": { + "color": "Blue" + } + }, + { + "id": "r4", + "type": "resistor", + "properties": { + "value": "10000 ohm" + } + }, + { + "id": "r5", + "type": "resistor", + "properties": { + "value": "10000 ohm" + } + }, + { + "id": "r6", + "type": "resistor", + "properties": { + "value": "10000 ohm" + } + } + ], + "connections": [ + [ + "r1.1", + "bb1.pin18t.d" + ], + [ + "r1.2", + "bb1.pin18b.h" + ], + [ + "r2.1", + "bb1.pin20t.d" + ], + [ + "r2.2", + "bb1.pin20b.h" + ], + [ + "r3.1", + "bb1.pin21t.d" + ], + [ + "r3.2", + "bb1.pin21b.h" + ], + [ + "bb1.pin18b.i", + "uno.11" + ], + [ + "bb1.pin20b.i", + "uno.10" + ], + [ + "bb1.pin21b.i", + "uno.9" + ], + [ + "bb1.pin19t.e", + "bb1.bn.15" + ], + [ + "led1.r", + "bb1.pin18t.b" + ], + [ + "led1.com", + "bb1.pin19t.c" + ], + [ + "led1.g", + "bb1.pin20t.b" + ], + [ + "led1.b", + "bb1.pin21t.b" + ], + [ + "bb1.bn.11", + "uno.gnd.1" + ], + [ + "btn1.pin1.l", + "bb1.pin36t.b" + ], + [ + "btn1.pin2.l", + "bb1.pin34t.b" + ], + [ + "btn1.pin1.r", + "bb1.pin36b.g" + ], + [ + "btn1.pin2.r", + "bb1.pin34b.g" + ], + [ + "btn2.pin1.l", + "bb1.pin44t.b" + ], + [ + "btn2.pin2.l", + "bb1.pin42t.b" + ], + [ + "btn2.pin1.r", + "bb1.pin44b.g" + ], + [ + "btn2.pin2.r", + "bb1.pin42b.g" + ], + [ + "btn3.pin1.l", + "bb1.pin52t.b" + ], + [ + "btn3.pin2.l", + "bb1.pin50t.b" + ], + [ + "btn3.pin1.r", + "bb1.pin52b.g" + ], + [ + "btn3.pin2.r", + "bb1.pin50b.g" + ], + [ + "bb1.pin34t.a", + "bb1.bn.21" + ], + [ + "bb1.pin42t.a", + "bb1.bn.20" + ], + [ + "bb1.pin50t.a", + "bb1.bn.46" + ], + [ + "bb1.pin30b.j", + "bb1.bp.28" + ], + [ + "bb1.pin38b.j", + "bb1.bp.32" + ], + [ + "bb1.pin46b.j", + "bb1.bp.38" + ], + [ + "bb1.bp.40", + "uno.5v" + ], + [ + "r4.1", + "bb1.pin36b.i" + ], + [ + "r4.2", + "bb1.pin30b.i" + ], + [ + "r5.1", + "bb1.pin44b.i" + ], + [ + "r5.2", + "bb1.pin38b.i" + ], + [ + "r6.1", + "bb1.pin52b.i" + ], + [ + "r6.2", + "bb1.pin46b.i" + ], + [ + "bb1.pin36b.h", + "uno.4" + ], + [ + "bb1.pin44b.h", + "uno.3" + ], + [ + "bb1.pin52b.h", + "uno.2" + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/button_RGB_led/diagram_shdf.json b/arduino/level3/button_RGB_led/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..9ba879f169bfc42b9a67872b67daebfd89b6a6c9 --- /dev/null +++ b/arduino/level3/button_RGB_led/diagram_shdf.json @@ -0,0 +1,153 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "led1", + "type": "rgb led" + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r2", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r3", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "btn1", + "type": "push button", + "properties": { + "color": "Red" + } + }, + { + "id": "btn2", + "type": "push button", + "properties": { + "color": "LimeGreen" + } + }, + { + "id": "btn3", + "type": "push button", + "properties": { + "color": "Blue" + } + }, + { + "id": "r4", + "type": "resistor", + "properties": { + "value": "10000 ohm" + } + }, + { + "id": "r5", + "type": "resistor", + "properties": { + "value": "10000 ohm" + } + }, + { + "id": "r6", + "type": "resistor", + "properties": { + "value": "10000 ohm" + } + } + ], + "connections": [ + [ + "uno.gnd.1", + "led1.com" + ], + [ + "uno.gnd.1", + "btn1.pin2.l" + ], + [ + "btn1.pin2.l", + "btn2.pin2.l" + ], + [ + "btn2.pin2.l", + "btn3.pin2.l" + ], + [ + "led1.r", + "r1.1" + ], + [ + "led1.b", + "r3.1" + ], + [ + "led1.g", + "r2.1" + ], + [ + "uno.11", + "r1.2" + ], + [ + "uno.9", + "r3.2" + ], + [ + "uno.10", + "r2.2" + ], + [ + "btn1.pin1.r", + "uno.4" + ], + [ + "btn2.pin1.r", + "uno.3" + ], + [ + "btn3.pin1.r", + "uno.2" + ], + [ + "uno.5v", + "r4.2" + ], + [ + "r4.2", + "r5.2" + ], + [ + "r5.2", + "r6.2" + ], + [ + "r4.1", + "btn1.pin1.r" + ], + [ + "r5.1", + "btn2.pin1.r" + ], + [ + "r6.1", + "btn3.pin1.r" + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/button_RGB_led/platformio.ini b/arduino/level3/button_RGB_led/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level3/button_RGB_led/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level3/button_RGB_led/scenario.yaml b/arduino/level3/button_RGB_led/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7bd7d503f70eddfd3f9e7eae6910ae46a6873332 --- /dev/null +++ b/arduino/level3/button_RGB_led/scenario.yaml @@ -0,0 +1,77 @@ +author: Blind Author +description: LED lights up when the button is pressed +name: Button LED +test-values: +- part-id: rgb led1 + attr-name: common + value: "cathode" +steps: +- delay: 10ms +- set-control: + control: pressed + part-id: push button1 + value: 1 +- delay: 10ms +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: rgb led1 + pin: COM + value: 0 + - part-id: rgb led1 + pin: R + value: 1 + - part-id: rgb led1 + pin: G + value: 0 + - part-id: rgb led1 + pin: B + value: 0 +- set-control: + control: pressed + part-id: push button2 + value: 1 +- delay: 10ms +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: rgb led1 + pin: COM + value: 0 + - part-id: rgb led1 + pin: R + value: 1 + - part-id: rgb led1 + pin: G + value: 1 + - part-id: rgb led1 + pin: B + value: 0 +- set-control: + control: pressed + part-id: push button3 + value: 1 +- set-control: + control: pressed + part-id: push button1 + value: 0 +- delay: 10ms +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: rgb led1 + pin: COM + value: 0 + - part-id: rgb led1 + pin: R + value: 0 + - part-id: rgb led1 + pin: G + value: 1 + - part-id: rgb led1 + pin: B + value: 1 +version: 1.0 diff --git a/arduino/level3/button_RGB_led/src/main.ino b/arduino/level3/button_RGB_led/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..75c8e3a96bb6323b72c194770275f2bddf51ea6c --- /dev/null +++ b/arduino/level3/button_RGB_led/src/main.ino @@ -0,0 +1,31 @@ +/** + Press the button to turn on the LED + 8 APR 2025 by Blind Author +*/ + +const int BUTTON_R = 4; +const int BUTTON_G = 3; +const int BUTTON_B = 2; + +const int LED_R = 11; +const int LED_G = 10; +const int LED_B = 9; + +void setup() { + pinMode(BUTTON_B, INPUT); + pinMode(BUTTON_G, INPUT); + pinMode(BUTTON_R, INPUT); + + pinMode(LED_B, OUTPUT); + pinMode(LED_G, OUTPUT); + pinMode(LED_R, OUTPUT); +} + +void loop() { + if (digitalRead(BUTTON_R) == LOW) analogWrite(LED_R, 255); + else analogWrite(LED_R, 0); + if (digitalRead(BUTTON_G) == LOW) analogWrite(LED_G, 255); + else analogWrite(LED_G, 0); + if (digitalRead(BUTTON_B) == LOW) analogWrite(LED_B, 255); + else analogWrite(LED_B, 0); +} \ No newline at end of file diff --git a/arduino/level3/button_RGB_led/wokwi.toml b/arduino/level3/button_RGB_led/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level3/button_RGB_led/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level3/button_RTC_timezone/description.md b/arduino/level3/button_RTC_timezone/description.md new file mode 100644 index 0000000000000000000000000000000000000000..4e3e6d1f5c15170926fe5a1027f3b26282f35c16 --- /dev/null +++ b/arduino/level3/button_RTC_timezone/description.md @@ -0,0 +1,35 @@ +# Button RTC timezone + +## Project Description +This is a Arduino project that prints UTC and UTC+9 timestamp with a RTC module. + +## Hardware Components +- Arduino Uno +- Push Button +- 10kΩ resistor +- RTC module + +## Circuit Description +The RTC module is connected to the Arduino. The VCC pin is connected to 5V, the GND pin to gnd3, the SDA pin to A4, and the SCL pin to A5. Push button is connected to pin2 for input, and reads high when it is pressed. + +## Expected Behavior +When the Arduino powers up, it should: +1. Configure the button pin as an input +2. Initialize the serial monitor +3. Check if the RTC module is available and initialize it +4. Continuously retrieve the current time from the RTC +5. Check the button state, and if it is pressed, add 9 hours to adjust the timezone +6. Print the resulting timestamp + +## Success Criteria +The test is successful when: +1. The UTC timestamp is printed when the button is not pressed +2. The UTC+9 timestamp is printed when the button is pressed + +## Notes for Implementation +- The button input will read HIGH when pressed. +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. +- The format of timestamp is YYYY-MM-DDTHH:MM:SS. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level3/button_RTC_timezone/description_no_pin.md b/arduino/level3/button_RTC_timezone/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..19df62e85f2dfe7076d74f36e050abd0f11a7841 --- /dev/null +++ b/arduino/level3/button_RTC_timezone/description_no_pin.md @@ -0,0 +1,35 @@ +# Button RTC timezone + +## Project Description +This is a Arduino project that prints UTC and UTC+9 timestamp with a RTC module. + +## Hardware Components +- Arduino Uno +- Push Button +- 10kΩ resistor +- RTC module + +## Circuit Description +The RTC module is connected to the Arduino with standard wiring conventions defined by the I2C protocol. Push button uses pull-down resistor configuration. + +## Expected Behavior +When the Arduino powers up, it should: +1. Configure the button pin as an input +2. Initialize the serial monitor +3. Check if the RTC module is available and initialize it +4. Continuously retrieve the current time from the RTC +5. Check the button state, and if it is pressed, add 9 hours to adjust the timezone +6. Print the resulting timestamp + +## Success Criteria +The test is successful when: +1. The UTC timestamp is printed when the button is not pressed +2. The UTC+9 timestamp is printed when the button is pressed + +## Notes for Implementation +- The button input will read HIGH when pressed. +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. +- The format of timestamp is YYYY-MM-DDTHH:MM:SS. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level3/button_RTC_timezone/diagram.json b/arduino/level3/button_RTC_timezone/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..c5fa3714c30387bc6d49184267e2ac3989e10a4e --- /dev/null +++ b/arduino/level3/button_RTC_timezone/diagram.json @@ -0,0 +1,114 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Get the current time using an RTC sensor, and change into different timezone", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-ds1307", + "id": "rtc module1", + "top": 244.2, + "left": 278.5, + "attrs": { + "initTime": "2024-11-24T04:48:00" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -109, + "left": 249.6, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -82.45, + "left": 345.6, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "rtc module1:SCL", + "arduino uno1:A5", + "green", + [ + "h0" + ] + ], + [ + "rtc module1:SDA", + "arduino uno1:A4", + "green", + [ + "h0" + ] + ], + [ + "rtc module1:5V", + "arduino uno1:5V", + "red", + [ + "h0" + ] + ], + [ + "rtc module1:GND", + "arduino uno1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "push button1:2.l", + "arduino uno1:2", + "green", + [ + "h0" + ] + ], + [ + "push button1:2.r", + "resistor1:1", + "green", + [ + "h0" + ] + ], + [ + "resistor1:2", + "arduino uno1:GND.2", + "green", + [ + "v0", + "h18", + "v240", + "h-249.6" + ] + ], + [ + "push button1:1.r", + "arduino uno1:5V", + "green", + [ + "v0", + "h125", + "v240", + "h-278.4" + ] + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/button_RTC_timezone/diagram_breadboard.json b/arduino/level3/button_RTC_timezone/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..a9f7e520cae8f3c7cb613dbda3cd7bdbf613f989 --- /dev/null +++ b/arduino/level3/button_RTC_timezone/diagram_breadboard.json @@ -0,0 +1,219 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Get the current time using an RTC sensor, and change into different timezone", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -22.2, + "left": 290.8, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-ds1307", + "id": "rtc module1", + "top": 24.1, + "left": 582.8, + "rotate": 270, + "attrs": { + "initTime": "2024-11-24T04:48:00" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": 57, + "left": 396.6, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 119.15, + "left": 364.8, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "rtc module1:GND", + "breadboard1:31b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:5V", + "breadboard1:32b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:SDA", + "breadboard1:33b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:SCL", + "breadboard1:34b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:SQW", + "breadboard1:35b.g", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:34b.j", + "arduino uno1:A5", + "green", + [ + "v76.8", + "h-374.4" + ] + ], + [ + "breadboard1:33b.j", + "arduino uno1:A4", + "green", + [ + "v86.4", + "h-374.4" + ] + ], + [ + "breadboard1:32b.j", + "breadboard1:bp.25", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:31b.j", + "breadboard1:bn.24", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:bn.1", + "arduino uno1:GND.3", + "green", + [ + "v46.7", + "h-164" + ] + ], + [ + "breadboard1:bp.1", + "arduino uno1:5V", + "green", + [ + "v8.7", + "h-173.6" + ] + ], + [ + "push button1:1.l", + "breadboard1:14t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.l", + "breadboard1:12t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.r", + "breadboard1:14b.h", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.r", + "breadboard1:12b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:6b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:12b.i", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:6b.j", + "breadboard1:bn.4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:12t.b", + "arduino uno1:2", + "green", + [ + "v-105.6", + "h-9.6" + ] + ], + [ + "breadboard1:14b.i", + "breadboard1:bp.11", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/button_RTC_timezone/platformio.ini b/arduino/level3/button_RTC_timezone/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..df4b80305bbe895d07c0f1c0e74b60a1d2862746 --- /dev/null +++ b/arduino/level3/button_RTC_timezone/platformio.ini @@ -0,0 +1,21 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + RTClib \ No newline at end of file diff --git a/arduino/level3/button_RTC_timezone/scenario.yaml b/arduino/level3/button_RTC_timezone/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..25afb2c0d95a4850d2b1ca3ce3b37e5e0665e207 --- /dev/null +++ b/arduino/level3/button_RTC_timezone/scenario.yaml @@ -0,0 +1,21 @@ +author: Blind Author +description: change timezone with push button +name: Button RTC Timezone +test-values: + - part-type: wokwi-ds1307 + attr-name: initTime + value: "2024-11-24T04:48:00" +steps: +- delay: 100ms +- wait-serial: 2024-11-24T04:48 +- set-control: + control: pressed + part-id: push button1 + value: 1 +- wait-serial: 2024-11-24T13:48 +- set-control: + control: pressed + part-id: push button1 + value: 0 +- wait-serial: 2024-11-24T04:48 +version: 1.0 diff --git a/arduino/level3/button_RTC_timezone/src/main.ino b/arduino/level3/button_RTC_timezone/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..8bc11cde8ae5a633032d091ec3307b1b0e5fbfe6 --- /dev/null +++ b/arduino/level3/button_RTC_timezone/src/main.ino @@ -0,0 +1,33 @@ +/** + Press the button to turn on the LED + 31 Mar 2025 by Blind Author +*/ + +#include "RTClib.h" + +RTC_DS1307 rtc; + +const int BUTTON_PIN = 2; + +void setup () { + Serial.begin(115200); + pinMode(BUTTON_PIN, INPUT); + + if (! rtc.begin()) { + Serial.println("Couldn't find RTC"); + Serial.flush(); + abort(); + } +} + +void loop () { + DateTime now = rtc.now(); + + if (digitalRead(BUTTON_PIN) == HIGH) { + now = now + TimeSpan(0, 9, 0, 0); + } + + Serial.println(now.timestamp()); + + delay(500); +} diff --git a/arduino/level3/button_RTC_timezone/wokwi.toml b/arduino/level3/button_RTC_timezone/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level3/button_RTC_timezone/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level3/button_buzzer/description.md b/arduino/level3/button_buzzer/description.md new file mode 100644 index 0000000000000000000000000000000000000000..839196510b3879cc979710dcbd0decc5b8a081ef --- /dev/null +++ b/arduino/level3/button_buzzer/description.md @@ -0,0 +1,34 @@ +# Button Buzzer + +## Project Description +This is a simple Arduino project that uses pushbutton to control piezoelectric buzzer. + +## Hardware Components +- Arduino Uno +- Piezoelectric buzzer +- Push Button +- 10kΩ resistor + +## Circuit Description +Piezo buzzer and button are connected to the Arduino. The positive pin of buzzer is connected to pin9, the negative pin to gnd3. The circuit is designed so that the input reads LOW when the push button is pressed and HIGH when it is not pressed. A 10kΩ resistor is connected on the side connected to 5V. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set button pin to INPUT, and buzzer pin to OUTPUT +2. Continuously read the button value +3. If the button is pressed, play 262Hz tone + +## Success Criteria +The test is successful when: +1. Piezo buzzer runs when the button is pressed. +2. The piezo buzzer doesn’t sound when the button is not pressed. + +## Notes for Implementation +- The button reads LOW when pressed and HIGH when not pressed. +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Variants +There may be variants with buzzer pin number, button pin number, and GND pin number. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level3/button_buzzer/description_no_pin.md b/arduino/level3/button_buzzer/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..a3ecdc02e6a63809cff0b6a581d7eca0ae577298 --- /dev/null +++ b/arduino/level3/button_buzzer/description_no_pin.md @@ -0,0 +1,34 @@ +# Button Buzzer + +## Project Description +This is a simple Arduino project that uses pushbutton to control piezoelectric buzzer. + +## Hardware Components +- Arduino Uno +- Piezoelectric buzzer +- Push Button +- 10kΩ resistor + +## Circuit Description +Piezo buzzer and button are connected to the Arduino. The positive pin of buzzer is connected to arduino digital pin. The button uses a pull-up resistor configuration. The button is connected to power using 10kΩ resistor. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set button pin to INPUT, and buzzer pin to OUTPUT +2. Continuously read the button value +3. If the button is pressed, play 262Hz tone + +## Success Criteria +The test is successful when: +1. Piezo buzzer runs when the button is pressed. +2. The piezo buzzer doesn’t sound when the button is not pressed. + +## Notes for Implementation +- The button reads LOW when pressed and HIGH when not pressed. +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Variants +There may be variants with buzzer pin number, button pin number, and GND pin number. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level3/button_buzzer/diagram.json b/arduino/level3/button_buzzer/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..bcfdd3ab94410c1abd41c9e22034af2966702e74 --- /dev/null +++ b/arduino/level3/button_buzzer/diagram.json @@ -0,0 +1,101 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Control piezo buzzer with pushbutton", + "config": { + "button_pin": 3, + "buzzer_pin": 9, + "gnd_pin": "GND.3" + }, + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-buzzer", + "id": "piezoelectric buzzer1", + "top": -141.6, + "left": 97.8, + "attrs": { + "volume": "0.1" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -137.8, + "left": 220.8, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -130.45, + "left": 307.2, + "attrs": { + "value": "1000" + } + } + ], + "connections": [ + [ + "piezoelectric buzzer1:1", + "arduino uno1:GND.1", + "green", + [ + "v0" + ] + ], + [ + "push button1:1.r", + "resistor1:1", + "green", + [ + "v0" + ] + ], + [ + "resistor1:2", + "arduino uno1:5V", + "green", + [ + "v326.4", + "h-222" + ] + ], + [ + "push button1:1.l", + "arduino uno1:3", + "green", + [ + "h0" + ] + ], + [ + "piezoelectric buzzer1:2", + "arduino uno1:9", + "green", + [ + "v0" + ] + ], + [ + "push button1:2.r", + "arduino uno1:GND.1", + "green", + [ + "h19.4", + "v57.8", + "h-211.2" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/button_buzzer/diagram_breadboard.json b/arduino/level3/button_buzzer/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..1177e7702fa2db1b9cf0ce763b4f4059fce822c2 --- /dev/null +++ b/arduino/level3/button_buzzer/diagram_breadboard.json @@ -0,0 +1,178 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Control piezo buzzer with pushbutton", + "config": { + "button_pin": 3, + "buzzer_pin": 9 + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -223.8, + "left": -122, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-buzzer", + "id": "piezoelectric buzzer1", + "top": -180, + "left": 78.6, + "attrs": { + "volume": "0.1" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -144.6, + "left": 156.6, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -82.45, + "left": 201.6, + "attrs": { + "value": "1000" + } + } + ], + "connections": [ + [ + "breadboard1:bn.17", + "breadboard1:22b.h", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:23b.h", + "arduino uno1:9", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:38b.j", + "breadboard1:bp.31", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:bp.32", + "arduino uno1:5V", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:32t.b", + "arduino uno1:3", + "green", + [ + "v-28.8", + "h9.6" + ] + ], + [ + "breadboard1:30t.b", + "breadboard1:bn.22", + "green", + [ + "v-19.2", + "h-19.2" + ] + ], + [ + "breadboard1:bn.14", + "arduino uno1:GND.1", + "green", + [ + "v0" + ] + ], + [ + "piezoelectric buzzer1:1", + "breadboard1:22b.g", + "", + [ + "$bb" + ] + ], + [ + "piezoelectric buzzer1:2", + "breadboard1:23b.g", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.l", + "breadboard1:32t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.l", + "breadboard1:30t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.r", + "breadboard1:32b.h", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.r", + "breadboard1:30b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:32b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:38b.i", + "", + [ + "$bb" + ] + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/button_buzzer/diagram_breadboard_shdf.json b/arduino/level3/button_buzzer/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..019cc9769e5609ce22c6390dc9620da3486672cb --- /dev/null +++ b/arduino/level3/button_buzzer/diagram_breadboard_shdf.json @@ -0,0 +1,92 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "bz1", + "type": "piezoelectric buzzer" + }, + { + "id": "btn1", + "type": "push button", + "properties": { + "color": "green" + } + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "1000 ohm" + } + } + ], + "connections": [ + [ + "bb1.bn.17", + "bb1.pin22b.h" + ], + [ + "bb1.pin23b.h", + "uno.9" + ], + [ + "bb1.pin38b.j", + "bb1.bp.31" + ], + [ + "bb1.bp.32", + "uno.5v" + ], + [ + "bb1.pin32t.b", + "uno.3" + ], + [ + "bb1.pin30t.b", + "bb1.bn.22" + ], + [ + "bb1.bn.14", + "uno.gnd.1" + ], + [ + "bz1.1", + "bb1.pin22b.g" + ], + [ + "bz1.2", + "bb1.pin23b.g" + ], + [ + "btn1.pin1.l", + "bb1.pin32t.c" + ], + [ + "btn1.pin2.l", + "bb1.pin30t.c" + ], + [ + "btn1.pin1.r", + "bb1.pin32b.h" + ], + [ + "btn1.pin2.r", + "bb1.pin30b.h" + ], + [ + "r1.1", + "bb1.pin32b.i" + ], + [ + "r1.2", + "bb1.pin38b.i" + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/button_buzzer/diagram_shdf.json b/arduino/level3/button_buzzer/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..35521247b0cf147eeef30d50312fa022a96448a7 --- /dev/null +++ b/arduino/level3/button_buzzer/diagram_shdf.json @@ -0,0 +1,52 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "bz1", + "type": "piezoelectric buzzer" + }, + { + "id": "btn1", + "type": "push button", + "properties": { + "color": "green" + } + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "1000 ohm" + } + } + ], + "connections": [ + [ + "bz1.1", + "uno.gnd.1" + ], + [ + "btn1.pin1.r", + "r1.1" + ], + [ + "r1.2", + "uno.5v" + ], + [ + "btn1.pin1.l", + "uno.3" + ], + [ + "bz1.2", + "uno.9" + ], + [ + "btn1.pin2.r", + "uno.gnd.1" + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/button_buzzer/platformio.ini b/arduino/level3/button_buzzer/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level3/button_buzzer/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level3/button_buzzer/scenario.yaml b/arduino/level3/button_buzzer/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e9664158b2fd351f23097db24e317da867277fe4 --- /dev/null +++ b/arduino/level3/button_buzzer/scenario.yaml @@ -0,0 +1,26 @@ +author: Blind Author +description: Control piezo buzzer with pushbutton +name: Button Buzzer +steps: +- delay: 100ms +- set-control: + control: pressed + part-id: push button1 + value: 1 +- wait-pin: + timeout: 1000 + interval: 100 + part-id: piezoelectric buzzer1 + pin: 2 + value: 1 +- set-control: + control: pressed + part-id: push button1 + value: 0 +- wait-pin: + timeout: 1000 + interval: 100 + part-id: piezoelectric buzzer1 + pin: 2 + value: 0 +version: 1.0 diff --git a/arduino/level3/button_buzzer/src/main.ino b/arduino/level3/button_buzzer/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..267ebe0acdf70e321759cdae1fa0274e45e4d082 --- /dev/null +++ b/arduino/level3/button_buzzer/src/main.ino @@ -0,0 +1,18 @@ +/* + Use a pushbutton to control piezoelectric buzzer. + 9 APR 2025 by Blind Author +*/ + +const int BUTTON_PIN = 3; +const int BUZZER_PIN = 9; + +void setup() { + pinMode(BUTTON_PIN, INPUT); + pinMode(BUZZER_PIN, OUTPUT); +} + +void loop() { + if (digitalRead(BUTTON_PIN) == LOW) { + tone(BUZZER_PIN, 262, 250); + } else noTone(BUZZER_PIN); +} diff --git a/arduino/level3/button_buzzer/wokwi.toml b/arduino/level3/button_buzzer/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level3/button_buzzer/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level3/button_led/description.md b/arduino/level3/button_led/description.md new file mode 100644 index 0000000000000000000000000000000000000000..8b913663876b7d7fc0eb9066eb777a8bac02075f --- /dev/null +++ b/arduino/level3/button_led/description.md @@ -0,0 +1,38 @@ +# Button Controlled LED + +## Project Description +This is a Arduino project that controls an LED with a pushbutton. The LED will turn on only while the button is pressed and turn off when released. + +## Hardware Components +- Arduino Uno +- Push Button +- 220Ω resistor +- LED + +## Circuit Description +The circuit consists of: +- A pushbutton connected to a digital pin. +- An LED connected to a digital output pin through a 220Ω current-limiting resistor +- The cathode (negative leg) of the LED is connected to ground + +## Expected Behavior +When the Arduino powers up, it should: +1. Configure the button pin as INPUT +2. Configure the LED pin as OUTPUT +3. Continuously monitor the button state +4. Turn the LED ON when the button is pressed (reads LOW) +5. Turn the LED OFF when the button is released (reads HIGH) + +## Success Criteria +The test is successful when: +1. The LED turns on immediately when the button is pressed +2. The LED remains on only while the button is held down +3. The LED turns off immediately when the button is released + +## Notes for Implementation +- The button input will read LOW when pressed if using a pull-up resistor configuration +- Ensure proper current-limiting resistor for the LED based on its specifications +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level3/button_led/description_no_pin.md b/arduino/level3/button_led/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..ce68bb6dfd3cf2bc91388526adeb52647568583b --- /dev/null +++ b/arduino/level3/button_led/description_no_pin.md @@ -0,0 +1,35 @@ +# Button Controlled LED + +## Project Description +This is a Arduino project that controls an LED with a pushbutton. The LED will turn on only while the button is pressed and turn off when released. + +## Hardware Components +- Arduino Uno +- Push Button +- 220Ω resistor +- LED + +## Circuit Description +A push button is connected to arduino digital pin. A LED is connected to a digital pin through a 220Ω current-limiting resistor. + +## Expected Behavior +When the Arduino powers up, it should: +1. Configure the button pin as INPUT +2. Configure the LED pin as OUTPUT +3. Continuously monitor the button state +4. Turn the LED ON when the button is pressed (reads LOW) +5. Turn the LED OFF when the button is released (reads HIGH) + +## Success Criteria +The test is successful when: +1. The LED turns on immediately when the button is pressed +2. The LED remains on only while the button is held down +3. The LED turns off immediately when the button is released + +## Notes for Implementation +- The button input will read LOW when pressed if using a pull-up resistor configuration +- Ensure proper current-limiting resistor for the LED based on its specifications +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level3/button_led/diagram.json b/arduino/level3/button_led/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..04aad814fb25ce2ab93304f5aa019e26194d85d0 --- /dev/null +++ b/arduino/level3/button_led/diagram.json @@ -0,0 +1,83 @@ +{ + "version": 1.0, + "author": "Blind Author", + "editor": "Blind Author", + "description": "Button LED", + "parts": [ + { + "id": "arduino uno1", + "type": "wokwi-arduino-uno", + "top": 200, + "left": 20 + }, + { + "id": "resistor1", + "type": "wokwi-resistor", + "top": 75, + "left": 115, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "id": "push button1", + "type": "wokwi-pushbutton", + "top": 125, + "left": 180, + "rotate": 90 + }, + { + "id": "led1", + "type": "wokwi-led", + "left": 120, + "top": 0, + "attrs": { + "color": "red" + } + } + ], + "connections": [ + [ + "arduino uno1:GND.1", + "led1:C", + "black", + [] + ], + [ + "resistor1:1", + "led1:A", + "green", + [] + ], + [ + "arduino uno1:13", + "resistor1:2", + "green", + [ + "*", + "h0" + ] + ], + [ + "arduino uno1:2", + "push button1:1.r", + "red", + [ + "v-12", + "*", + "h0" + ] + ], + [ + "arduino uno1:GND.1", + "push button1:2.l", + "red", + [ + "v-95", + "*", + "h0" + ] + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/button_led/diagram_breadboard.json b/arduino/level3/button_led/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..9fb7fd08076e3616efdf1d69cd7b1937bb5f0c2d --- /dev/null +++ b/arduino/level3/button_led/diagram_breadboard.json @@ -0,0 +1,155 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Button LED", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -89.4, + "left": -6.8, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 200, + "left": 20, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 24, + "left": 114.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -10.2, + "left": 252.6, + "rotate": 90, + "attrs": {} + }, + { + "type": "wokwi-led", + "id": "led1", + "top": -51.6, + "left": 119, + "attrs": { + "color": "red" + } + } + ], + "connections": [ + [ + "push button1:1.l", + "breadboard1:30t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.l", + "breadboard1:28t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.r", + "breadboard1:30b.h", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.r", + "breadboard1:28b.h", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:bn.18", + "breadboard1:28t.b", + "green", + [ + "v0" + ] + ], + [ + "arduino uno1:2", + "breadboard1:30b.j", + "green", + [ + "v0" + ] + ], + [ + "arduino uno1:GND.1", + "breadboard1:bn.9", + "black", + [ + "v0" + ] + ], + [ + "led1:A", + "breadboard1:14t.d", + "", + [ + "$bb" + ] + ], + [ + "led1:C", + "breadboard1:13t.d", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:bn.8", + "breadboard1:13t.e", + "green", + [ + "v0" + ] + ], + [ + "resistor1:1", + "breadboard1:14t.e", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:14b.i", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:14b.j", + "arduino uno1:13", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/button_led/diagram_breadboard_shdf.json b/arduino/level3/button_led/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..a69b17195f329336e392894710ba31b2ddd34f9d --- /dev/null +++ b/arduino/level3/button_led/diagram_breadboard_shdf.json @@ -0,0 +1,84 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "button", + "type": "push button" + }, + { + "id": "led", + "type": "led", + "properties": { + "color": "red" + } + } + ], + "connections": [ + [ + "button.pin1.l", + "bb1.pin30t.c" + ], + [ + "button.pin2.l", + "bb1.pin28t.c" + ], + [ + "button.pin1.r", + "bb1.pin30b.h" + ], + [ + "button.pin2.r", + "bb1.pin28b.h" + ], + [ + "bb1.bn.18", + "bb1.pin28t.b" + ], + [ + "uno.2", + "bb1.pin30b.j" + ], + [ + "uno.gnd.1", + "bb1.bn.9" + ], + [ + "led.a", + "bb1.pin14t.d" + ], + [ + "led.c", + "bb1.pin13t.d" + ], + [ + "bb1.bn.8", + "bb1.pin13t.e" + ], + [ + "r1.1", + "bb1.pin14t.e" + ], + [ + "r1.2", + "bb1.pin14b.i" + ], + [ + "bb1.pin14b.j", + "uno.13" + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/button_led/diagram_shdf.json b/arduino/level3/button_led/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..2f54058b70781934dc13352943fc03fb2eaffbd0 --- /dev/null +++ b/arduino/level3/button_led/diagram_shdf.json @@ -0,0 +1,48 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "btn1", + "type": "push button" + }, + { + "id": "led1", + "type": "led", + "properties": { + "color": "red" + } + } + ], + "connections": [ + [ + "uno.gnd.1", + "led1.c" + ], + [ + "r1.1", + "led1.a" + ], + [ + "uno.13", + "r1.2" + ], + [ + "uno.2", + "btn1.pin1.r" + ], + [ + "uno.gnd.1", + "btn1.pin2.l" + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/button_led/platformio.ini b/arduino/level3/button_led/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level3/button_led/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level3/button_led/scenario.yaml b/arduino/level3/button_led/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..da0853651530061e2f5a890f7b9291084d022cc6 --- /dev/null +++ b/arduino/level3/button_led/scenario.yaml @@ -0,0 +1,61 @@ +author: Blind Author +description: LED lights up when the button is pressed +name: Button LED +steps: +- delay: 100ms +- set-control: + control: pressed + part-id: push button1 + value: 1 +- delay: 100ms +- expect-pin: + part-id: led1 + pin: C + value: 1 +- expect-pin: + part-id: led1 + pin: A + value: 1 +- delay: 1000ms +- set-control: + control: pressed + part-id: push button1 + value: 0 +- delay: 100ms +- expect-pin: + part-id: led1 + pin: C + value: 0 +- expect-pin: + part-id: led1 + pin: A + value: 0 +- delay: 1000ms +- set-control: + control: pressed + part-id: push button1 + value: 1 +- delay: 100ms +- expect-pin: + part-id: led1 + pin: C + value: 0 +- expect-pin: + part-id: led1 + pin: A + value: 1 +- delay: 1000ms +- set-control: + control: pressed + part-id: push button1 + value: 0 +- delay: 100ms +- expect-pin: + part-id: led1 + pin: C + value: 0 +- expect-pin: + part-id: led1 + pin: A + value: 0 +version: 1.0 diff --git a/arduino/level3/button_led/src/main.ino b/arduino/level3/button_led/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..d87987071e7c762c1d0be1c16bf4fd21b7c54552 --- /dev/null +++ b/arduino/level3/button_led/src/main.ino @@ -0,0 +1,28 @@ +/** + Press the button to turn on the LED + 31 Mar 2025 by Blind Author +*/ + +const int BUTTON_PIN = 2; +const int LED_PIN = 13; + +void setup() { + Serial.begin(9600); + Serial.println("Button LED test starts"); + + pinMode(BUTTON_PIN, INPUT_PULLUP); + pinMode(LED_PIN, OUTPUT); +} + +void loop() { + int buttonState = digitalRead(BUTTON_PIN); + + if (buttonState == LOW) { + digitalWrite(LED_PIN, HIGH); + } + + else { + digitalWrite(LED_PIN, LOW); + } + +} \ No newline at end of file diff --git a/arduino/level3/button_led/wokwi.toml b/arduino/level3/button_led/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level3/button_led/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level3/button_servo_motor/description.md b/arduino/level3/button_servo_motor/description.md new file mode 100644 index 0000000000000000000000000000000000000000..5ca87ed21303d6cb094c752062072eeb4390f344 --- /dev/null +++ b/arduino/level3/button_servo_motor/description.md @@ -0,0 +1,35 @@ +# Button Servo Motor + +## Project Description +This is a simple Arduino project that controls servo motor with a pushbutton. + +## Hardware Components +- Arduino Uno +- Servo Motor +- Push Button +- 10kΩ resistor + +## Circuit Description +Button is connected to Arduino pin pin3 with 10kΩ pull up resistor. PWM pin of the servo motor is connected to pin9, and V+ pin to 5V. All GND pins are connected to gnd1. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial monitor as baud rate 9600 +2. Attaches the servo on pin pin9 to the servo object +3. Set button pin mode as INPUT +4. Continuously print the angle of the servo motor to serial monitor +5. Continuously read the button value, and set the servo motor to 180 degrees when the button is pressed, and to 90 degrees when it is not + +## Success Criteria +The test is successful when: +1. The pressed button and the corresponding servo motor angle line up perfectly. + +## Notes for Implementation +- Use the Servo library to create and control a servo object. +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Variants +This project may have different variants with the servo motor, button, GND connected to different pins, and the angle of the servo motor. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level3/button_servo_motor/description_no_pin.md b/arduino/level3/button_servo_motor/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..6601a8a7df8afeedead60538c33eea789746b598 --- /dev/null +++ b/arduino/level3/button_servo_motor/description_no_pin.md @@ -0,0 +1,35 @@ +# Button Servo Motor + +## Project Description +This is a simple Arduino project that controls servo motor with a pushbutton. + +## Hardware Components +- Arduino Uno +- Servo Motor +- Push Button +- 10kΩ resistor + +## Circuit Description +Button is connected to Arduino with 10kΩ pull up resistor. PWM pin of the servo motor is connected to arduino digital pin. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial monitor as baud rate 9600 +2. Attaches the servo to the servo object +3. Set button pin mode as INPUT +4. Continuously print the angle of the servo motor to serial monitor +5. Continuously read the button value, and set the servo motor to 180 degrees when the button is pressed, and to 90 degrees when it is not + +## Success Criteria +The test is successful when: +1. The pressed button and the corresponding servo motor angle line up perfectly. + +## Notes for Implementation +- Use the Servo library to create and control a servo object. +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Variants +This project may have different variants with the servo motor, button, GND connected to different pins, and the angle of the servo motor. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level3/button_servo_motor/diagram.json b/arduino/level3/button_servo_motor/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..f7f52f7c1d9e6519fbd05989dfb78ced171e3943 --- /dev/null +++ b/arduino/level3/button_servo_motor/diagram.json @@ -0,0 +1,121 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Control servo motor with push button", + "config": { + "servo_pin": 9, + "button_pin": 3, + "servo_angle_1": 180, + "servo_angle_2": 90, + "gnd_pin": "GND.1" + }, + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 200, + "left": 20, + "attrs": {} + }, + { + "type": "wokwi-servo", + "id": "servo motor1", + "top": 200, + "left": 400, + "attrs": { + "hornColor": "black" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": 57, + "left": 147, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 128.75, + "left": 192, + "attrs": { + "value": "1000" + } + } + ], + "connections": [ + [ + "arduino uno1:9", + "servo motor1:PWM", + "orange", + [ + "v-20", + "*", + "h0", + "h-52" + ] + ], + [ + "arduino uno1:5V", + "servo motor1:V+", + "red", + [ + "v20", + "h0", + "*", + "h-20" + ] + ], + [ + "arduino uno1:GND.1", + "servo motor1:GND", + "black", + [ + "v-28", + "h240", + "*", + "h-20" + ] + ], + [ + "push button1:1.r", + "resistor1:1", + "green", + [ + "v0" + ] + ], + [ + "resistor1:2", + "arduino uno1:5V", + "green", + [ + "v0", + "h56.4" + ] + ], + [ + "push button1:1.l", + "arduino uno1:3", + "green", + [ + "v38.4", + "h115.2" + ] + ], + [ + "push button1:2.l", + "arduino uno1:GND.1", + "green", + [ + "v0", + "h-38.6" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/button_servo_motor/diagram_breadboard.json b/arduino/level3/button_servo_motor/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..642669186604b460f9383f35d0815b811065702c --- /dev/null +++ b/arduino/level3/button_servo_motor/diagram_breadboard.json @@ -0,0 +1,177 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Control servo motor with push button", + "config": { + "servo_pin": 9, + "button_pin": 3, + "servo_angle_1": 180, + "servo_angle_2": 90, + "gnd_pin": "GND.1" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -41.4, + "left": -74, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 200, + "left": 20, + "attrs": {} + }, + { + "type": "wokwi-servo", + "id": "servo motor1", + "top": 151.6, + "left": 374.4, + "attrs": { + "hornColor": "black" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": 28.2, + "left": 89.4, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 99.95, + "left": 134.4, + "attrs": { + "value": "1000" + } + } + ], + "connections": [ + [ + "push button1:1.l", + "breadboard1:20t.b", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.l", + "breadboard1:18t.b", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.r", + "breadboard1:20b.g", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.r", + "breadboard1:18b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:20b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:26b.i", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:26b.j", + "breadboard1:bp.21", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:bp.26", + "arduino uno1:5V", + "green", + [ + "v47.1", + "h56.8", + "v230.4", + "h-144" + ] + ], + [ + "breadboard1:18t.a", + "breadboard1:bn.11", + "green", + [ + "v-9.6", + "h-38.4" + ] + ], + [ + "breadboard1:bn.13", + "arduino uno1:GND.1", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:20b.h", + "arduino uno1:3", + "green", + [ + "v86.4", + "h115.2" + ] + ], + [ + "servo motor1:GND", + "breadboard1:bn.31", + "black", + [ + "h0" + ] + ], + [ + "servo motor1:V+", + "breadboard1:bp.33", + "green", + [ + "h0" + ] + ], + [ + "servo motor1:PWM", + "arduino uno1:9", + "green", + [ + "h0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/button_servo_motor/diagram_breadboard_shdf.json b/arduino/level3/button_servo_motor/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..3e7d413bc9c72dad108422328736c69bfdd36269 --- /dev/null +++ b/arduino/level3/button_servo_motor/diagram_breadboard_shdf.json @@ -0,0 +1,88 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno1", + "type": "arduino uno" + }, + { + "id": "servo1", + "type": "servo motor" + }, + { + "id": "btn1", + "type": "push button", + "properties": { + "color": "green" + } + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "1000 ohm" + } + } + ], + "connections": [ + [ + "btn1.pin1.l", + "bb1.pin20t.b" + ], + [ + "btn1.pin2.l", + "bb1.pin18t.b" + ], + [ + "btn1.pin1.r", + "bb1.pin20b.g" + ], + [ + "btn1.pin2.r", + "bb1.pin18b.g" + ], + [ + "r1.1", + "bb1.pin20b.i" + ], + [ + "r1.2", + "bb1.pin26b.i" + ], + [ + "bb1.pin26b.j", + "bb1.bp.21" + ], + [ + "bb1.bp.26", + "uno1.5v" + ], + [ + "bb1.pin18t.a", + "bb1.bn.11" + ], + [ + "bb1.bn.13", + "uno1.gnd.1" + ], + [ + "bb1.pin20b.h", + "uno1.3" + ], + [ + "servo1.gnd", + "bb1.bn.31" + ], + [ + "servo1.v+", + "bb1.bp.33" + ], + [ + "servo1.pwm", + "uno1.9" + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/button_servo_motor/diagram_shdf.json b/arduino/level3/button_servo_motor/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..33cb4c9f3ac5119d8f846fca9c5f9bbe1b8b7771 --- /dev/null +++ b/arduino/level3/button_servo_motor/diagram_shdf.json @@ -0,0 +1,56 @@ +{ + "components": [ + { + "id": "uno1", + "type": "arduino uno" + }, + { + "id": "servo1", + "type": "servo motor" + }, + { + "id": "btn1", + "type": "push button", + "properties": { + "color": "green" + } + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "1000 ohm" + } + } + ], + "connections": [ + [ + "uno1.9", + "servo1.pwm" + ], + [ + "uno1.5v", + "servo1.v+" + ], + [ + "uno1.gnd.1", + "servo1.gnd" + ], + [ + "btn1.pin1.r", + "r1.1" + ], + [ + "r1.2", + "uno1.5v" + ], + [ + "btn1.pin1.l", + "uno1.3" + ], + [ + "btn1.pin2.l", + "uno1.gnd.1" + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/button_servo_motor/platformio.ini b/arduino/level3/button_servo_motor/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..2033d8801bf6e9e5c685f82885d2aa139c33b31f --- /dev/null +++ b/arduino/level3/button_servo_motor/platformio.ini @@ -0,0 +1,21 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Servo + Arduino \ No newline at end of file diff --git a/arduino/level3/button_servo_motor/scenario.yaml b/arduino/level3/button_servo_motor/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..dab508c11639f2aa165c4451488d71f43e7f49e2 --- /dev/null +++ b/arduino/level3/button_servo_motor/scenario.yaml @@ -0,0 +1,51 @@ +author: Blind Author +description: Control a servo motor with button +name: Button Servo Motor Control +steps: +- delay: 100ms +- expect-pin: + part-id: servo motor1 + pin: PWM + value: 0 +- expect-pin: + part-id: servo motor1 + pin: V+ + value: 1 +- expect-pin: + part-id: servo motor1 + pin: GND + value: 0 +- set-control: + control: pressed + part-id: push button1 + value: 1 +- wait-pin: + timeout: 5000 + interval: 10 + part-id: servo motor1 + pin: PWM + value: 1 +- wait-serial: '180' +- set-control: + control: pressed + part-id: push button1 + value: 0 +- wait-pin: + timeout: 5000 + interval: 10 + part-id: servo motor1 + pin: PWM + value: 1 +- wait-serial: '90' +- set-control: + control: pressed + part-id: push button1 + value: 1 +- wait-pin: + timeout: 5000 + interval: 10 + part-id: servo motor1 + pin: PWM + value: 1 +- wait-serial: '180' +version: 1.0 diff --git a/arduino/level3/button_servo_motor/src/main.ino b/arduino/level3/button_servo_motor/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..c60d199c051966cee03a1289751fb90e7cd66f52 --- /dev/null +++ b/arduino/level3/button_servo_motor/src/main.ino @@ -0,0 +1,31 @@ +/* + Press the button to control servo motor + 8 APR 2025 by Blind Author +*/ + +#include + +Servo myservo; + +const int BUTTON_PIN = 3; +const int SERVO_PIN = 9; + +void setup() { + Serial.begin(9600); + myservo.attach(SERVO_PIN); + pinMode(BUTTON_PIN, INPUT); +} + +void loop() { + if (digitalRead(BUTTON_PIN) == LOW) { + myservo.write(180); + delay(10); + } else { + myservo.write(90); + delay(10); + } + + Serial.println(myservo.read()); + delay(100); +} + diff --git a/arduino/level3/button_servo_motor/wokwi.toml b/arduino/level3/button_servo_motor/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level3/button_servo_motor/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level3/dht22_LCD_display/description.md b/arduino/level3/dht22_LCD_display/description.md new file mode 100644 index 0000000000000000000000000000000000000000..e83df991dd894727945e81082e3df2261e2c6880 --- /dev/null +++ b/arduino/level3/dht22_LCD_display/description.md @@ -0,0 +1,29 @@ +# LCD Display with DHT22 sensor + +## Project Description +This is an Arduino project that shows dht22 sensor value to the ili9341 lcd display. + +## Hardware Components +- Arduino Uno +- Ili9341 LCD Display +- DHT22 sensor + +## Circuit Description +Ili9341 LCD Display and dht22 sensor are connected to the Arudino Uno board. RST, D/C, CS, MOSI, MISO, SCK pin of LCD display is connected to arduino pin 8 to 13, respectively. Each GND pins of LCD display and DHT sensor are connected to arduino pin gnd1. Each VCC pins of LCD display and DHT sensor are connected to arduino pin 5v. SDA pin of DHT sensor is connected to arduino pin2. + +## Expected Behavior +When the Arduino powers up, it should: +1. Declare Adafruit_ILI9341 object +2. Begin display and change it to landscape mode (rotation 1) +3. Set the text color to white, and size to 2 +4. Initialize and begin the dht22 sensor +5. Continuously read the humidity and temperature value of dht22 sensor +6. If the sensor value is changed, clear the display with a black background and print the humidity at position (0, 0), in the following format: "Humidity: {humidity}", and print the temperature at position (0, 100) in the following format: "Temperature: {temperature}" + +## Success Criteria +The test is successful when: +1. Sensor value is successfully printed to the display, with correct position, color, and size. + +## Notes for Implementation +- Use the following libraries: , , and . +- Wait for 100 milliseconds at the end of every loop iteration. diff --git a/arduino/level3/dht22_LCD_display/description_no_pin.md b/arduino/level3/dht22_LCD_display/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..eb2d97e498f26f626fae7e9027efeedce6b0ba05 --- /dev/null +++ b/arduino/level3/dht22_LCD_display/description_no_pin.md @@ -0,0 +1,29 @@ +# LCD Display with DHT22 sensor + +## Project Description +This is an Arduino project that shows dht22 sensor value to the ili9341 lcd display. + +## Hardware Components +- Arduino Uno +- Ili9341 LCD Display +- DHT22 sensor + +## Circuit Description +Ili9341 LCD Display and dht22 sensor are connected to the Arudino Uno board. RST, D/C, CS, MOSI, MISO, SCK pin of LCD display is connected to arduino digital pins. SDA pin of DHT sensor is connected to arduino digital pin. + +## Expected Behavior +When the Arduino powers up, it should: +1. Declare Adafruit_ILI9341 object +2. Begin display and change it to landscape mode (rotation 1) +3. Set the text color to white, and size to 2 +4. Initialize and begin the dht22 sensor +5. Continuously read the humidity and temperature value of dht22 sensor +6. If the sensor value is changed, clear the display with a black background and print the humidity at position (0, 0), in the following format: "Humidity: {humidity}", and print the temperature at position (0, 100) in the following format: "Temperature: {temperature}" + +## Success Criteria +The test is successful when: +1. Sensor value is successfully printed to the display, with correct position, color, and size. + +## Notes for Implementation +- Use the following libraries: , , and . +- Wait for 100 milliseconds at the end of every loop iteration. diff --git a/arduino/level3/dht22_LCD_display/diagram.json b/arduino/level3/dht22_LCD_display/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..becff80259c5b26706164f7836b274d9ef1744f1 --- /dev/null +++ b/arduino/level3/dht22_LCD_display/diagram.json @@ -0,0 +1,134 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Show humidity and temperature with lcd display", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 331.89, + "left": 1.49, + "attrs": {} + }, + { + "type": "wokwi-ili9341", + "id": "ili9341 lcd display1", + "top": 5.51, + "left": 40.77, + "attrs": {} + }, + { + "type": "wokwi-dht22", + "id": "dht22 sensor1", + "top": 0.3, + "left": 311.4, + "attrs": {} + } + ], + "connections": [ + [ + "ili9341 lcd display1:GND", + "arduino uno1:GND.1", + "black", + [ + "v22", + "h-46" + ] + ], + [ + "ili9341 lcd display1:SCK", + "arduino uno1:13", + "green", + [ + "v16", + "h-75" + ] + ], + [ + "ili9341 lcd display1:MISO", + "arduino uno1:12", + "limegreen", + [ + "v20", + "h-78" + ] + ], + [ + "ili9341 lcd display1:MOSI", + "arduino uno1:11", + "green", + [ + "v24", + "h-75" + ] + ], + [ + "ili9341 lcd display1:CS", + "arduino uno1:10", + "orange", + [ + "v32", + "h-64" + ] + ], + [ + "ili9341 lcd display1:D/C", + "arduino uno1:9", + "purple", + [ + "v36", + "h-84" + ] + ], + [ + "ili9341 lcd display1:VCC", + "arduino uno1:5V", + "red", + [ + "v24.09", + "h-98.67", + "v230.4", + "h172.8" + ] + ], + [ + "dht22 sensor1:VCC", + "arduino uno1:5V", + "red", + [ + "v201.6", + "h-336", + "v230.4", + "h172.8" + ] + ], + [ + "dht22 sensor1:GND", + "arduino uno1:GND.1", + "black", + [ + "v201.6", + "h-240" + ] + ], + [ + "dht22 sensor1:SDA", + "arduino uno1:2", + "green", + [ + "v211.2", + "h-95.9" + ] + ], + [ + "ili9341 lcd display1:RST", + "arduino uno1:8", + "green", + [ + "v33.69", + "h54.93" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/dht22_LCD_display/diagram_breadboard.json b/arduino/level3/dht22_LCD_display/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..ab2e1351fd60801e54979b6cda1e1865d1b81a44 --- /dev/null +++ b/arduino/level3/dht22_LCD_display/diagram_breadboard.json @@ -0,0 +1,255 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Show serial input with lcd display", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": 45, + "left": -160.4, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 331.89, + "left": 1.49, + "attrs": {} + }, + { + "type": "wokwi-ili9341", + "id": "ili9341 lcd display1", + "top": -124, + "left": 47.7, + "attrs": {} + }, + { + "type": "wokwi-dht22", + "id": "dht22 sensor1", + "top": 57.9, + "left": 282.6, + "attrs": {} + } + ], + "connections": [ + [ + "breadboard1:25b.i", + "breadboard1:bp.20", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:26b.i", + "breadboard1:bn.20", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:27b.j", + "arduino uno1:10", + "orange", + [ + "v105.6", + "h38.4" + ] + ], + [ + "breadboard1:29b.j", + "arduino uno1:9", + "green", + [ + "v96", + "h28.8" + ] + ], + [ + "breadboard1:30b.j", + "arduino uno1:11", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:31b.j", + "arduino uno1:13", + "green", + [ + "v67.2", + "h-28.8" + ] + ], + [ + "breadboard1:33b.j", + "arduino uno1:12", + "green", + [ + "v48", + "h-38.4" + ] + ], + [ + "breadboard1:bp.8", + "arduino uno1:5V", + "red", + [ + "v306.3", + "h191.2" + ] + ], + [ + "breadboard1:bn.12", + "arduino uno1:GND.1", + "black", + [ + "v75.5", + "h104.8" + ] + ], + [ + "breadboard1:28b.j", + "arduino uno1:8", + "green", + [ + "v105.6", + "h57.6", + "v28.8" + ] + ], + [ + "ili9341 lcd display1:VCC", + "breadboard1:25b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:GND", + "breadboard1:26b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:CS", + "breadboard1:27b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:RST", + "breadboard1:28b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:D/C", + "breadboard1:29b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:MOSI", + "breadboard1:30b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:SCK", + "breadboard1:31b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:LED", + "breadboard1:32b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:MISO", + "breadboard1:33b.f", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:VCC", + "breadboard1:46b.g", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:SDA", + "breadboard1:47b.g", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:NC", + "breadboard1:48b.g", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:GND", + "breadboard1:49b.g", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:46b.i", + "breadboard1:bp.36", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:49b.i", + "breadboard1:bn.40", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:47b.i", + "arduino uno1:2", + "green", + [ + "v115.2", + "h-67.2" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/dht22_LCD_display/platformio.ini b/arduino/level3/dht22_LCD_display/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..c207aa50d0350945bcea039b01acf71d70e9536a --- /dev/null +++ b/arduino/level3/dht22_LCD_display/platformio.ini @@ -0,0 +1,22 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + Adafruit ILI9341 + DHT sensor library \ No newline at end of file diff --git a/arduino/level3/dht22_LCD_display/scenario.yaml b/arduino/level3/dht22_LCD_display/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b92e558c0872e29733a7849107f3ee71e97a0f21 --- /dev/null +++ b/arduino/level3/dht22_LCD_display/scenario.yaml @@ -0,0 +1,33 @@ +author: Blind Author +description: Show dht22 sensor value to LCD display +name: dht22 LCD Display +steps: +- delay: 3000ms +- take-screenshot: + part-id: ili9341 lcd display1 + compare-with: screenshots/0.png +- set-control: + part-id: dht22 sensor1 + control: humidity + value: 26.8 +- set-control: + part-id: dht22 sensor1 + control: temperature + value: 36.5 +- delay: 3000ms +- take-screenshot: + part-id: ili9341 lcd display1 + compare-with: screenshots/1.png +- set-control: + part-id: dht22 sensor1 + control: humidity + value: 80.9 +- set-control: + part-id: dht22 sensor1 + control: temperature + value: 10.3 +- delay: 3000ms +- take-screenshot: + part-id: ili9341 lcd display1 + compare-with: screenshots/2.png +version: 1.0 diff --git a/arduino/level3/dht22_LCD_display/screenshots/0.png b/arduino/level3/dht22_LCD_display/screenshots/0.png new file mode 100644 index 0000000000000000000000000000000000000000..e6365c16aed49f21c9d32b35050164d94747016d --- /dev/null +++ b/arduino/level3/dht22_LCD_display/screenshots/0.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:594efdabfa0e781fc9fed7164f98fd8ae279f7d549c1e7868d73d27e1da84913 +size 2061 diff --git a/arduino/level3/dht22_LCD_display/screenshots/1.png b/arduino/level3/dht22_LCD_display/screenshots/1.png new file mode 100644 index 0000000000000000000000000000000000000000..3fdac67155c7e73f2746330a007b56dafa482594 --- /dev/null +++ b/arduino/level3/dht22_LCD_display/screenshots/1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7fda75201b07afeda13af5c0aeaa8c5761a80405f1388eb448342aa46ca7737f +size 2024 diff --git a/arduino/level3/dht22_LCD_display/screenshots/2.png b/arduino/level3/dht22_LCD_display/screenshots/2.png new file mode 100644 index 0000000000000000000000000000000000000000..af478fa3d85eda8ab3510dfc8016570f59689033 --- /dev/null +++ b/arduino/level3/dht22_LCD_display/screenshots/2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:52954a437a912adc68ca155d43d8d3b4666328c315bd6fe12773c0fd83bd30d9 +size 2041 diff --git a/arduino/level3/dht22_LCD_display/src/main.ino b/arduino/level3/dht22_LCD_display/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..c86215360fdd5f1fb0bee5b1441d09235ae27737 --- /dev/null +++ b/arduino/level3/dht22_LCD_display/src/main.ino @@ -0,0 +1,53 @@ +/** + Show dht22 sensor value in ili9431 lcd display + 06 MAY 2025 by Blind Author +*/ + +#include +#include +#include +#include "DHT.h" + +#define TFT_CS 10 +#define TFT_DC 9 +#define TFT_RST 8 + +#define DHTPIN 2 +#define DHTTYPE DHT22 + +Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); + +DHT dht(DHTPIN, DHTTYPE); + +bool pressed = true; + +float humidity = 0; +float temperature = 0; + +void setup() { + tft.begin(); + tft.setRotation(1); + tft.fillScreen(ILI9341_BLACK); + + tft.setTextColor(ILI9341_WHITE); + tft.setTextSize(2); + + dht.begin(); +} + +void loop() { + + if (dht.readHumidity() != humidity || dht.readTemperature() != temperature) { + humidity = dht.readHumidity(); + temperature = dht.readTemperature(); + + tft.fillScreen(ILI9341_BLACK); + tft.setCursor(0, 0); + tft.print("Humidity: "); + tft.println(humidity); + tft.setCursor(0, 100); + tft.print("Temperature: "); + tft.println(temperature); + } + delay(100); +} \ No newline at end of file diff --git a/arduino/level3/dht22_LCD_display/wokwi.toml b/arduino/level3/dht22_LCD_display/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level3/dht22_LCD_display/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level3/multiplexer_photoresistor/description.md b/arduino/level3/multiplexer_photoresistor/description.md new file mode 100644 index 0000000000000000000000000000000000000000..f3b217a56b1c361ca68c6a22ee6a824cccf41e97 --- /dev/null +++ b/arduino/level3/multiplexer_photoresistor/description.md @@ -0,0 +1,31 @@ +# Multiplexer with Photoresistor + +## Project Description +This is an arduino project that reads 6 photoresistor sensor value with 16 channel analog multiplexer. + +## Hardware Components +- Arduino Uno +- Photoresistor * 6 +- Analog Multiplexer + +## Circuit Description +Six photoresistors are connected to an Arduino Uno through an analog multiplexer. +The AO pins of photoresistors 1 through 6 are connected to channels I0 to I5 of the multiplexer, respectively. +The VCC pins of the photoresistors are connected to the Arduino's 5V pin, and the GND pins are connected to gnd2. +The SIG pin of the multiplexer is connected to the Arduino's A0 pin and is used to read values. +The S0 to S3 pins of the multiplexer are connected to Arduino digital pins 2 to 5. +The EN and GND pins of the multiplexer are connected to gnd2, and the VCC pin is connected to the 5V pin. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set Arduino pins 2 to 5 as output pins. +2. Initialize the Serial Monitor for communication. +3. Continuously read the sensor values from each channel (0 to 5). +4. Print each sensor value to the Serial Monitor in the format: "Sensor {channel}: {light value}" for example: "Sensor 0: 544" + +## Success Criteria +The test is successful when: +1. The light value of each photoresistor (1 to 6) is printed to the Serial Monitor in the correct format. + +## Notes for Implementation +- No other component is connected to I6~I15 pin of the anaolog multiplexer. diff --git a/arduino/level3/multiplexer_photoresistor/description_no_pin.md b/arduino/level3/multiplexer_photoresistor/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..9ab64f217540283cfa70b04c4bff4822b56e7051 --- /dev/null +++ b/arduino/level3/multiplexer_photoresistor/description_no_pin.md @@ -0,0 +1,29 @@ +# Multiplexer with Photoresistor + +## Project Description +This is an arduino project that reads 6 photoresistor sensor value with 16 channel analog multiplexer. + +## Hardware Components +- Arduino Uno +- Photoresistor * 6 +- Analog Multiplexer + +## Circuit Description +Six photoresistors are connected to an Arduino Uno through an analog multiplexer. +The AO pins of photoresistors 1 through 6 are connected to channels I0 to I5 of the multiplexer, respectively. +The SIG pin of the multiplexer is connected to the Arduino's analog pin and is used to read values. +The S0 to S3 pins of the multiplexer are connected to Arduino digital pins. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set select pins as output pins. +2. Initialize the Serial Monitor for communication. +3. Continuously read the sensor values from each channel (0 to 5). +4. Print each sensor value to the Serial Monitor in the format: "Sensor {channel}: {light value}" for example: "Sensor 0: 544" + +## Success Criteria +The test is successful when: +1. The light value of each photoresistor (1 to 6) is printed to the Serial Monitor in the correct format. + +## Notes for Implementation +- No other component is connected to I6~I15 pin of the anaolog multiplexer. diff --git a/arduino/level3/multiplexer_photoresistor/diagram.json b/arduino/level3/multiplexer_photoresistor/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..a4f36f10f8f9bd85734da925dc3f9d3ac8f7a4e9 --- /dev/null +++ b/arduino/level3/multiplexer_photoresistor/diagram.json @@ -0,0 +1,330 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read 6 photoresistor value with analog multiplexer", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "board-cd74hc4067", + "id": "analog multiplexer1", + "top": 24.45, + "left": -129.71, + "attrs": {} + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor1", + "top": -140.8, + "left": -431.2, + "attrs": { + "lux": "10" + } + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor2", + "top": -64, + "left": -431.2, + "attrs": { + "lux": "100" + } + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor3", + "top": 12.8, + "left": -431.2, + "attrs": { + "lux": "200" + } + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor4", + "top": 89.6, + "left": -431.2, + "attrs": { + "lux": "300" + } + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor5", + "top": 166.4, + "left": -431.2, + "attrs": { + "lux": "400" + } + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor6", + "top": 243.2, + "left": -431.2, + "attrs": { + "lux": "500" + } + } + ], + "connections": [ + [ + "arduino uno1:GND.2", + "photoresistor6:GND", + "black", + [ + "v0" + ] + ], + [ + "arduino uno1:GND.2", + "photoresistor5:GND", + "black", + [ + "v77.3", + "h-409.5", + "v-76.8" + ] + ], + [ + "arduino uno1:GND.2", + "photoresistor4:GND", + "black", + [ + "v77.3", + "h-409.5", + "v-153.6" + ] + ], + [ + "arduino uno1:GND.2", + "photoresistor3:GND", + "black", + [ + "v77.3", + "h-409.5", + "v-230.4" + ] + ], + [ + "arduino uno1:GND.2", + "photoresistor2:GND", + "black", + [ + "v77.3", + "h-409.5", + "v-307.2" + ] + ], + [ + "arduino uno1:GND.2", + "photoresistor1:GND", + "black", + [ + "v77.3", + "h-409.5", + "v-384" + ] + ], + [ + "arduino uno1:5V", + "photoresistor6:VCC", + "red", + [ + "v0" + ] + ], + [ + "arduino uno1:5V", + "photoresistor5:VCC", + "red", + [ + "v67.7", + "h-390.4", + "v-86.4" + ] + ], + [ + "arduino uno1:5V", + "photoresistor4:VCC", + "red", + [ + "v67.7", + "h-390.4", + "v-153.6", + "h-38.4" + ] + ], + [ + "arduino uno1:5V", + "photoresistor3:VCC", + "red", + [ + "v67.7", + "h-390.4", + "v-230.4" + ] + ], + [ + "arduino uno1:5V", + "photoresistor2:VCC", + "red", + [ + "v67.7", + "h-390.4", + "v-307.2" + ] + ], + [ + "arduino uno1:5V", + "photoresistor1:VCC", + "red", + [ + "v67.7", + "h-390.4", + "v-384" + ] + ], + [ + "photoresistor1:AO", + "analog multiplexer1:I0", + "green", + [ + "h105.6", + "v268.1" + ] + ], + [ + "photoresistor2:AO", + "analog multiplexer1:I1", + "green", + [ + "h96", + "v181.7" + ] + ], + [ + "photoresistor3:AO", + "analog multiplexer1:I2", + "green", + [ + "h86.4", + "v95.3" + ] + ], + [ + "photoresistor4:AO", + "analog multiplexer1:I3", + "green", + [ + "h76.8", + "v8.9" + ] + ], + [ + "photoresistor5:AO", + "analog multiplexer1:I4", + "green", + [ + "h67.2", + "v-87.1" + ] + ], + [ + "photoresistor6:AO", + "analog multiplexer1:I5", + "green", + [ + "h57.6", + "v-163.9" + ] + ], + [ + "analog multiplexer1:COM", + "arduino uno1:A0", + "green", + [ + "v0", + "h67.23", + "v144", + "h220.8" + ] + ], + [ + "analog multiplexer1:VCC", + "arduino uno1:5V", + "red", + [ + "h48.03", + "v134.4", + "h182.4" + ] + ], + [ + "analog multiplexer1:GND", + "arduino uno1:GND.2", + "black", + [ + "h19.23", + "v134.4", + "h230.4" + ] + ], + [ + "analog multiplexer1:EN", + "arduino uno1:GND.2", + "green", + [ + "h19.23", + "v153.6", + "h230.4" + ] + ], + [ + "analog multiplexer1:S0", + "arduino uno1:2", + "green", + [ + "h57.63", + "v-115.2", + "h259.2" + ] + ], + [ + "analog multiplexer1:S1", + "arduino uno1:3", + "green", + [ + "h48.03", + "v-115.2", + "h259.2" + ] + ], + [ + "analog multiplexer1:S2", + "arduino uno1:4", + "green", + [ + "h38.43", + "v-115.2", + "h259.2" + ] + ], + [ + "analog multiplexer1:S3", + "arduino uno1:5", + "green", + [ + "h28.83", + "v-115.2", + "h259.2" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/multiplexer_photoresistor/diagram_breadboard.json b/arduino/level3/multiplexer_photoresistor/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..57105ab6d613ada826215ed6da5fe3486bc1f067 --- /dev/null +++ b/arduino/level3/multiplexer_photoresistor/diagram_breadboard.json @@ -0,0 +1,713 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read 6 photoresistor value with analog multiplexer", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -377.4, + "left": -323.6, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -95.4, + "left": -135, + "attrs": {} + }, + { + "type": "board-cd74hc4067", + "id": "analog multiplexer1", + "top": -360.79, + "left": 175.55, + "rotate": 270, + "attrs": {} + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor1", + "top": -374.7, + "left": -351.1, + "rotate": 90, + "attrs": { + "lux": "10" + } + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor2", + "top": -374.7, + "left": -283.9, + "rotate": 90, + "attrs": { + "lux": "100" + } + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor3", + "top": -374.7, + "left": -216.7, + "rotate": 90, + "attrs": { + "lux": "200" + } + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor4", + "top": -374.7, + "left": -149.5, + "rotate": 90, + "attrs": { + "lux": "300" + } + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor5", + "top": -374.7, + "left": -82.3, + "rotate": 90, + "attrs": { + "lux": "400" + } + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor6", + "top": -374.7, + "left": -15.1, + "rotate": 90, + "attrs": { + "lux": "500" + } + } + ], + "connections": [ + [ + "photoresistor2:VCC", + "breadboard1:13b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor2:GND", + "breadboard1:12b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor2:DO", + "breadboard1:11b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor2:AO", + "breadboard1:10b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor3:VCC", + "breadboard1:20b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor3:GND", + "breadboard1:19b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor3:DO", + "breadboard1:18b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor3:AO", + "breadboard1:17b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor4:VCC", + "breadboard1:27b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor4:GND", + "breadboard1:26b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor4:DO", + "breadboard1:25b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor4:AO", + "breadboard1:24b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor5:VCC", + "breadboard1:34b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor5:GND", + "breadboard1:33b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor5:DO", + "breadboard1:32b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor5:AO", + "breadboard1:31b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor6:VCC", + "breadboard1:41b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor6:GND", + "breadboard1:40b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor6:DO", + "breadboard1:39b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor6:AO", + "breadboard1:38b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I15", + "breadboard1:46b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I14", + "breadboard1:47b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I13", + "breadboard1:48b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I12", + "breadboard1:49b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I11", + "breadboard1:50b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I10", + "breadboard1:51b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I9", + "breadboard1:52b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I8", + "breadboard1:53b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I7", + "breadboard1:54b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I6", + "breadboard1:55b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I5", + "breadboard1:56b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I4", + "breadboard1:57b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I3", + "breadboard1:58b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I2", + "breadboard1:59b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I1", + "breadboard1:60b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I0", + "breadboard1:61b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:COM", + "breadboard1:50t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:S3", + "breadboard1:51t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:S2", + "breadboard1:52t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:S1", + "breadboard1:53t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:S0", + "breadboard1:54t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:EN", + "breadboard1:55t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:VCC", + "breadboard1:56t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:GND", + "breadboard1:57t.c", + "", + [ + "$bb" + ] + ], + [ + "photoresistor1:VCC", + "breadboard1:6b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor1:GND", + "breadboard1:5b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor1:DO", + "breadboard1:4b.f", + "", + [ + "$bb" + ] + ], + [ + "photoresistor1:AO", + "breadboard1:3b.f", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:3b.g", + "breadboard1:61b.g", + "green", + [ + "v38.4", + "h556.8" + ] + ], + [ + "breadboard1:10b.g", + "breadboard1:60b.g", + "green", + [ + "v28.8", + "h480" + ] + ], + [ + "breadboard1:17b.g", + "breadboard1:59b.g", + "green", + [ + "v19.2", + "h403.2" + ] + ], + [ + "breadboard1:24b.g", + "breadboard1:58b.g", + "green", + [ + "v9.6", + "h326.4" + ] + ], + [ + "breadboard1:31b.g", + "breadboard1:57b.g", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:38b.g", + "breadboard1:56b.g", + "green", + [ + "v-19.2", + "h172.8" + ] + ], + [ + "breadboard1:bp.4", + "breadboard1:6b.g", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:13b.g", + "breadboard1:bp.10", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:20b.g", + "breadboard1:bp.15", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:27b.g", + "breadboard1:bp.21", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:34b.g", + "breadboard1:bp.27", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:41b.g", + "breadboard1:bp.33", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:5b.g", + "breadboard1:bn.3", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:12b.g", + "breadboard1:bn.9", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:19b.g", + "breadboard1:bn.15", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:26b.g", + "breadboard1:bn.20", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:33b.g", + "breadboard1:bn.26", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:40b.g", + "breadboard1:bn.32", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:57t.b", + "breadboard1:bn.50", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:56t.b", + "breadboard1:bp.45", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:55t.b", + "breadboard1:bn.45", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:50t.b", + "arduino uno1:A0", + "green", + [ + "v432", + "h-96" + ] + ], + [ + "breadboard1:54t.b", + "arduino uno1:2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:53t.b", + "arduino uno1:3", + "green", + [ + "v211.2", + "h-115.2" + ] + ], + [ + "breadboard1:52t.b", + "arduino uno1:4", + "green", + [ + "v201.6", + "h-105.6" + ] + ], + [ + "breadboard1:51t.b", + "arduino uno1:5", + "green", + [ + "v192", + "h-115.2" + ] + ], + [ + "breadboard1:bn.1", + "arduino uno1:GND.2", + "black", + [ + "v296.3", + "h306.4" + ] + ], + [ + "breadboard1:bp.1", + "arduino uno1:5V", + "red", + [ + "v-0.9", + "h-10.4", + "v316.8", + "h316.8" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/multiplexer_photoresistor/platformio.ini b/arduino/level3/multiplexer_photoresistor/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level3/multiplexer_photoresistor/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level3/multiplexer_photoresistor/scenario.yaml b/arduino/level3/multiplexer_photoresistor/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..839f9573cecb4dc1dc1582ff5dec4859089f20e8 --- /dev/null +++ b/arduino/level3/multiplexer_photoresistor/scenario.yaml @@ -0,0 +1,31 @@ +author: Blind Author +description: Read 6 photoresistor value with 16 channel analog multiplexer +name: Multiplexer with photoresistor +steps: +- delay: 100ms +- wait-serial: 'ensor 0: 853' +- wait-serial: 'ensor 1: 511' +- wait-serial: 'ensor 2: 389' +- wait-serial: 'ensor 3: 323' +- wait-serial: 'ensor 4: 280' +- wait-serial: 'ensor 5: 250' +test-values: +- attr-name: lux + part-id: photoresistor1 + value: '10' +- attr-name: lux + part-id: photoresistor2 + value: '100' +- attr-name: lux + part-id: photoresistor3 + value: '200' +- attr-name: lux + part-id: photoresistor4 + value: '300' +- attr-name: lux + part-id: photoresistor5 + value: '400' +- attr-name: lux + part-id: photoresistor6 + value: '500' +version: 1.0 diff --git a/arduino/level3/multiplexer_photoresistor/src/main.ino b/arduino/level3/multiplexer_photoresistor/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..f37a1d7b82dba6ae09e760567f0618f786495f89 --- /dev/null +++ b/arduino/level3/multiplexer_photoresistor/src/main.ino @@ -0,0 +1,35 @@ +/** + Read 6 LDR sensor values with 16 channel analog multiplexer + 03 MAY 2025 by Blind Author +*/ + +const int s0 = 2, s1 = 3, s2 = 4, s3 = 5; +const int SIG = A0; + +int selectPins[4] = {s0, s1, s2, s3}; + +void setup() { + Serial.begin(9600); + for (int i = 0; i < 4; i++) { + pinMode(selectPins[i], OUTPUT); + } +} + +int readMux(int channel) { + for (int i = 0; i < 4; i++) { + digitalWrite(selectPins[i], (channel >> i) & 1); + } + delay(100); + return analogRead(SIG); +} + +void loop() { + for (int i = 0; i < 6; i++) { + int lightValue = readMux(i); + Serial.print("sensor "); + Serial.print(i); + Serial.print(": "); + Serial.println(lightValue); + } + delay(1000); +} \ No newline at end of file diff --git a/arduino/level3/multiplexer_photoresistor/wokwi.toml b/arduino/level3/multiplexer_photoresistor/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level3/multiplexer_photoresistor/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level3/multiplexer_potentiometer/description.md b/arduino/level3/multiplexer_potentiometer/description.md new file mode 100644 index 0000000000000000000000000000000000000000..ed11f280d58e60f5f51f1af9cc78b72310994037 --- /dev/null +++ b/arduino/level3/multiplexer_potentiometer/description.md @@ -0,0 +1,31 @@ +# Multiplexer with potentiometer + +## Project Description +This is an arduino project that reads 5 potentiometer value with 16 channel analog multiplexer. + +## Hardware Components +- Arduino Uno +- Potentiometer * 5 +- Analog Multiplexer + +## Circuit Description +Five potentiometers are connected to an Arduino Uno through an analog multiplexer. +The SIG pins of potentiometers 1 through 5 are connected to channel pins I0 to I4 of the multiplexer, respectively. +The VCC pins of the potentiometers are connected to the Arduino's 5V pin, and the GND pins are connected to gnd2. +The SIG pin of the multiplexer is connected to the Arduino's A0 pin and is used to read values. +The S0 to S3 pins of the multiplexer are connected to Arduino digital pins 2 to 5. +The EN and GND pins of the multiplexer are connected to gnd2, and the VCC pin is connected to the 5V pin. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set Arduino pins 2 to 5 as output pins. +2. Initialize the Serial Monitor for communication. +3. Continuously read the sensor values from each channel (0 to 4). +4. Print each sensor value to the Serial Monitor in the format: "Sensor {channel}: {potentiometer value}" for example: "Sensor 0: 544" + +## Success Criteria +The test is successful when: +1. The value of each potentiometer (1 to 5) is printed to the Serial Monitor in the correct format. + +## Notes for Implementation +- No other component is connected to I5~I15 pin of the anaolog multiplexer. diff --git a/arduino/level3/multiplexer_potentiometer/description_no_pin.md b/arduino/level3/multiplexer_potentiometer/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..bf9942c5bf55e7de43145c83c33955b5a2fb23af --- /dev/null +++ b/arduino/level3/multiplexer_potentiometer/description_no_pin.md @@ -0,0 +1,29 @@ +# Multiplexer with potentiometer + +## Project Description +This is an arduino project that reads 5 potentiometer value with 16 channel analog multiplexer. + +## Hardware Components +- Arduino Uno +- Potentiometer * 5 +- Analog Multiplexer + +## Circuit Description +Five potentiometers are connected to an Arduino Uno through an analog multiplexer. +The SIG pins of potentiometers 1 through 5 are connected to channel pins I0 to I4 of the multiplexer, respectively. +The SIG pin of the multiplexer is connected to the Arduino's analog pin and is used to read values. +The S0 to S3 pins of the multiplexer are connected to Arduino digital pins. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set select pins as output pins. +2. Initialize the Serial Monitor for communication. +3. Continuously read the sensor values from each channel (0 to 4). +4. Print each sensor value to the Serial Monitor in the format: "Sensor {channel}: {potentiometer value}" for example: "Sensor 0: 544" + +## Success Criteria +The test is successful when: +1. The value of each potentiometer (1 to 5) is printed to the Serial Monitor in the correct format. + +## Notes for Implementation +- No other component is connected to I5~I15 pin of the anaolog multiplexer. diff --git a/arduino/level3/multiplexer_potentiometer/diagram.json b/arduino/level3/multiplexer_potentiometer/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..6d3e11bd8cf9345d222a42e3f468651e9ef21b3e --- /dev/null +++ b/arduino/level3/multiplexer_potentiometer/diagram.json @@ -0,0 +1,260 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read multiple potentiometer value with analog multiplexer", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 192.6, + "left": 37.8, + "attrs": {} + }, + { + "type": "board-cd74hc4067", + "id": "analog multiplexer1", + "top": -148.35, + "left": 283.09, + "attrs": {} + }, + { + "type": "wokwi-potentiometer", + "id": "potentiometer1", + "top": -260.5, + "left": 9.4, + "attrs": {} + }, + { + "type": "wokwi-potentiometer", + "id": "potentiometer2", + "top": -260.5, + "left": 95.8, + "attrs": {} + }, + { + "type": "wokwi-potentiometer", + "id": "potentiometer3", + "top": -260.5, + "left": 182.2, + "attrs": {} + }, + { + "type": "wokwi-potentiometer", + "id": "potentiometer4", + "top": -260.5, + "left": 268.6, + "attrs": {} + }, + { + "type": "wokwi-potentiometer", + "id": "potentiometer5", + "top": -260.5, + "left": 355, + "attrs": {} + } + ], + "connections": [ + [ + "analog multiplexer1:GND", + "arduino uno1:GND.2", + "black", + [ + "h48.03", + "v470.4", + "h-182.4" + ] + ], + [ + "analog multiplexer1:VCC", + "arduino uno1:5V", + "red", + [ + "h57.63", + "v470.4", + "h-201.6" + ] + ], + [ + "analog multiplexer1:EN", + "arduino uno1:GND.2", + "black", + [ + "h67.23", + "v489.6", + "h-192" + ] + ], + [ + "analog multiplexer1:S0", + "arduino uno1:2", + "green", + [ + "h19.23", + "v249.6", + "h-76.8" + ] + ], + [ + "analog multiplexer1:S1", + "arduino uno1:3", + "green", + [ + "h28.83", + "v249.6", + "h-105.6" + ] + ], + [ + "analog multiplexer1:S2", + "arduino uno1:4", + "green", + [ + "h38.43", + "v249.6", + "h-124.8" + ] + ], + [ + "analog multiplexer1:S3", + "arduino uno1:5", + "green", + [ + "h9.63", + "v249.6", + "h-96" + ] + ], + [ + "analog multiplexer1:COM", + "arduino uno1:A0", + "green", + [ + "v0", + "h86.43", + "v508.8", + "h-182.4" + ] + ], + [ + "potentiometer1:GND", + "arduino uno1:GND.2", + "black", + [ + "v0" + ] + ], + [ + "potentiometer2:GND", + "arduino uno1:GND.2", + "black", + [ + "v0" + ] + ], + [ + "potentiometer3:GND", + "arduino uno1:GND.2", + "black", + [ + "v0" + ] + ], + [ + "potentiometer4:GND", + "arduino uno1:GND.2", + "black", + [ + "v0" + ] + ], + [ + "potentiometer5:GND", + "arduino uno1:GND.2", + "black", + [ + "v0" + ] + ], + [ + "potentiometer1:SIG", + "analog multiplexer1:I0", + "green", + [ + "v0" + ] + ], + [ + "potentiometer2:SIG", + "analog multiplexer1:I1", + "green", + [ + "v0" + ] + ], + [ + "potentiometer3:SIG", + "analog multiplexer1:I2", + "green", + [ + "v0" + ] + ], + [ + "potentiometer4:SIG", + "analog multiplexer1:I3", + "green", + [ + "v0" + ] + ], + [ + "potentiometer5:SIG", + "analog multiplexer1:I4", + "green", + [ + "v0" + ] + ], + [ + "potentiometer1:VCC", + "arduino uno1:5V", + "red", + [ + "v0" + ] + ], + [ + "potentiometer2:VCC", + "arduino uno1:5V", + "red", + [ + "v0" + ] + ], + [ + "potentiometer3:VCC", + "arduino uno1:5V", + "red", + [ + "v0" + ] + ], + [ + "potentiometer4:VCC", + "arduino uno1:5V", + "red", + [ + "v0" + ] + ], + [ + "potentiometer5:VCC", + "arduino uno1:5V", + "red", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/multiplexer_potentiometer/diagram_breadboard.json b/arduino/level3/multiplexer_potentiometer/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..824f447ace2f8faa90f42d32a896bd6ddd392186 --- /dev/null +++ b/arduino/level3/multiplexer_potentiometer/diagram_breadboard.json @@ -0,0 +1,580 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read multiple potentiometer value with analog multiplexer", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -70.2, + "left": -74, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 144.6, + "left": 57, + "attrs": {} + }, + { + "type": "board-cd74hc4067", + "id": "analog multiplexer1", + "top": -50.41, + "left": 387.45, + "rotate": 90, + "attrs": {} + }, + { + "type": "wokwi-potentiometer", + "id": "potentiometer1", + "top": -78.1, + "left": -77, + "attrs": {} + }, + { + "type": "wokwi-potentiometer", + "id": "potentiometer2", + "top": -78.1, + "left": -0.2, + "attrs": {} + }, + { + "type": "wokwi-potentiometer", + "id": "potentiometer3", + "top": -78.1, + "left": 76.6, + "attrs": {} + }, + { + "type": "wokwi-potentiometer", + "id": "potentiometer4", + "top": -78.1, + "left": 153.4, + "attrs": {} + }, + { + "type": "wokwi-potentiometer", + "id": "potentiometer5", + "top": -78.1, + "left": 230.2, + "attrs": {} + } + ], + "connections": [ + [ + "analog multiplexer1:I15", + "breadboard1:57t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I14", + "breadboard1:56t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I13", + "breadboard1:55t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I12", + "breadboard1:54t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I11", + "breadboard1:53t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I10", + "breadboard1:52t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I9", + "breadboard1:51t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I8", + "breadboard1:50t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I7", + "breadboard1:49t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I6", + "breadboard1:48t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I5", + "breadboard1:47t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I4", + "breadboard1:46t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I3", + "breadboard1:45t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I2", + "breadboard1:44t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I1", + "breadboard1:43t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:I0", + "breadboard1:42t.c", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:COM", + "breadboard1:53b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:S3", + "breadboard1:52b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:S2", + "breadboard1:51b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:S1", + "breadboard1:50b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:S0", + "breadboard1:49b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:EN", + "breadboard1:48b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:VCC", + "breadboard1:47b.f", + "", + [ + "$bb" + ] + ], + [ + "analog multiplexer1:GND", + "breadboard1:46b.f", + "", + [ + "$bb" + ] + ], + [ + "potentiometer1:GND", + "breadboard1:1t.b", + "", + [ + "$bb" + ] + ], + [ + "potentiometer1:SIG", + "breadboard1:2t.b", + "", + [ + "$bb" + ] + ], + [ + "potentiometer1:VCC", + "breadboard1:3t.b", + "", + [ + "$bb" + ] + ], + [ + "potentiometer2:GND", + "breadboard1:9t.b", + "", + [ + "$bb" + ] + ], + [ + "potentiometer2:SIG", + "breadboard1:10t.b", + "", + [ + "$bb" + ] + ], + [ + "potentiometer2:VCC", + "breadboard1:11t.b", + "", + [ + "$bb" + ] + ], + [ + "potentiometer3:GND", + "breadboard1:17t.b", + "", + [ + "$bb" + ] + ], + [ + "potentiometer3:SIG", + "breadboard1:18t.b", + "", + [ + "$bb" + ] + ], + [ + "potentiometer3:VCC", + "breadboard1:19t.b", + "", + [ + "$bb" + ] + ], + [ + "potentiometer4:GND", + "breadboard1:25t.b", + "", + [ + "$bb" + ] + ], + [ + "potentiometer4:SIG", + "breadboard1:26t.b", + "", + [ + "$bb" + ] + ], + [ + "potentiometer4:VCC", + "breadboard1:27t.b", + "", + [ + "$bb" + ] + ], + [ + "potentiometer5:GND", + "breadboard1:33t.b", + "", + [ + "$bb" + ] + ], + [ + "potentiometer5:SIG", + "breadboard1:34t.b", + "", + [ + "$bb" + ] + ], + [ + "potentiometer5:VCC", + "breadboard1:35t.b", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:1t.c", + "breadboard1:bn.1", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:9t.c", + "breadboard1:bn.6", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:17t.c", + "breadboard1:bn.13", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:25t.c", + "breadboard1:bn.20", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:33t.c", + "breadboard1:bn.26", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:11t.d", + "breadboard1:bp.8", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:19t.d", + "breadboard1:bp.15", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:3t.d", + "breadboard1:bp.1", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:27t.d", + "breadboard1:bp.21", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:35t.d", + "breadboard1:bp.28", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:2t.d", + "breadboard1:42t.b", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:10t.d", + "breadboard1:43t.b", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:18t.d", + "breadboard1:44t.b", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:26t.d", + "breadboard1:45t.b", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:34t.d", + "breadboard1:46t.b", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:46b.h", + "breadboard1:bn.36", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:47b.h", + "breadboard1:bp.38", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:48b.h", + "breadboard1:bn.39", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:49b.h", + "arduino uno1:2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:50b.h", + "arduino uno1:3", + "green", + [ + "v76.8", + "h-134.4" + ] + ], + [ + "breadboard1:51b.h", + "arduino uno1:4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:52b.h", + "arduino uno1:5", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:53b.h", + "arduino uno1:A0", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:bn.50", + "arduino uno1:GND.3", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:bp.50", + "arduino uno1:5V", + "red", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/multiplexer_potentiometer/platformio.ini b/arduino/level3/multiplexer_potentiometer/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level3/multiplexer_potentiometer/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level3/multiplexer_potentiometer/scenario.yaml b/arduino/level3/multiplexer_potentiometer/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..29da47a0fed3038180e303410247cac8bba22cc0 --- /dev/null +++ b/arduino/level3/multiplexer_potentiometer/scenario.yaml @@ -0,0 +1,61 @@ +author: Blind Author +description: Read multiple potentiometer values with analog multiplexer +name: Multiplexer Potentiometer +steps: +- delay: 100ms +- wait-serial: 'ensor 0: 0' +- wait-serial: 'ensor 1: 0' +- wait-serial: 'ensor 2: 0' +- wait-serial: 'ensor 3: 0' +- wait-serial: 'ensor 4: 0' +- set-control: + part-id: potentiometer1 + control: position + value: 0.1 +- set-control: + part-id: potentiometer2 + control: position + value: 0.2 +- set-control: + part-id: potentiometer3 + control: position + value: 0.3 +- set-control: + part-id: potentiometer4 + control: position + value: 0.4 +- set-control: + part-id: potentiometer5 + control: position + value: 0.5 +- wait-serial: 'ensor 0: 102' +- wait-serial: 'ensor 1: 204' +- wait-serial: 'ensor 2: 307' +- wait-serial: 'ensor 3: 409' +- wait-serial: 'ensor 4: 512' +- set-control: + part-id: potentiometer1 + control: position + value: 0.6 +- set-control: + part-id: potentiometer2 + control: position + value: 0.7 +- set-control: + part-id: potentiometer3 + control: position + value: 0.8 +- set-control: + part-id: potentiometer4 + control: position + value: 0.9 +- set-control: + part-id: potentiometer5 + control: position + value: 1.0 +- wait-serial: 'ensor 0: 614' +- wait-serial: 'ensor 1: 716' +- wait-serial: 'ensor 2: 819' +- wait-serial: 'ensor 3: 921' +- wait-serial: 'ensor 4: 1023' +version: 1.0 diff --git a/arduino/level3/multiplexer_potentiometer/src/main.ino b/arduino/level3/multiplexer_potentiometer/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..2040418bf7b32b184315debb47220377205b0fff --- /dev/null +++ b/arduino/level3/multiplexer_potentiometer/src/main.ino @@ -0,0 +1,36 @@ +/** + Read multiple potentiometer value with analog multiplexer + 05 MAY 2025 by Blind Author +*/ + +const int s0 = 2, s1 = 3, s2 = 4, s3 = 5; +const int SIG = A0; + +int selectPins[4] = {s0, s1, s2, s3}; + +void setup() { + Serial.begin(9600); + for (int i = 0; i < 4; i++) { + pinMode(selectPins[i], OUTPUT); + } +} + +void loop() { + for (int i = 0; i < 5; i++) { + selectMuxChannel(i); + delay(500); + + int sensorReading = analogRead(SIG); + Serial.print("sensor "); + Serial.print(i); + Serial.print(": "); + Serial.println(sensorReading); + } +} + +void selectMuxChannel(int channel) { + digitalWrite(s0, bitRead(channel, 0)); + digitalWrite(s1, bitRead(channel, 1)); + digitalWrite(s2, bitRead(channel, 2)); + digitalWrite(s3, bitRead(channel, 3)); +} \ No newline at end of file diff --git a/arduino/level3/multiplexer_potentiometer/wokwi.toml b/arduino/level3/multiplexer_potentiometer/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level3/multiplexer_potentiometer/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level3/photoresistor_bar_led/description.md b/arduino/level3/photoresistor_bar_led/description.md new file mode 100644 index 0000000000000000000000000000000000000000..150967fa396e8b488810528b45b7987b2a7c3af8 --- /dev/null +++ b/arduino/level3/photoresistor_bar_led/description.md @@ -0,0 +1,30 @@ +# Photoresitor Bar LED + +## Project Description +This is an Arduino project that lights up the bar LED according to the brightness level. + +## Hardware Components +- Arduino Uno +- Bar graph LED +- 220Ω resistor * 10 +- Photoresistor + +## Circuit Description +Anode pins 1~10 of bar graph LED are connected to pin2, pin3, pin4, pin5, pin6, pin7, pin8, pin9, pin10, pin11, respectively. The cathode pins 1 through 10 of the bar graph LED are connected to GND pin gnd2 through 220kΩ resistors. The AO pin of the photoresistor is connected to the arduino a0 pin, the GND pin is connected to gnd2, and the VCC pin is connected to 5v. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set pin2, pin3, pin4, pin5, pin6, pin7, pin8, pin9, pin10, pin11 pin mode as OUTPUT +2. Set photoresistor signal pin A0 as INPUT +3. Continuously read the photoresistor value, which ranges from 1023 to 0, and map it to a range of 0 to 10 +4. Turn on only the LEDs up to the mapped value, and turn off the rest. + +## Success Criteria +The test is successful when: +1. Anode of the bar LED pins whose number is smaller than the mapped value receive HIGH signals, while greater pins receive LOW signals. + +## Notes for Implementation +- Photoresistor's analog value ranges from 1023 to 0. The smaller the analog value, the brighter the light. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level3/photoresistor_bar_led/description_no_pin.md b/arduino/level3/photoresistor_bar_led/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..daac043fd2aa17e616c6aab2bd750ddb8271c09d --- /dev/null +++ b/arduino/level3/photoresistor_bar_led/description_no_pin.md @@ -0,0 +1,30 @@ +# Photoresitor Bar LED + +## Project Description +This is an Arduino project that lights up the bar LED according to the brightness level. + +## Hardware Components +- Arduino Uno +- Bar graph LED +- 220Ω resistor * 10 +- Photoresistor + +## Circuit Description +Anode pins 1~10 of bar graph LED are connected to arduino digital pins. The cathode pins 1 through 10 of the bar graph LED are connected to ground through 220kΩ resistors. The AO pin of the photoresistor is connected to the arduino analog pin. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set bar graph led pin modes as OUTPUT +2. Set photoresistor signal pin as INPUT +3. Continuously read the photoresistor value, which ranges from 1023 to 0, and map it to a range of 0 to 10 +4. Turn on only the LEDs up to the mapped value, and turn off the rest. + +## Success Criteria +The test is successful when: +1. Anode of the bar LED pins whose number is smaller than the mapped value receive HIGH signals, while greater pins receive LOW signals. + +## Notes for Implementation +- Photoresistor's analog value ranges from 1023 to 0. The smaller the analog value, the brighter the light. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level3/photoresistor_bar_led/diagram.json b/arduino/level3/photoresistor_bar_led/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..59997669972c9732929fb6a7a23f1852d1e48542 --- /dev/null +++ b/arduino/level3/photoresistor_bar_led/diagram.json @@ -0,0 +1,417 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Control bar LED with photoresistor", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor1", + "top": -153.9, + "left": -187.9, + "rotate": 90, + "attrs": {} + }, + { + "type": "wokwi-led-bar-graph", + "id": "bar graph led1", + "top": -244.8, + "left": -24, + "attrs": { + "color": "lime" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -245.65, + "left": 28.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -236.05, + "left": 28.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -226.45, + "left": 28.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": -216.85, + "left": 28.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": -207.25, + "left": 28.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -197.65, + "left": 28.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": -188.05, + "left": 28.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": -178.45, + "left": 28.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor9", + "top": -168.85, + "left": 28.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor10", + "top": -159.25, + "left": 28.8, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "photoresistor1:AO", + "arduino uno1:A0", + "green", + [ + "v19.2", + "h211.2", + "v296.9", + "h83.9" + ] + ], + [ + "photoresistor1:GND", + "arduino uno1:GND.2", + "black", + [ + "v28.8", + "h-114.8", + "v316.4", + "h351.9" + ] + ], + [ + "photoresistor1:VCC", + "arduino uno1:5V", + "red", + [ + "v38.4", + "h-134.4", + "v307.2", + "h352" + ] + ], + [ + "resistor1:2", + "arduino uno1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "resistor2:2", + "arduino uno1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "resistor3:2", + "arduino uno1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "resistor4:2", + "arduino uno1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "resistor5:2", + "arduino uno1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "resistor6:2", + "arduino uno1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "resistor7:2", + "arduino uno1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "resistor8:2", + "arduino uno1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "resistor9:2", + "arduino uno1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "resistor10:2", + "arduino uno1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "arduino uno1:2", + "bar graph led1:A1", + "green", + [ + "v-105", + "h-294.1", + "v-144" + ] + ], + [ + "arduino uno1:3", + "bar graph led1:A2", + "green", + [ + "v-105", + "h-284.6", + "v-134.4" + ] + ], + [ + "arduino uno1:4", + "bar graph led1:A3", + "green", + [ + "v-105", + "h-275.1", + "v-124.8" + ] + ], + [ + "arduino uno1:5", + "bar graph led1:A4", + "green", + [ + "v-105", + "h-265.6", + "v-115.2" + ] + ], + [ + "arduino uno1:6", + "bar graph led1:A5", + "green", + [ + "v-105", + "h-256.1", + "v-105.59" + ] + ], + [ + "arduino uno1:7", + "bar graph led1:A6", + "green", + [ + "v-105", + "h-246.6", + "v-95.99" + ] + ], + [ + "arduino uno1:8", + "bar graph led1:A7", + "green", + [ + "v-105", + "h-230.6", + "v-86.39" + ] + ], + [ + "arduino uno1:9", + "bar graph led1:A8", + "green", + [ + "v-105", + "h-220.6", + "v-76.79" + ] + ], + [ + "arduino uno1:10", + "bar graph led1:A9", + "green", + [ + "v-105", + "h-211.1", + "v-67.19" + ] + ], + [ + "arduino uno1:11", + "bar graph led1:A10", + "green", + [ + "v-105", + "h-201.6", + "v-57.59" + ] + ], + [ + "resistor1:1", + "bar graph led1:C1", + "green", + [ + "v0" + ] + ], + [ + "resistor2:1", + "bar graph led1:C2", + "green", + [ + "v0" + ] + ], + [ + "resistor3:1", + "bar graph led1:C3", + "green", + [ + "v0" + ] + ], + [ + "resistor4:1", + "bar graph led1:C4", + "green", + [ + "v0" + ] + ], + [ + "resistor5:1", + "bar graph led1:C5", + "green", + [ + "v0" + ] + ], + [ + "resistor6:1", + "bar graph led1:C6", + "green", + [ + "v0" + ] + ], + [ + "resistor7:1", + "bar graph led1:C7", + "green", + [ + "v0" + ] + ], + [ + "resistor8:1", + "bar graph led1:C8", + "green", + [ + "v0" + ] + ], + [ + "resistor9:1", + "bar graph led1:C9", + "green", + [ + "v0" + ] + ], + [ + "resistor10:1", + "bar graph led1:C10", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/photoresistor_bar_led/diagram_breadboard.json b/arduino/level3/photoresistor_bar_led/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..12fc50f3c366347fb8e82e52ac00aa891d680c30 --- /dev/null +++ b/arduino/level3/photoresistor_bar_led/diagram_breadboard.json @@ -0,0 +1,664 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Control bar LED with photoresistor", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -377.4, + "left": -208.4, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -124.2, + "left": -10.2, + "attrs": {} + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor1", + "top": -365.1, + "left": -130.3, + "rotate": 90, + "attrs": { + "lux": "550" + } + }, + { + "type": "wokwi-led-bar-graph", + "id": "bar graph led1", + "top": -321.8, + "left": 129.8, + "rotate": 90, + "attrs": { + "color": "lime" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -254.95, + "left": 190.6, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -245.35, + "left": 181, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -235.75, + "left": 171.4, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": -216, + "left": 133.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": -216, + "left": 124.25, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -216, + "left": 114.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": -216, + "left": 105.05, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": -236.05, + "left": 67.2, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor9", + "top": -245.65, + "left": 57.6, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor10", + "top": -255.25, + "left": 48, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "bar graph led1:A1", + "breadboard1:40t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A2", + "breadboard1:39t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A3", + "breadboard1:38t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A4", + "breadboard1:37t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A5", + "breadboard1:36t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A6", + "breadboard1:35t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A7", + "breadboard1:34t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A8", + "breadboard1:33t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A9", + "breadboard1:32t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A10", + "breadboard1:31t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C1", + "breadboard1:40b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C2", + "breadboard1:39b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C3", + "breadboard1:38b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C4", + "breadboard1:37b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C5", + "breadboard1:36b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C6", + "breadboard1:35b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C7", + "breadboard1:34b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C8", + "breadboard1:33b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C9", + "breadboard1:32b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C10", + "breadboard1:31b.f", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:46b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:40b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:45b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:39b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:44b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:38b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor5:1", + "breadboard1:36b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor5:2", + "breadboard1:bn.29", + "", + [ + "$bb" + ] + ], + [ + "resistor4:1", + "breadboard1:37b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor4:2", + "breadboard1:bn.30", + "", + [ + "$bb" + ] + ], + [ + "resistor6:1", + "breadboard1:35b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor6:2", + "breadboard1:bn.28", + "", + [ + "$bb" + ] + ], + [ + "resistor7:1", + "breadboard1:34b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor7:2", + "breadboard1:bn.27", + "", + [ + "$bb" + ] + ], + [ + "resistor8:1", + "breadboard1:27b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor8:2", + "breadboard1:33b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor9:1", + "breadboard1:26b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor9:2", + "breadboard1:32b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor10:1", + "breadboard1:25b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor10:2", + "breadboard1:31b.g", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:27b.j", + "breadboard1:bn.21", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:26b.i", + "breadboard1:bn.20", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:25b.h", + "breadboard1:bn.19", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:44b.j", + "breadboard1:bn.35", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:45b.i", + "breadboard1:bn.36", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:46b.h", + "breadboard1:bn.37", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:40t.d", + "arduino uno1:2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:39t.d", + "arduino uno1:3", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:38t.d", + "arduino uno1:4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:37t.d", + "arduino uno1:5", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:36t.d", + "arduino uno1:6", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:35t.d", + "arduino uno1:7", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:34t.d", + "arduino uno1:8", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:33t.d", + "arduino uno1:9", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:32t.d", + "arduino uno1:10", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:31t.d", + "arduino uno1:11", + "green", + [ + "v0" + ] + ], + [ + "photoresistor1:VCC", + "breadboard1:17b.g", + "", + [ + "$bb" + ] + ], + [ + "photoresistor1:GND", + "breadboard1:16b.g", + "", + [ + "$bb" + ] + ], + [ + "photoresistor1:DO", + "breadboard1:15b.g", + "", + [ + "$bb" + ] + ], + [ + "photoresistor1:AO", + "breadboard1:14b.g", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:14b.h", + "arduino uno1:A0", + "green", + [ + "v345.6", + "h259.2" + ] + ], + [ + "breadboard1:16b.h", + "breadboard1:bn.12", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:17b.h", + "breadboard1:bp.13", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:bp.1", + "arduino uno1:5V", + "red", + [ + "v277.5", + "h316" + ] + ], + [ + "breadboard1:bn.1", + "arduino uno1:GND.2", + "black", + [ + "v267.5", + "h325.6" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/photoresistor_bar_led/platformio.ini b/arduino/level3/photoresistor_bar_led/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level3/photoresistor_bar_led/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level3/photoresistor_bar_led/scenario.yaml b/arduino/level3/photoresistor_bar_led/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ded6c59fb6eff14f0954860c45ad8ea19b1e5b1b --- /dev/null +++ b/arduino/level3/photoresistor_bar_led/scenario.yaml @@ -0,0 +1,74 @@ +author: Blind Author +description: Control bar LED with photoresistor +name: Photoresistor Bar LED +test-values: +- part-type: wokwi-photoresistor-sensor + attr-name: lux + value: '550' +steps: +- delay: 100ms +- wait-multi-pin: + timeout: 1000 + interval: 200 + pins: + - part-id: bar graph led1 + pin: A1 + value: 1 + - part-id: bar graph led1 + pin: A2 + value: 1 + - part-id: bar graph led1 + pin: A3 + value: 1 + - part-id: bar graph led1 + pin: A4 + value: 1 + - part-id: bar graph led1 + pin: A5 + value: 1 + - part-id: bar graph led1 + pin: A6 + value: 1 + - part-id: bar graph led1 + pin: A7 + value: 1 + - part-id: bar graph led1 + pin: A8 + value: 0 + - part-id: bar graph led1 + pin: A9 + value: 0 + - part-id: bar graph led1 + pin: A10 + value: 0 + - part-id: bar graph led1 + pin: C1 + value: 0 + - part-id: bar graph led1 + pin: C2 + value: 0 + - part-id: bar graph led1 + pin: C3 + value: 0 + - part-id: bar graph led1 + pin: C4 + value: 0 + - part-id: bar graph led1 + pin: C5 + value: 0 + - part-id: bar graph led1 + pin: C6 + value: 0 + - part-id: bar graph led1 + pin: C7 + value: 0 + - part-id: bar graph led1 + pin: C8 + value: 0 + - part-id: bar graph led1 + pin: C9 + value: 0 + - part-id: bar graph led1 + pin: C10 + value: 0 +version: 1.0 diff --git a/arduino/level3/photoresistor_bar_led/src/main.ino b/arduino/level3/photoresistor_bar_led/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..39d9c86d905cba401de2b02ee4d42aacb14c8a2a --- /dev/null +++ b/arduino/level3/photoresistor_bar_led/src/main.ino @@ -0,0 +1,32 @@ +/** + Control bar LED with photoresistor + 06 MAY 2025 by Blind Author +*/ + +const int analogPin = A0; +const int ledCount = 10; + +int ledPins[] = { + 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 +}; + +void setup() { + for (int thisLed = 0; thisLed < ledCount; thisLed++) { + pinMode(ledPins[thisLed], OUTPUT); + } + pinMode(analogPin, INPUT); +} + +void loop() { + int sensorReading = analogRead(analogPin); + int ledLevel = map(sensorReading, 1023, 0, 0, ledCount); + + for (int thisLed = 0; thisLed < ledCount; thisLed++) { + if (thisLed < ledLevel) { + digitalWrite(ledPins[thisLed], HIGH); + } + else { + digitalWrite(ledPins[thisLed], LOW); + } + } +} \ No newline at end of file diff --git a/arduino/level3/photoresistor_bar_led/wokwi.toml b/arduino/level3/photoresistor_bar_led/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level3/photoresistor_bar_led/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level3/potentiometer_bar_led/description.md b/arduino/level3/potentiometer_bar_led/description.md new file mode 100644 index 0000000000000000000000000000000000000000..1d0d431d948e2b729d7ce0dd548e2392d7189f3d --- /dev/null +++ b/arduino/level3/potentiometer_bar_led/description.md @@ -0,0 +1,33 @@ +# Potentiometer Bar LED + +## Project Description +This is a simple Arduino project that controls bar graph LED with a potentiometer. + +## Hardware Components +- Arduino Uno +- Bar graph LED +- 220Ω resistor * 10 +- Potentiometer + +## Circuit Description +Anode pins 1~10 of bar graph LED are connected to pin2, pin3, pin4, pin5, pin6, pin7, pin8, pin9, pin10, pin11, respectively. The cathode pins 1 through 10 of the bar graph LED are connected to GND pin gnd1 through 220kΩ resistors. The SIG pin of the potentiometer is connected to the a0, the GND pin is connected to gnd1, and the VCC pin is connected to 5v. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set pin2, pin3, pin4, pin5, pin6, pin7, pin8, pin9, pin10, pin11 pin mode as OUTPUT +2. Set potentiometer signal pin a0 as INPUT +3. Continuously read the potentiometer value, which ranges from 0 to 1023, and map it to a range of 0 to 10 +4. Turn on only the LEDs up to the mapped value, and turn off the rest. + +## Success Criteria +The test is successful when: +1. Anode of the bar LED pins whose number is smaller than the mapped value receive HIGH signals, while greater pins receive LOW signals. + +## Notes for Implementation +- Potentiometer value ranges from 0 to 1023. + +## Variants +This project may have different variants with the LED, potentiometer connected to different pins or using LEDs of different colors. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level3/potentiometer_bar_led/description_no_pin.md b/arduino/level3/potentiometer_bar_led/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..b3af5753bc8766a5096fc25263079ba5cbfcb53c --- /dev/null +++ b/arduino/level3/potentiometer_bar_led/description_no_pin.md @@ -0,0 +1,33 @@ +# Potentiometer Bar LED + +## Project Description +This is a simple Arduino project that controls bar graph LED with a potentiometer. + +## Hardware Components +- Arduino Uno +- Bar graph LED +- 220Ω resistor * 10 +- Potentiometer + +## Circuit Description +Anode pins 1~10 of bar graph LED are connected to arduino digital pins. The cathode pins 1 through 10 of the bar graph LED are connected to ground through 220kΩ resistors. The SIG pin of the potentiometer is connected to the arduino analog pin. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set bar graph led pin modes as OUTPUT +2. Set potentiometer signal pin as INPUT +3. Continuously read the potentiometer value, which ranges from 0 to 1023, and map it to a range of 0 to 10 +4. Turn on only the LEDs up to the mapped value, and turn off the rest. + +## Success Criteria +The test is successful when: +1. Anode of the bar LED pins whose number is smaller than the mapped value receive HIGH signals, while greater pins receive LOW signals. + +## Notes for Implementation +- Potentiometer value ranges from 0 to 1023. + +## Variants +This project may have different variants with the LED, potentiometer connected to different pins or using LEDs of different colors. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level3/potentiometer_bar_led/diagram.json b/arduino/level3/potentiometer_bar_led/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..df991846567739cb537af5907d0f186762a37413 --- /dev/null +++ b/arduino/level3/potentiometer_bar_led/diagram.json @@ -0,0 +1,436 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Control bar LED with potentiometer", + "config": { + "1_pin": 2, + "2_pin": 3, + "3_pin": 4, + "4_pin": 5, + "5_pin": 6, + "6_pin": 7, + "7_pin": 8, + "8_pin": 9, + "9_pin": 10, + "10_pin": 11, + "led_color": "lime", + "gnd_pin": "GND.1", + "potentiometer_sig_pin": "A0", + "vcc_pin": "5V" + }, + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 67.8, + "left": 517.8, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 109.85, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": 129.05, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 119.45, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-led-bar-graph", + "id": "bar graph led1", + "top": 110.4, + "left": 849.6, + "attrs": { + "color": "lime" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 138.65, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": 148.25, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": 157.85, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": 167.45, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": 177.05, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor9", + "top": 186.65, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor10", + "top": 196.25, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-potentiometer", + "id": "potentiometer1", + "top": 325.1, + "left": 662.2, + "attrs": {} + } + ], + "connections": [ + [ + "resistor1:2", + "bar graph led1:C1", + "green", + [ + "v0" + ] + ], + [ + "resistor3:2", + "bar graph led1:C2", + "green", + [ + "v0" + ] + ], + [ + "resistor2:2", + "bar graph led1:C3", + "green", + [ + "v0" + ] + ], + [ + "resistor4:2", + "bar graph led1:C4", + "green", + [ + "v0" + ] + ], + [ + "resistor5:2", + "bar graph led1:C5", + "green", + [ + "v0" + ] + ], + [ + "resistor6:2", + "bar graph led1:C6", + "green", + [ + "v0" + ] + ], + [ + "resistor7:2", + "bar graph led1:C7", + "green", + [ + "v0" + ] + ], + [ + "resistor8:2", + "bar graph led1:C8", + "green", + [ + "v0" + ] + ], + [ + "resistor9:2", + "bar graph led1:C9", + "green", + [ + "v0" + ] + ], + [ + "resistor10:2", + "bar graph led1:C10", + "green", + [ + "v0" + ] + ], + [ + "arduino uno1:GND.1", + "resistor10:1", + "black", + [ + "v-28.8", + "h365.1", + "v153.6" + ] + ], + [ + "arduino uno1:GND.1", + "resistor9:1", + "black", + [ + "v-28.8", + "h365.1", + "v144" + ] + ], + [ + "arduino uno1:GND.1", + "resistor8:1", + "black", + [ + "v-28.8", + "h365.1", + "v134.4" + ] + ], + [ + "arduino uno1:GND.1", + "resistor7:1", + "black", + [ + "v-28.8", + "h365.1", + "v124.8" + ] + ], + [ + "arduino uno1:GND.1", + "resistor6:1", + "black", + [ + "v-28.8", + "h365.1", + "v115.2" + ] + ], + [ + "arduino uno1:GND.1", + "resistor5:1", + "black", + [ + "v-28.8", + "h365.1", + "v105.6" + ] + ], + [ + "arduino uno1:GND.1", + "resistor4:1", + "black", + [ + "v-28.8", + "h365.1", + "v96" + ] + ], + [ + "arduino uno1:GND.1", + "resistor2:1", + "black", + [ + "v-28.8", + "h365.1", + "v86.4" + ] + ], + [ + "arduino uno1:GND.1", + "resistor3:1", + "black", + [ + "v-28.8", + "h365.1", + "v76.8" + ] + ], + [ + "arduino uno1:GND.1", + "resistor1:1", + "black", + [ + "v-28.8", + "h365.1", + "v67.2" + ] + ], + [ + "bar graph led1:A1", + "arduino uno1:2", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A2", + "arduino uno1:3", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A3", + "arduino uno1:4", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A4", + "arduino uno1:5", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A5", + "arduino uno1:6", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A6", + "arduino uno1:7", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A7", + "arduino uno1:8", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A8", + "arduino uno1:9", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A9", + "arduino uno1:10", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A10", + "arduino uno1:11", + "green", + [ + "h0" + ] + ], + [ + "potentiometer1:VCC", + "arduino uno1:5V", + "red", + [ + "v0" + ] + ], + [ + "potentiometer1:SIG", + "arduino uno1:A0", + "green", + [ + "v0" + ] + ], + [ + "potentiometer1:GND", + "arduino uno1:GND.1", + "black", + [ + "v0", + "h-201.6", + "v-345.6", + "h144" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/potentiometer_bar_led/diagram_breadboard.json b/arduino/level3/potentiometer_bar_led/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..6a95c882c818cfc20cf112bc117b6a9a02ad4ee5 --- /dev/null +++ b/arduino/level3/potentiometer_bar_led/diagram_breadboard.json @@ -0,0 +1,678 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Control bar LED with potentiometer", + "config": { + "1_pin": 2, + "2_pin": 3, + "3_pin": 4, + "4_pin": 5, + "5_pin": 6, + "6_pin": 7, + "7_pin": 8, + "8_pin": 9, + "9_pin": 10, + "10_pin": 11, + "led_color": "lime", + "gnd_pin": "GND.1", + "vcc_pin": "5V", + "potentiometer_sig_pin": "A0" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -156.6, + "left": 406, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 67.8, + "left": 623.4, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -34.45, + "left": 652.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-led-bar-graph", + "id": "bar graph led1", + "top": -101, + "left": 734.6, + "rotate": 90, + "attrs": { + "color": "lime" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -24.85, + "left": 662.4, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -15.25, + "left": 672, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 4.8, + "left": 709.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": -34.45, + "left": 796.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -24.85, + "left": 787.2, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": -15.25, + "left": 777.6, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": 4.8, + "left": 738.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor9", + "top": 4.8, + "left": 719.45, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor10", + "top": 4.8, + "left": 729.05, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-potentiometer", + "id": "potentiometer1", + "top": -106.9, + "left": 479.8, + "attrs": { + "value": "615" + } + } + ], + "connections": [ + [ + "breadboard1:43b.j", + "breadboard1:bn.35", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:44b.i", + "breadboard1:bn.36", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:45b.h", + "breadboard1:bn.37", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:26b.j", + "breadboard1:bn.21", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:25b.i", + "breadboard1:bn.20", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:24b.h", + "breadboard1:bn.19", + "green", + [ + "v0" + ] + ], + [ + "arduino uno1:GND.1", + "breadboard1:bn.24", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:30t.d", + "arduino uno1:11", + "green", + [ + "v-105.6", + "h48" + ] + ], + [ + "breadboard1:31t.d", + "arduino uno1:10", + "green", + [ + "v-115.2", + "h57.6" + ] + ], + [ + "breadboard1:32t.d", + "arduino uno1:9", + "green", + [ + "v-124.8", + "h57.6" + ] + ], + [ + "breadboard1:33t.d", + "arduino uno1:8", + "green", + [ + "v-134.4", + "h57.6" + ] + ], + [ + "breadboard1:34t.d", + "arduino uno1:7", + "green", + [ + "v-96", + "h57.6" + ] + ], + [ + "breadboard1:35t.d", + "arduino uno1:6", + "green", + [ + "v-105.6", + "h57.6" + ] + ], + [ + "breadboard1:36t.d", + "arduino uno1:5", + "green", + [ + "v-115.2", + "h67.2" + ] + ], + [ + "breadboard1:37t.d", + "arduino uno1:4", + "green", + [ + "v-86.4", + "h67.2" + ] + ], + [ + "breadboard1:38t.d", + "arduino uno1:3", + "green", + [ + "v-76.8", + "h67.2" + ] + ], + [ + "breadboard1:39t.d", + "arduino uno1:2", + "green", + [ + "v-96", + "h67.2" + ] + ], + [ + "resistor1:1", + "breadboard1:24b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:30b.g", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A1", + "breadboard1:39t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A2", + "breadboard1:38t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A3", + "breadboard1:37t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A4", + "breadboard1:36t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A5", + "breadboard1:35t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A6", + "breadboard1:34t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A7", + "breadboard1:33t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A8", + "breadboard1:32t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A9", + "breadboard1:31t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A10", + "breadboard1:30t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C1", + "breadboard1:39b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C2", + "breadboard1:38b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C3", + "breadboard1:37b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C4", + "breadboard1:36b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C5", + "breadboard1:35b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C6", + "breadboard1:34b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C7", + "breadboard1:33b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C8", + "breadboard1:32b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C9", + "breadboard1:31b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C10", + "breadboard1:30b.f", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:25b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:31b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:32b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:26b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor4:1", + "breadboard1:33b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor4:2", + "breadboard1:bn.26", + "", + [ + "$bb" + ] + ], + [ + "resistor5:1", + "breadboard1:39b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor5:2", + "breadboard1:45b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor6:1", + "breadboard1:38b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor6:2", + "breadboard1:44b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor7:1", + "breadboard1:37b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor7:2", + "breadboard1:43b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor8:1", + "breadboard1:36b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor8:2", + "breadboard1:bn.29", + "", + [ + "$bb" + ] + ], + [ + "resistor9:1", + "breadboard1:34b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor9:2", + "breadboard1:bn.27", + "", + [ + "$bb" + ] + ], + [ + "resistor10:1", + "breadboard1:35b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor10:2", + "breadboard1:bn.28", + "", + [ + "$bb" + ] + ], + [ + "potentiometer1:GND", + "breadboard1:9b.f", + "", + [ + "$bb" + ] + ], + [ + "potentiometer1:SIG", + "breadboard1:10b.f", + "", + [ + "$bb" + ] + ], + [ + "potentiometer1:VCC", + "breadboard1:11b.f", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:11b.h", + "breadboard1:bp.8", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:10b.h", + "arduino uno1:A0", + "green", + [ + "v307.2", + "h316.8" + ] + ], + [ + "breadboard1:9b.h", + "breadboard1:bn.6", + "green", + [ + "v0" + ] + ], + [ + "arduino uno1:5V", + "breadboard1:bp.9", + "red", + [ + "v76.7", + "h-236.2" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/potentiometer_bar_led/diagram_breadboard_shdf.json b/arduino/level3/potentiometer_bar_led/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..238d2356915e36380ff4e824dd3e3a4ee55bf9e7 --- /dev/null +++ b/arduino/level3/potentiometer_bar_led/diagram_breadboard_shdf.json @@ -0,0 +1,351 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "bargraph1", + "type": "bar graph led", + "properties": { + "color": "lime" + } + }, + { + "id": "r2", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r3", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r4", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r5", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r6", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r7", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r8", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r9", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r10", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "pot1", + "type": "potentiometer" + } + ], + "connections": [ + [ + "bb1.pin43b.j", + "bb1.bn.35" + ], + [ + "bb1.pin44b.i", + "bb1.bn.36" + ], + [ + "bb1.pin45b.h", + "bb1.bn.37" + ], + [ + "bb1.pin26b.j", + "bb1.bn.21" + ], + [ + "bb1.pin25b.i", + "bb1.bn.20" + ], + [ + "bb1.pin24b.h", + "bb1.bn.19" + ], + [ + "uno.gnd.1", + "bb1.bn.24" + ], + [ + "bb1.pin30t.d", + "uno.11" + ], + [ + "bb1.pin31t.d", + "uno.10" + ], + [ + "bb1.pin32t.d", + "uno.9" + ], + [ + "bb1.pin33t.d", + "uno.8" + ], + [ + "bb1.pin34t.d", + "uno.7" + ], + [ + "bb1.pin35t.d", + "uno.6" + ], + [ + "bb1.pin36t.d", + "uno.5" + ], + [ + "bb1.pin37t.d", + "uno.4" + ], + [ + "bb1.pin38t.d", + "uno.3" + ], + [ + "bb1.pin39t.d", + "uno.2" + ], + [ + "r1.1", + "bb1.pin24b.g" + ], + [ + "r1.2", + "bb1.pin30b.g" + ], + [ + "bargraph1.a1", + "bb1.pin39t.e" + ], + [ + "bargraph1.a2", + "bb1.pin38t.e" + ], + [ + "bargraph1.a3", + "bb1.pin37t.e" + ], + [ + "bargraph1.a4", + "bb1.pin36t.e" + ], + [ + "bargraph1.a5", + "bb1.pin35t.e" + ], + [ + "bargraph1.a6", + "bb1.pin34t.e" + ], + [ + "bargraph1.a7", + "bb1.pin33t.e" + ], + [ + "bargraph1.a8", + "bb1.pin32t.e" + ], + [ + "bargraph1.a9", + "bb1.pin31t.e" + ], + [ + "bargraph1.a10", + "bb1.pin30t.e" + ], + [ + "bargraph1.c1", + "bb1.pin39b.f" + ], + [ + "bargraph1.c2", + "bb1.pin38b.f" + ], + [ + "bargraph1.c3", + "bb1.pin37b.f" + ], + [ + "bargraph1.c4", + "bb1.pin36b.f" + ], + [ + "bargraph1.c5", + "bb1.pin35b.f" + ], + [ + "bargraph1.c6", + "bb1.pin34b.f" + ], + [ + "bargraph1.c7", + "bb1.pin33b.f" + ], + [ + "bargraph1.c8", + "bb1.pin32b.f" + ], + [ + "bargraph1.c9", + "bb1.pin31b.f" + ], + [ + "bargraph1.c10", + "bb1.pin30b.f" + ], + [ + "r2.1", + "bb1.pin25b.h" + ], + [ + "r2.2", + "bb1.pin31b.h" + ], + [ + "r3.1", + "bb1.pin32b.i" + ], + [ + "r3.2", + "bb1.pin26b.i" + ], + [ + "r4.1", + "bb1.pin33b.h" + ], + [ + "r4.2", + "bb1.bn.26" + ], + [ + "r5.1", + "bb1.pin39b.g" + ], + [ + "r5.2", + "bb1.pin45b.g" + ], + [ + "r6.1", + "bb1.pin38b.h" + ], + [ + "r6.2", + "bb1.pin44b.h" + ], + [ + "r7.1", + "bb1.pin37b.i" + ], + [ + "r7.2", + "bb1.pin43b.i" + ], + [ + "r8.1", + "bb1.pin36b.h" + ], + [ + "r8.2", + "bb1.bn.29" + ], + [ + "r9.1", + "bb1.pin34b.h" + ], + [ + "r9.2", + "bb1.bn.27" + ], + [ + "r10.1", + "bb1.pin35b.h" + ], + [ + "r10.2", + "bb1.bn.28" + ], + [ + "pot1.gnd", + "bb1.pin9b.f" + ], + [ + "pot1.sig", + "bb1.pin10b.f" + ], + [ + "pot1.vcc", + "bb1.pin11b.f" + ], + [ + "bb1.pin11b.h", + "bb1.bp.8" + ], + [ + "bb1.pin10b.h", + "uno.a0" + ], + [ + "bb1.pin9b.h", + "bb1.bn.6" + ], + [ + "uno.5v", + "bb1.bp.9" + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/potentiometer_bar_led/diagram_shdf.json b/arduino/level3/potentiometer_bar_led/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..7a074995cdffbbccb7bac08c2f0d4dd6475442db --- /dev/null +++ b/arduino/level3/potentiometer_bar_led/diagram_shdf.json @@ -0,0 +1,223 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "r1", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r2", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r3", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "bargraph1", + "type": "bar graph led", + "properties": { + "color": "lime" + } + }, + { + "id": "r4", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r5", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r6", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r7", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r8", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r9", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "r10", + "type": "resistor", + "properties": { + "value": "220 ohm" + } + }, + { + "id": "pot1", + "type": "potentiometer" + } + ], + "connections": [ + [ + "r1.2", + "bargraph1.c1" + ], + [ + "r3.2", + "bargraph1.c2" + ], + [ + "r2.2", + "bargraph1.c3" + ], + [ + "r4.2", + "bargraph1.c4" + ], + [ + "r5.2", + "bargraph1.c5" + ], + [ + "r6.2", + "bargraph1.c6" + ], + [ + "r7.2", + "bargraph1.c7" + ], + [ + "r8.2", + "bargraph1.c8" + ], + [ + "r9.2", + "bargraph1.c9" + ], + [ + "r10.2", + "bargraph1.c10" + ], + [ + "uno.gnd.1", + "r10.1" + ], + [ + "uno.gnd.1", + "r9.1" + ], + [ + "uno.gnd.1", + "r8.1" + ], + [ + "uno.gnd.1", + "r7.1" + ], + [ + "uno.gnd.1", + "r6.1" + ], + [ + "uno.gnd.1", + "r5.1" + ], + [ + "uno.gnd.1", + "r4.1" + ], + [ + "uno.gnd.1", + "r2.1" + ], + [ + "uno.gnd.1", + "r3.1" + ], + [ + "uno.gnd.1", + "r1.1" + ], + [ + "bargraph1.a1", + "uno.2" + ], + [ + "bargraph1.a2", + "uno.3" + ], + [ + "bargraph1.a3", + "uno.4" + ], + [ + "bargraph1.a4", + "uno.5" + ], + [ + "bargraph1.a5", + "uno.6" + ], + [ + "bargraph1.a6", + "uno.7" + ], + [ + "bargraph1.a7", + "uno.8" + ], + [ + "bargraph1.a8", + "uno.9" + ], + [ + "bargraph1.a9", + "uno.10" + ], + [ + "bargraph1.a10", + "uno.11" + ], + [ + "pot1.vcc", + "uno.5v" + ], + [ + "pot1.sig", + "uno.a0" + ], + [ + "pot1.gnd", + "uno.gnd.1" + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/potentiometer_bar_led/platformio.ini b/arduino/level3/potentiometer_bar_led/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level3/potentiometer_bar_led/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level3/potentiometer_bar_led/scenario.yaml b/arduino/level3/potentiometer_bar_led/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7c9498265c24e28e69929a4755e12815aab00e18 --- /dev/null +++ b/arduino/level3/potentiometer_bar_led/scenario.yaml @@ -0,0 +1,142 @@ +author: Blind Author +description: Control bar LED with potentiometer +name: Potentiometer bar LED +steps: +- delay: 100ms +- set-control: + control: position + part-id: potentiometer1 + value: 0.6 +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: bar graph led1 + pin: A1 + value: 1 + - part-id: bar graph led1 + pin: A2 + value: 1 + - part-id: bar graph led1 + pin: A3 + value: 1 + - part-id: bar graph led1 + pin: A4 + value: 1 + - part-id: bar graph led1 + pin: A5 + value: 1 + - part-id: bar graph led1 + pin: A6 + value: 1 + - part-id: bar graph led1 + pin: A7 + value: 0 + - part-id: bar graph led1 + pin: A8 + value: 0 + - part-id: bar graph led1 + pin: A9 + value: 0 + - part-id: bar graph led1 + pin: A10 + value: 0 + - part-id: bar graph led1 + pin: C1 + value: 0 + - part-id: bar graph led1 + pin: C2 + value: 0 + - part-id: bar graph led1 + pin: C3 + value: 0 + - part-id: bar graph led1 + pin: C4 + value: 0 + - part-id: bar graph led1 + pin: C5 + value: 0 + - part-id: bar graph led1 + pin: C6 + value: 0 + - part-id: bar graph led1 + pin: C7 + value: 0 + - part-id: bar graph led1 + pin: C8 + value: 0 + - part-id: bar graph led1 + pin: C9 + value: 0 + - part-id: bar graph led1 + pin: C10 + value: 0 +- set-control: + control: position + part-id: potentiometer1 + value: 0.3 +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: bar graph led1 + pin: A1 + value: 1 + - part-id: bar graph led1 + pin: A2 + value: 1 + - part-id: bar graph led1 + pin: A3 + value: 1 + - part-id: bar graph led1 + pin: A4 + value: 0 + - part-id: bar graph led1 + pin: A5 + value: 0 + - part-id: bar graph led1 + pin: A6 + value: 0 + - part-id: bar graph led1 + pin: A7 + value: 0 + - part-id: bar graph led1 + pin: A8 + value: 0 + - part-id: bar graph led1 + pin: A9 + value: 0 + - part-id: bar graph led1 + pin: A10 + value: 0 + - part-id: bar graph led1 + pin: C1 + value: 0 + - part-id: bar graph led1 + pin: C2 + value: 0 + - part-id: bar graph led1 + pin: C3 + value: 0 + - part-id: bar graph led1 + pin: C4 + value: 0 + - part-id: bar graph led1 + pin: C5 + value: 0 + - part-id: bar graph led1 + pin: C6 + value: 0 + - part-id: bar graph led1 + pin: C7 + value: 0 + - part-id: bar graph led1 + pin: C8 + value: 0 + - part-id: bar graph led1 + pin: C9 + value: 0 + - part-id: bar graph led1 + pin: C10 + value: 0 +version: 1.0 diff --git a/arduino/level3/potentiometer_bar_led/src/main.ino b/arduino/level3/potentiometer_bar_led/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..3a40d9930fc5e9c07219d1ecfb3dd05b15fc84ed --- /dev/null +++ b/arduino/level3/potentiometer_bar_led/src/main.ino @@ -0,0 +1,32 @@ +/** + Control bar LED with potentiometer + 10 APR 2025 by Blind Author +*/ + +const int analogPin = A0; +const int ledCount = 10; + +int ledPins[] = { + 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 +}; + +void setup() { + for (int thisLed = 0; thisLed < ledCount; thisLed++) { + pinMode(ledPins[thisLed], OUTPUT); + } + pinMode(analogPin, INPUT); +} + +void loop() { + int sensorReading = analogRead(analogPin); + int ledLevel = map(sensorReading, 0, 1023, 0, ledCount); + + for (int thisLed = 0; thisLed < ledCount; thisLed++) { + if (thisLed < ledLevel) { + digitalWrite(ledPins[thisLed], HIGH); + } + else { + digitalWrite(ledPins[thisLed], LOW); + } + } +} \ No newline at end of file diff --git a/arduino/level3/potentiometer_bar_led/wokwi.toml b/arduino/level3/potentiometer_bar_led/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level3/potentiometer_bar_led/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level3/potentiometer_servo_motor/description.md b/arduino/level3/potentiometer_servo_motor/description.md new file mode 100644 index 0000000000000000000000000000000000000000..d9d00e9d39d870cfe078ea4f3304aa487b4ce87b --- /dev/null +++ b/arduino/level3/potentiometer_servo_motor/description.md @@ -0,0 +1,31 @@ +# Potentiometer Servo Motor + +## Project Description +This is a simple Arduino project that controls servo motor with a potentiometer. + +## Hardware Components +- Arduino Uno +- Servo motor +- Potentiometer + +## Circuit Description +The SIG pin of the potentiometer is connected to the a0. The PWN pin of servo motor is connected to the pin9. GND pins are connected to gnd1, and VCC pins are connected to 5v. + +## Expected Behavior +When the Arduino powers up, it should: +1. Generate Servo object +2. Set potentiometer signal pin a0 as INPUT +3. Continuously read the potentiometer value, which ranges from 0 to 1023, and map it to a range of 0 to 180 +4. Write the mapped value to the servo motor +5. Continuously read the servo value and print it to the serial monitor + +## Success Criteria +The test is successful when: +1. The servo motor rotates correctly according to the mapped value from the potentiometer. + +## Notes for Implementation +- Potentiometer value ranges from 0 to 1023. +- Servo motor value ranges from 0 to 180. + +## Variants +This project may have different variants with the servo motor, potentiometer connected to different pins. \ No newline at end of file diff --git a/arduino/level3/potentiometer_servo_motor/description_no_pin.md b/arduino/level3/potentiometer_servo_motor/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..c95a1809bdccbb8313d2b1fb16c2d7066539b4b1 --- /dev/null +++ b/arduino/level3/potentiometer_servo_motor/description_no_pin.md @@ -0,0 +1,31 @@ +# Potentiometer Servo Motor + +## Project Description +This is a simple Arduino project that controls servo motor with a potentiometer. + +## Hardware Components +- Arduino Uno +- Servo motor +- Potentiometer + +## Circuit Description +The SIG pin of the potentiometer is connected to the arduino analog pin. The PWN pin of servo motor is connected to the arduino digital pin. + +## Expected Behavior +When the Arduino powers up, it should: +1. Generate Servo object +2. Set potentiometer signal pin a0 as INPUT +3. Continuously read the potentiometer value, which ranges from 0 to 1023, and map it to a range of 0 to 180 +4. Write the mapped value to the servo motor +5. Continuously read the servo value and print it to the serial monitor + +## Success Criteria +The test is successful when: +1. The servo motor rotates correctly according to the mapped value from the potentiometer. + +## Notes for Implementation +- Potentiometer value ranges from 0 to 1023. +- Servo motor value ranges from 0 to 180. + +## Variants +This project may have different variants with the servo motor, potentiometer connected to different pins. \ No newline at end of file diff --git a/arduino/level3/potentiometer_servo_motor/diagram.json b/arduino/level3/potentiometer_servo_motor/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..7d7ccbbdc622566680e3f7ccdd3493cb54c4b116 --- /dev/null +++ b/arduino/level3/potentiometer_servo_motor/diagram.json @@ -0,0 +1,102 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Control servo motor with potentiometer", + "config": { + "potentiometer_sig_pin": "A0", + "gnd_pin": "GND.1", + "vcc_pin": "5V", + "servo_pin": "9" + }, + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 200, + "left": 20, + "attrs": {} + }, + { + "type": "wokwi-servo", + "id": "servo motor1", + "top": 199.6, + "left": 403.2, + "attrs": { + "hornColor": "black" + } + }, + { + "type": "wokwi-potentiometer", + "id": "potentiometer1", + "top": 440.3, + "left": 153.4, + "attrs": {} + } + ], + "connections": [ + [ + "arduino uno1:9", + "servo motor1:PWM", + "orange", + [ + "v-20", + "*", + "h0", + "h-52" + ] + ], + [ + "arduino uno1:5V", + "servo motor1:V+", + "red", + [ + "v20", + "h0", + "*", + "h-20" + ] + ], + [ + "arduino uno1:GND.1", + "servo motor1:GND", + "black", + [ + "v-28", + "h240", + "*", + "h-20" + ] + ], + [ + "potentiometer1:VCC", + "arduino uno1:5V", + "red", + [ + "v19.2", + "h37.6", + "v-115.2", + "h-57.6" + ] + ], + [ + "potentiometer1:SIG", + "arduino uno1:A0", + "green", + [ + "v19.2", + "h66.8" + ] + ], + [ + "potentiometer1:GND", + "arduino uno1:GND.1", + "black", + [ + "v19.2", + "h-192", + "v-307.2" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/potentiometer_servo_motor/diagram_breadboard.json b/arduino/level3/potentiometer_servo_motor/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..9a0fc2c5c4065b7c7ec0827d66b42fef24c92329 --- /dev/null +++ b/arduino/level3/potentiometer_servo_motor/diagram_breadboard.json @@ -0,0 +1,160 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Control servo motor with potentiometer", + "config": { + "potentiometer_sig_pin": "A0", + "gnd_pin": "GND.1", + "vcc_pin": "5V", + "servo_pin": "9" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -51, + "left": -26, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 200, + "left": 20, + "attrs": {} + }, + { + "type": "wokwi-servo", + "id": "servo motor1", + "top": -97, + "left": 347.4, + "rotate": 270, + "attrs": { + "hornColor": "black" + } + }, + { + "type": "wokwi-potentiometer", + "id": "potentiometer1", + "top": 17.9, + "left": 191.8, + "attrs": {} + } + ], + "connections": [ + [ + "breadboard1:24b.i", + "breadboard1:bn.19", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:25b.i", + "arduino uno1:A0", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:26b.i", + "breadboard1:bp.21", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:bp.10", + "arduino uno1:5V", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:bn.13", + "arduino uno1:GND.1", + "green", + [ + "v0" + ] + ], + [ + "potentiometer1:GND", + "breadboard1:24b.h", + "", + [ + "$bb" + ] + ], + [ + "potentiometer1:SIG", + "breadboard1:25b.h", + "", + [ + "$bb" + ] + ], + [ + "potentiometer1:VCC", + "breadboard1:26b.h", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:45b.i", + "breadboard1:bn.36", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:46b.i", + "breadboard1:bp.37", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:47b.i", + "arduino uno1:9", + "green", + [ + "v115.2", + "h-259.2" + ] + ], + [ + "breadboard1:45b.h", + "servo motor1:GND", + "green", + [ + "v0" + ] + ], + [ + "servo motor1:V+", + "breadboard1:46b.h", + "green", + [ + "v0" + ] + ], + [ + "servo motor1:PWM", + "breadboard1:47b.h", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level3/potentiometer_servo_motor/diagram_breadboard_shdf.json b/arduino/level3/potentiometer_servo_motor/diagram_breadboard_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..f2772ccf3af270795d2df4c1c75c1b7e5b2dc28b --- /dev/null +++ b/arduino/level3/potentiometer_servo_motor/diagram_breadboard_shdf.json @@ -0,0 +1,78 @@ +{ + "components": [ + { + "id": "bb1", + "type": "breadboard" + }, + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "servo", + "type": "servo motor" + }, + { + "id": "pot1", + "type": "potentiometer" + } + ], + "connections": [ + [ + "bb1.pin24b.i", + "bb1.bn.19" + ], + [ + "bb1.pin25b.i", + "uno.a0" + ], + [ + "bb1.pin26b.i", + "bb1.bp.21" + ], + [ + "bb1.bp.10", + "uno.5v" + ], + [ + "bb1.bn.13", + "uno.gnd.1" + ], + [ + "pot1.gnd", + "bb1.pin24b.h" + ], + [ + "pot1.sig", + "bb1.pin25b.h" + ], + [ + "pot1.vcc", + "bb1.pin26b.h" + ], + [ + "bb1.pin45b.i", + "bb1.bn.36" + ], + [ + "bb1.pin46b.i", + "bb1.bp.37" + ], + [ + "bb1.pin47b.i", + "uno.9" + ], + [ + "bb1.pin45b.h", + "servo.gnd" + ], + [ + "servo.v+", + "bb1.pin46b.h" + ], + [ + "servo.pwm", + "bb1.pin47b.h" + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/potentiometer_servo_motor/diagram_shdf.json b/arduino/level3/potentiometer_servo_motor/diagram_shdf.json new file mode 100644 index 0000000000000000000000000000000000000000..acf1dd5e4be2d9e01436f6100d3583e7a96f165a --- /dev/null +++ b/arduino/level3/potentiometer_servo_motor/diagram_shdf.json @@ -0,0 +1,42 @@ +{ + "components": [ + { + "id": "uno", + "type": "arduino uno" + }, + { + "id": "servo", + "type": "servo motor" + }, + { + "id": "pot1", + "type": "potentiometer" + } + ], + "connections": [ + [ + "uno.9", + "servo.pwm" + ], + [ + "uno.5v", + "servo.v+" + ], + [ + "uno.gnd.1", + "servo.gnd" + ], + [ + "pot1.vcc", + "uno.5v" + ], + [ + "pot1.sig", + "uno.a0" + ], + [ + "pot1.gnd", + "uno.gnd.1" + ] + ] +} \ No newline at end of file diff --git a/arduino/level3/potentiometer_servo_motor/platformio.ini b/arduino/level3/potentiometer_servo_motor/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..2033d8801bf6e9e5c685f82885d2aa139c33b31f --- /dev/null +++ b/arduino/level3/potentiometer_servo_motor/platformio.ini @@ -0,0 +1,21 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Servo + Arduino \ No newline at end of file diff --git a/arduino/level3/potentiometer_servo_motor/scenario.yaml b/arduino/level3/potentiometer_servo_motor/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1ea26c18cc68344bd618619c5cf0c9bb3927c05b --- /dev/null +++ b/arduino/level3/potentiometer_servo_motor/scenario.yaml @@ -0,0 +1,26 @@ +author: Blind Author +description: Control a servo motor with potentiometer +name: Potentiometer Servo motor control +steps: +- delay: 100ms +- set-control: + control: position + part-id: potentiometer1 + value: 0.0 +- wait-serial: '0' +- set-control: + control: position + part-id: potentiometer1 + value: 0.3 +- wait-serial: '54' +- set-control: + control: position + part-id: potentiometer1 + value: 0.8 +- wait-serial: '144' +- set-control: + control: position + part-id: potentiometer1 + value: 1.0 +- wait-serial: '180' +version: 1.0 diff --git a/arduino/level3/potentiometer_servo_motor/src/main.ino b/arduino/level3/potentiometer_servo_motor/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..5d99b5ce3df4a2d10d7cab2cd50edd09ad66040d --- /dev/null +++ b/arduino/level3/potentiometer_servo_motor/src/main.ino @@ -0,0 +1,26 @@ +/* + Control servo motor with potentiometer + 11 APR 2025 by Blind Author +*/ + +#include + +Servo myservo; + +const int POT_PIN = A0; +const int SERVO_PIN = 9; + +void setup() { + Serial.begin(9600); + myservo.attach(SERVO_PIN); + pinMode(POT_PIN, INPUT); +} + +void loop() { + int pot = analogRead(POT_PIN); + myservo.write(map(pot, 0, 1023, 0, 180)); + + Serial.println(myservo.read()); + delay(100); +} + diff --git a/arduino/level3/potentiometer_servo_motor/wokwi.toml b/arduino/level3/potentiometer_servo_motor/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level3/potentiometer_servo_motor/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level4/alarm/description.md b/arduino/level4/alarm/description.md new file mode 100644 index 0000000000000000000000000000000000000000..9d98d3990fdaec41813d7e3c61ce652935f2f564 --- /dev/null +++ b/arduino/level4/alarm/description.md @@ -0,0 +1,28 @@ +# Alarm + +## Project Description +This is an Arduino project that triggers the buzzer when the specified time is reached. + +## Hardware Components +- Arduino Uno +- Piezoelectric Buzzer +- RTC module + +## Circuit Description +The RTC module and piezo buzzer is connected to the Arduino. For RTC module, the VCC pin is connected to 5V, the GND pin to gnd2, the SDA pin to A4, and the SCL pin to A5. For piezo buzzer, the negative pin is connected to gnd2, and the positive pin is connected to the arduino pin8. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set the buzzer pin mode as OUTPUT +2. Initialize the RTC module, and check if it can begin +3. Continuously read the current time with RTC module +4. Tone the buzzer if the current time is on or after '2024-11-24T04:49:00' + +## Success Criteria +The test is successful when: +1. Buzzer plays tone only when the current time is on or after the specified time. + +## Notes for Implementation +- Specified time is "2024-11-24T04:49:00". +- Use RTClib to generate RTC_DS1307 object and read the value. +- RTC module has I2C interface. diff --git a/arduino/level4/alarm/description_no_pin.md b/arduino/level4/alarm/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..96c3d7a320d6baa1f602d975ac2fdd314939ce91 --- /dev/null +++ b/arduino/level4/alarm/description_no_pin.md @@ -0,0 +1,28 @@ +# Alarm + +## Project Description +This is an Arduino project that triggers the buzzer when the specified time is reached. + +## Hardware Components +- Arduino Uno +- Piezoelectric Buzzer +- RTC module + +## Circuit Description +The RTC module and piezo buzzer is connected to the Arduino. RTC module follows the standard wiring conventions defined by the I2C protocol. For piezo buzzer, the positive pin is connected to the arduino digital pin. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set the buzzer pin mode as OUTPUT +2. Initialize the RTC module, and check if it can begin +3. Continuously read the current time with RTC module +4. Tone the buzzer if the current time is on or after '2024-11-24T04:49:00' + +## Success Criteria +The test is successful when: +1. Buzzer plays tone only when the current time is on or after the specified time. + +## Notes for Implementation +- Specified time is "2024-11-24T04:49:00". +- Use RTClib to generate RTC_DS1307 object and read the value. +- RTC module has I2C interface. diff --git a/arduino/level4/alarm/diagram.json b/arduino/level4/alarm/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..083b9ffa43812438fb078cc2f4131d515fef6a7d --- /dev/null +++ b/arduino/level4/alarm/diagram.json @@ -0,0 +1,85 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Trigger the buzzer when the specified time is reached", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-ds1307", + "id": "rtc module1", + "top": 234.6, + "left": 268.9, + "attrs": { + "initTime": "2024-11-24T04:48:55" + } + }, + { + "type": "wokwi-buzzer", + "id": "piezoelectric buzzer1", + "top": -132, + "left": 232.2, + "attrs": { + "volume": "0.1" + } + } + ], + "connections": [ + [ + "rtc module1:SCL", + "arduino uno1:A5", + "green", + [ + "h0" + ] + ], + [ + "rtc module1:SDA", + "arduino uno1:A4", + "green", + [ + "h0" + ] + ], + [ + "rtc module1:5V", + "arduino uno1:5V", + "red", + [ + "h0" + ] + ], + [ + "rtc module1:GND", + "arduino uno1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "piezoelectric buzzer1:1", + "arduino uno1:GND.2", + "black", + [ + "v192", + "h-96" + ] + ], + [ + "piezoelectric buzzer1:2", + "arduino uno1:8", + "green", + [ + "v28.8", + "h-38.8" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level4/alarm/diagram_breadboard.json b/arduino/level4/alarm/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..ce3a241683fb965ecff584c43a6a1226d9f99612 --- /dev/null +++ b/arduino/level4/alarm/diagram_breadboard.json @@ -0,0 +1,152 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Trigger the buzzer when the specified time is reached", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -233.4, + "left": 2.8, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 29.4, + "left": 181.8, + "attrs": {} + }, + { + "type": "wokwi-ds1307", + "id": "rtc module1", + "top": -196.7, + "left": 371.6, + "rotate": 270, + "attrs": { + "initTime": "2024-11-24T04:48:55" + } + }, + { + "type": "wokwi-buzzer", + "id": "piezoelectric buzzer1", + "top": -180, + "left": 232.2, + "attrs": { + "volume": "0.1" + } + } + ], + "connections": [ + [ + "piezoelectric buzzer1:1", + "breadboard1:25b.h", + "", + [ + "$bb" + ] + ], + [ + "piezoelectric buzzer1:2", + "breadboard1:26b.h", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:GND", + "breadboard1:39b.f", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:5V", + "breadboard1:40b.f", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:SDA", + "breadboard1:41b.f", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:SCL", + "breadboard1:42b.f", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:SQW", + "breadboard1:43b.f", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:25b.i", + "breadboard1:bn.20", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:26b.i", + "arduino uno1:8", + "green", + [ + "v96", + "h86.4" + ] + ], + [ + "breadboard1:39b.h", + "breadboard1:bn.31", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:40b.h", + "breadboard1:bp.32", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:41b.h", + "arduino uno1:A4", + "green", + [ + "v115.2", + "h57.6", + "v230.4", + "h-48" + ] + ], + [ + "breadboard1:42b.h", + "arduino uno1:A5", + "green", + [ + "v307.2", + "h9.6" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level4/alarm/platformio.ini b/arduino/level4/alarm/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..df4b80305bbe895d07c0f1c0e74b60a1d2862746 --- /dev/null +++ b/arduino/level4/alarm/platformio.ini @@ -0,0 +1,21 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + RTClib \ No newline at end of file diff --git a/arduino/level4/alarm/scenario.yaml b/arduino/level4/alarm/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..feff1e5a6f623346ca8ebdd30c8a4273cde92560 --- /dev/null +++ b/arduino/level4/alarm/scenario.yaml @@ -0,0 +1,21 @@ +author: Blind Author +description: Trigger the buzzer when the specified time is reached +name: Alarm +test-values: +- part-type: wokwi-ds1307 + attr-name: initTime + value: '2024-11-24T04:48:55' +steps: +- delay: 100ms +- expect-pin: + part-id: piezoelectric buzzer1 + pin: 2 + value: 0 +- delay: 4000ms +- wait-pin: + timeout: 2000 + interval: 10 + part-id: piezoelectric buzzer1 + pin: 2 + value: 1 +version: 1.0 diff --git a/arduino/level4/alarm/src/main.ino b/arduino/level4/alarm/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..9903565ef3bec2acb409b35a739c7f16ab72be24 --- /dev/null +++ b/arduino/level4/alarm/src/main.ino @@ -0,0 +1,30 @@ +/** + Trigger the buzzer when the specified time is reached + 06 MAY 2025 by Blind Author +*/ + +#define BUZZER_PIN 8 +#include "RTClib.h" + +RTC_DS1307 rtc; + +DateTime targetTime(2024, 11, 24, 04, 49, 0); + +void setup() { + pinMode(BUZZER_PIN, OUTPUT); + if (! rtc.begin()) { + Serial.println("Couldn't find RTC"); + Serial.flush(); + abort(); + } +} + +void loop() { + DateTime now = rtc.now(); + + if (now >= targetTime) { + tone(BUZZER_PIN, 262); + } else { + noTone(BUZZER_PIN); + } +} diff --git a/arduino/level4/alarm/wokwi.toml b/arduino/level4/alarm/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level4/alarm/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level4/binary_led/description.md b/arduino/level4/binary_led/description.md new file mode 100644 index 0000000000000000000000000000000000000000..7ae29cadac8eba3d052c2d55d564ab2bb1f83725 --- /dev/null +++ b/arduino/level4/binary_led/description.md @@ -0,0 +1,28 @@ +# Binary LED + +## Project Description +This is an arduino project that uses 5 LEDs to display the binary form of a number received over serial. + +## Hardware Components +- Arduino Uno +- 220Ω resistor * 5 +- LED * 5 + +## Circuit Description +Five LEDs are connected to Arduino Uno. LED 1 to 5 are connected to arduino pin2 to pin6 through 220Ω resistor, respectively. Cathode pin of each LEDs are connected to gnd2. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set pin2, pin3, pin4, pin5, pin6 pin mode as OUTPUT +3. Continuously read the serial monitor, which ranges from 0 to 31 +4. With LED1 as the LSB and LED5 as the MSB, light up the LEDs that represent 1s in the binary form of the input number + +## Success Criteria +The test is successful when: +1. When a number is entered via serial input, LEDs corresponding to the bits set to 1 in its binary representation are turned on. + +## Notes for Implementation +- Serial input ranges from 0 to 31. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level4/binary_led/description_no_pin.md b/arduino/level4/binary_led/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..62bc019520607ddb346561132c9a6113d1c16bda --- /dev/null +++ b/arduino/level4/binary_led/description_no_pin.md @@ -0,0 +1,28 @@ +# Binary LED + +## Project Description +This is an arduino project that uses 5 LEDs to display the binary form of a number received over serial. + +## Hardware Components +- Arduino Uno +- 220Ω resistor * 5 +- LED * 5 + +## Circuit Description +Five LEDs are connected to Arduino Uno. LED 1 to 5 are connected to arduino digital pins through 220Ω resistor. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set led pin modes as OUTPUT +3. Continuously read the serial monitor, which ranges from 0 to 31 +4. With LED1 as the LSB and LED5 as the MSB, light up the LEDs that represent 1s in the binary form of the input number + +## Success Criteria +The test is successful when: +1. When a number is entered via serial input, LEDs corresponding to the bits set to 1 in its binary representation are turned on. + +## Notes for Implementation +- Serial input ranges from 0 to 31. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level4/binary_led/diagram.json b/arduino/level4/binary_led/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..26e1c4af42fcb78d505d64e353bc1cdedc847731 --- /dev/null +++ b/arduino/level4/binary_led/diagram.json @@ -0,0 +1,249 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Use 5 LEDs to display the binary form of a number received over serial", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-led", + "id": "led1", + "top": -166.8, + "left": 243.8, + "attrs": { + "color": "red", + "flip": "" + } + }, + { + "type": "wokwi-led", + "id": "led2", + "top": -166.8, + "left": 215, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-led", + "id": "led3", + "top": -166.8, + "left": 186.2, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-led", + "id": "led4", + "top": -166.8, + "left": 147.8, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-led", + "id": "led5", + "top": -166.8, + "left": 119, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -91.2, + "left": 239.45, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -91.2, + "left": 210.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -91.2, + "left": 181.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": -91.2, + "left": 153.05, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": -91.2, + "left": 124.25, + "rotate": 90, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "led1:A", + "resistor1:1", + "green", + [ + "v0" + ] + ], + [ + "resistor1:2", + "arduino uno1:2", + "green", + [ + "h0", + "v46.8", + "h-38.4" + ] + ], + [ + "led2:C", + "arduino uno1:GND.2", + "black", + [ + "v57.6", + "h-191.6", + "v182.4", + "h131.1" + ] + ], + [ + "led3:C", + "arduino uno1:GND.2", + "black", + [ + "v57.6", + "h-162.8", + "v258.7" + ] + ], + [ + "led4:C", + "arduino uno1:GND.2", + "black", + [ + "v57.6", + "h-124.4", + "v182.4", + "h131.1" + ] + ], + [ + "led5:C", + "arduino uno1:GND.2", + "black", + [ + "v57.6", + "h-95.6", + "v182.4", + "h131.1" + ] + ], + [ + "led1:C", + "arduino uno1:GND.2", + "black", + [ + "v57.6", + "h-220.4", + "v182.4", + "h131.1" + ] + ], + [ + "led2:A", + "resistor2:1", + "green", + [ + "v0" + ] + ], + [ + "resistor2:2", + "arduino uno1:3", + "green", + [ + "h0" + ] + ], + [ + "led3:A", + "resistor3:1", + "green", + [ + "v0" + ] + ], + [ + "resistor3:2", + "arduino uno1:4", + "green", + [ + "h0" + ] + ], + [ + "led4:A", + "resistor4:1", + "green", + [ + "v0" + ] + ], + [ + "resistor4:2", + "arduino uno1:5", + "green", + [ + "h0" + ] + ], + [ + "resistor5:1", + "led5:A", + "green", + [ + "h0" + ] + ], + [ + "resistor5:2", + "arduino uno1:6", + "green", + [ + "h0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level4/binary_led/diagram_breadboard.json b/arduino/level4/binary_led/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..b5c188112f79f11965da5e34c1948d0b4105e0e4 --- /dev/null +++ b/arduino/level4/binary_led/diagram_breadboard.json @@ -0,0 +1,373 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Use 5 LEDs to display the binary form of a number received over serial", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -291, + "left": 2.8, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-led", + "id": "led1", + "top": -272.4, + "left": 215, + "attrs": { + "color": "red", + "flip": "" + } + }, + { + "type": "wokwi-led", + "id": "led2", + "top": -272.4, + "left": 176.6, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-led", + "id": "led3", + "top": -272.4, + "left": 138.2, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-led", + "id": "led4", + "top": -272.4, + "left": 99.8, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-led", + "id": "led5", + "top": -272.4, + "left": 61.4, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -187.2, + "left": 210.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -187.2, + "left": 172.25, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -187.2, + "left": 133.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": -187.2, + "left": 95.45, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": -187.2, + "left": 57.05, + "rotate": 90, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "led5:A", + "breadboard1:7t.b", + "", + [ + "$bb" + ] + ], + [ + "led5:C", + "breadboard1:6t.b", + "", + [ + "$bb" + ] + ], + [ + "led4:A", + "breadboard1:11t.b", + "", + [ + "$bb" + ] + ], + [ + "led4:C", + "breadboard1:10t.b", + "", + [ + "$bb" + ] + ], + [ + "led3:A", + "breadboard1:15t.b", + "", + [ + "$bb" + ] + ], + [ + "led3:C", + "breadboard1:14t.b", + "", + [ + "$bb" + ] + ], + [ + "led2:A", + "breadboard1:19t.b", + "", + [ + "$bb" + ] + ], + [ + "led2:C", + "breadboard1:18t.b", + "", + [ + "$bb" + ] + ], + [ + "led1:A", + "breadboard1:23t.b", + "", + [ + "$bb" + ] + ], + [ + "led1:C", + "breadboard1:22t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor5:1", + "breadboard1:7t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor5:2", + "breadboard1:7b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor4:1", + "breadboard1:11t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor4:2", + "breadboard1:11b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:15t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:15b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:19t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:19b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:23t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:23b.h", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:6t.d", + "breadboard1:bn.4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:10t.d", + "breadboard1:bn.7", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:14t.d", + "breadboard1:bn.11", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:18t.d", + "breadboard1:bn.14", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:22t.d", + "breadboard1:bn.17", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:23b.j", + "arduino uno1:2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:19b.j", + "arduino uno1:3", + "green", + [ + "v115.2", + "h28.8" + ] + ], + [ + "breadboard1:15b.j", + "arduino uno1:4", + "green", + [ + "v124.8", + "h57.6" + ] + ], + [ + "breadboard1:11b.j", + "arduino uno1:5", + "green", + [ + "v105.6", + "h76.8" + ] + ], + [ + "breadboard1:7b.j", + "arduino uno1:6", + "green", + [ + "v115.2", + "h105.6" + ] + ], + [ + "breadboard1:bn.1", + "arduino uno1:GND.2", + "black", + [ + "v267.5", + "h124" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level4/binary_led/platformio.ini b/arduino/level4/binary_led/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level4/binary_led/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level4/binary_led/scenario.yaml b/arduino/level4/binary_led/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..687a8585f97ed8c984025d258c6d50d409691c4b --- /dev/null +++ b/arduino/level4/binary_led/scenario.yaml @@ -0,0 +1,109 @@ +author: Blind Author +description: Use 5 LEDs to display the binary form of a number received over serial +name: Binary LED +steps: +- delay: 100ms +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: led1 + pin: C + value: 0 + - part-id: led2 + pin: C + value: 0 + - part-id: led3 + pin: C + value: 0 + - part-id: led4 + pin: C + value: 0 + - part-id: led5 + pin: C + value: 0 +- write-serial: '1' +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: led1 + pin: A + value: 1 + - part-id: led2 + pin: A + value: 0 + - part-id: led3 + pin: A + value: 0 + - part-id: led4 + pin: A + value: 0 + - part-id: led5 + pin: A + value: 0 +- write-serial: '7' +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: led1 + pin: A + value: 1 + - part-id: led2 + pin: A + value: 1 + - part-id: led3 + pin: A + value: 1 + - part-id: led4 + pin: A + value: 0 + - part-id: led5 + pin: A + value: 0 +- write-serial: '31' +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: led1 + pin: A + value: 1 + - part-id: led2 + pin: A + value: 1 + - part-id: led3 + pin: A + value: 1 + - part-id: led4 + pin: A + value: 1 + - part-id: led5 + pin: A + value: 1 +- write-serial: '14' +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: led1 + pin: A + value: 0 + - part-id: led2 + pin: A + value: 1 + - part-id: led3 + pin: A + value: 1 + - part-id: led4 + pin: A + value: 1 + - part-id: led5 + pin: A + value: 0 +version: 1.0 diff --git a/arduino/level4/binary_led/src/main.ino b/arduino/level4/binary_led/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..b042f67f7c1f1bafa86c84076ce0d56020c2f64b --- /dev/null +++ b/arduino/level4/binary_led/src/main.ino @@ -0,0 +1,36 @@ +/** + Use 5 LEDs to display the binary form of a number received over serial + 09 MAY 2025 by Blind Author +*/ + +const int ledPins[5] = {2, 3, 4, 5, 6}; + +void setup() { + Serial.begin(9600); + for (int i = 0; i < 5; i++) { + pinMode(ledPins[i], OUTPUT); + } +} + +void loop() { + if (Serial.available() > 0) { + int number = Serial.parseInt(); + + while (Serial.available()) { + Serial.read(); + } + + for (int i = 0; i < 5; i++) { + int bitValue = (number >> i) & 1; + digitalWrite(ledPins[i], bitValue); + } + + Serial.print("Binary of "); + Serial.print(number); + Serial.print(" is: "); + for (int i = 4; i >= 0; i--) { + Serial.print((number >> i) & 1); + } + Serial.println(); + } +} diff --git a/arduino/level4/binary_led/wokwi.toml b/arduino/level4/binary_led/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level4/binary_led/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level4/calendar_display/description.md b/arduino/level4/calendar_display/description.md new file mode 100644 index 0000000000000000000000000000000000000000..6eaeebcee41e565a6343ace615d1622b359fd905 --- /dev/null +++ b/arduino/level4/calendar_display/description.md @@ -0,0 +1,34 @@ +# Calendar Display + +## Project Description +This is a simple Arduino project that uses an RTC module to display the current date and day of the week on ili9341 LCD, and navigate days with buttons. + +## Hardware Components +- Arduino Uno +- RTC module ds1307 +- Ili9341 LCD Display +- Push Button * 2 +- 10kΩ resistor * 2 + +## Circuit Description +RTC module, ili9341 LCD display, two push buttons are connected to arduino uno. For LCD display, VCC and GND are connected to arduino gnd2 and 5v. RST, D/C, CS, MOSI, MISO, SCK pin of LCD display is connected to arduino pin 8 to 13, respectively. For RTC module, SDA pin and SCL pin are connected to A4 and A5, and 5V and GND are connected to arduino 5v and gnd2. Button 1 is connected to arduino pin 3, and button 2 is connected to pin 2. When the button is not pressed, it is connected to gnd2 by 10kΩ resistor. When the button is pressed, it is connected to arduino 5v. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize the RTC module and check if it can begin +2. Set text size as 3, and text color to white. +3. Continuously read the current time, and show YYYY-MM-DD to (10, 30) position. +4. Also show days of the week to (10, 80) position. + +## Success Criteria +The test is successful when: +1. The correct date is displayed on the screen. +2. When a button is pressed, the displayed date changes correctly. + +## Notes for Implementation +- Day of the week is one of the "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". +- Button 1 corresponds to the previous date, and Button 2 to the next date. +- Use , , "RTClib.h" libraries. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level4/calendar_display/description_no_pin.md b/arduino/level4/calendar_display/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..c6e4b6ed023fb56864571343314c3c36d1c8ee9d --- /dev/null +++ b/arduino/level4/calendar_display/description_no_pin.md @@ -0,0 +1,34 @@ +# Calendar Display + +## Project Description +This is a simple Arduino project that uses an RTC module to display the current date and day of the week on ili9341 LCD, and navigate days with buttons. + +## Hardware Components +- Arduino Uno +- RTC module +- Ili9341 LCD Display +- Push Button * 2 +- 10kΩ resistor * 2 + +## Circuit Description +RTC module, ili9341 LCD display, two push buttons are connected to arduino uno. For LCD display, RST, D/C, CS, MOSI, MISO, SCK pin of LCD display is connected to arduino digital pins. RTC module follows the standard wiring conventions defined by the I2C protocol. Button 1 and button 2 are connected to arduino digital pins. When the button is not pressed, it is connected to ground by 10kΩ resistor. Buttons use a pull-down resistor configuration. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize the RTC module and check if it can begin +2. Set text size as 3, and text color to white. +3. Continuously read the current time, and show YYYY-MM-DD to (10, 30) position. +4. Also show days of the week to (10, 80) position. + +## Success Criteria +The test is successful when: +1. The correct date is displayed on the screen. +2. When a button is pressed, the displayed date changes correctly. + +## Notes for Implementation +- Day of the week is one of the "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". +- Button 1 corresponds to the previous date, and Button 2 to the next date. +- Use , , "RTClib.h" libraries. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level4/calendar_display/diagram.json b/arduino/level4/calendar_display/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..389b9da5ba7f82d4fc9bce8b109683edb72384d8 --- /dev/null +++ b/arduino/level4/calendar_display/diagram.json @@ -0,0 +1,253 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Using an RTC, display the current date and day of the week on ili9341 LCD, and navigate days with buttons", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-ili9341", + "id": "ili9341 lcd display1", + "top": -344.8, + "left": 66.9, + "attrs": {} + }, + { + "type": "wokwi-ds1307", + "id": "rtc module1", + "top": 234.6, + "left": 201.7, + "attrs": { + "initTime": "2025-05-10T02:04:00" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -205, + "left": -38.4, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button2", + "top": -205, + "left": 288, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -129.6, + "left": -77.35, + "rotate": 90, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -129.6, + "left": 335.45, + "rotate": 90, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "rtc module1:GND", + "arduino uno1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "rtc module1:5V", + "arduino uno1:5V", + "red", + [ + "h0" + ] + ], + [ + "rtc module1:SDA", + "arduino uno1:A4", + "green", + [ + "h0" + ] + ], + [ + "rtc module1:SCL", + "arduino uno1:A5", + "green", + [ + "h0" + ] + ], + [ + "push button1:2.l", + "resistor1:1", + "green", + [ + "h0" + ] + ], + [ + "push button2:2.r", + "resistor2:1", + "green", + [ + "h0" + ] + ], + [ + "resistor1:2", + "arduino uno1:GND.2", + "black", + [ + "h0", + "v344.4", + "h201.6" + ] + ], + [ + "resistor2:2", + "arduino uno1:GND.2", + "black", + [ + "h0", + "v315.6", + "h-211.2" + ] + ], + [ + "push button1:2.r", + "arduino uno1:3", + "green", + [ + "h19.4", + "v153.8", + "h153.6" + ] + ], + [ + "push button2:2.l", + "arduino uno1:2", + "green", + [ + "h-28.8", + "v153.8", + "h-48" + ] + ], + [ + "ili9341 lcd display1:VCC", + "arduino uno1:5V", + "red", + [ + "v28.8", + "h-172.8", + "v288", + "h201.6" + ] + ], + [ + "ili9341 lcd display1:GND", + "arduino uno1:GND.2", + "black", + [ + "v48", + "h-172.8", + "v230.4", + "h201.6" + ] + ], + [ + "ili9341 lcd display1:CS", + "arduino uno1:10", + "orange", + [ + "v0" + ] + ], + [ + "ili9341 lcd display1:RST", + "arduino uno1:8", + "green", + [ + "v28.8", + "h9.6" + ] + ], + [ + "ili9341 lcd display1:D/C", + "arduino uno1:9", + "green", + [ + "v0" + ] + ], + [ + "ili9341 lcd display1:MOSI", + "arduino uno1:11", + "green", + [ + "v0" + ] + ], + [ + "ili9341 lcd display1:SCK", + "arduino uno1:13", + "green", + [ + "v0" + ] + ], + [ + "ili9341 lcd display1:MISO", + "arduino uno1:12", + "green", + [ + "v0" + ] + ], + [ + "push button1:1.l", + "arduino uno1:5V", + "red", + [ + "h-19.2", + "v451.2", + "h201.6" + ] + ], + [ + "push button2:1.r", + "arduino uno1:5V", + "red", + [ + "v0", + "h19.4", + "v451.2", + "h-240" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level4/calendar_display/diagram_breadboard.json b/arduino/level4/calendar_display/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..22459f4864b93ffe7b5f591384250c95f49379dc --- /dev/null +++ b/arduino/level4/calendar_display/diagram_breadboard.json @@ -0,0 +1,460 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Using an RTC, display the current date and day of the week on ili9341 LCD, and navigate days with buttons", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -319.8, + "left": -102.8, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-ili9341", + "id": "ili9341 lcd display1", + "top": -488.8, + "left": 57.3, + "attrs": {} + }, + { + "type": "wokwi-ds1307", + "id": "rtc module1", + "top": -273.5, + "left": 381.2, + "rotate": 270, + "attrs": { + "initTime": "2025-05-10T02:04:00" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -250.2, + "left": -25.8, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button2", + "top": -250.2, + "left": 252.6, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -187.75, + "left": -59, + "rotate": 180, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -187.75, + "left": 296.2, + "rotate": 180, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "ili9341 lcd display1:VCC", + "breadboard1:20b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:GND", + "breadboard1:21b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:CS", + "breadboard1:22b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:RST", + "breadboard1:23b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:D/C", + "breadboard1:24b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:MOSI", + "breadboard1:25b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:SCK", + "breadboard1:26b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:LED", + "breadboard1:27b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:MISO", + "breadboard1:28b.f", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:20b.h", + "breadboard1:bp.15", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:21b.h", + "breadboard1:bn.16", + "green", + [ + "v0" + ] + ], + [ + "push button1:1.l", + "breadboard1:11t.b", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.l", + "breadboard1:9t.b", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.r", + "breadboard1:11b.g", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.r", + "breadboard1:9b.g", + "", + [ + "$bb" + ] + ], + [ + "push button2:1.l", + "breadboard1:40t.b", + "", + [ + "$bb" + ] + ], + [ + "push button2:2.l", + "breadboard1:38t.b", + "", + [ + "$bb" + ] + ], + [ + "push button2:1.r", + "breadboard1:40b.g", + "", + [ + "$bb" + ] + ], + [ + "push button2:2.r", + "breadboard1:38b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:9b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:3b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:46b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:40b.h", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:3b.j", + "breadboard1:bn.2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:46b.j", + "breadboard1:bn.36", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:9t.a", + "arduino uno1:3", + "green", + [ + "v240", + "h211.2" + ] + ], + [ + "breadboard1:40t.a", + "arduino uno1:2", + "green", + [ + "v240", + "h-86.4" + ] + ], + [ + "breadboard1:38b.h", + "breadboard1:bp.31", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:11b.h", + "breadboard1:bp.8", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:22b.h", + "arduino uno1:10", + "green", + [ + "v134.4", + "h9.6" + ] + ], + [ + "breadboard1:23b.h", + "arduino uno1:8", + "green", + [ + "v134.4", + "h19.2" + ] + ], + [ + "breadboard1:24b.h", + "arduino uno1:9", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:25b.h", + "arduino uno1:11", + "green", + [ + "v163.2", + "h-28.8" + ] + ], + [ + "breadboard1:26b.h", + "arduino uno1:13", + "green", + [ + "v163.2", + "h-57.6" + ] + ], + [ + "breadboard1:28b.h", + "arduino uno1:12", + "green", + [ + "v172.8", + "h-67.2" + ] + ], + [ + "rtc module1:GND", + "breadboard1:51b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:5V", + "breadboard1:52b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:SDA", + "breadboard1:53b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:SCL", + "breadboard1:54b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:SQW", + "breadboard1:55b.g", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:51b.i", + "breadboard1:bn.41", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:52b.i", + "breadboard1:bp.42", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:53b.i", + "arduino uno1:A4", + "green", + [ + "v374.4", + "h-201.6" + ] + ], + [ + "breadboard1:54b.i", + "arduino uno1:A5", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:bn.1", + "arduino uno1:GND.2", + "green", + [ + "v334.7", + "h210.4" + ] + ], + [ + "breadboard1:bp.3", + "arduino uno1:5V", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level4/calendar_display/platformio.ini b/arduino/level4/calendar_display/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..f0b285e6e7253af3f5f15b3fde056ae53ff0c2f0 --- /dev/null +++ b/arduino/level4/calendar_display/platformio.ini @@ -0,0 +1,22 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + RTClib + Adafruit ILI9341 \ No newline at end of file diff --git a/arduino/level4/calendar_display/scenario.yaml b/arduino/level4/calendar_display/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..98edc15991ea473d3fad39d9f852d93200eff058 --- /dev/null +++ b/arduino/level4/calendar_display/scenario.yaml @@ -0,0 +1,50 @@ +author: Blind Author +description: Using an RTC, display the current date and day of the week on ili9341 + LCD, and navigate days with buttons +name: Calendar Display +test-values: +- part-type: wokwi-ds1307 + attr-name: initTime + value: '2025-05-10T02:04:00' +steps: +- delay: 2000ms +- take-screenshot: + part-id: ili9341 lcd display1 + compare-with: screenshots/0.png +- set-control: + control: pressed + part-id: push button1 + value: 1 +- set-control: + control: pressed + part-id: push button1 + value: 0 +- delay: 2000ms +- take-screenshot: + part-id: ili9341 lcd display1 + compare-with: screenshots/1.png +- set-control: + control: pressed + part-id: push button2 + value: 1 +- set-control: + control: pressed + part-id: push button2 + value: 0 +- delay: 2000ms +- take-screenshot: + part-id: ili9341 lcd display1 + compare-with: screenshots/2.png +- set-control: + control: pressed + part-id: push button2 + value: 1 +- set-control: + control: pressed + part-id: push button2 + value: 0 +- delay: 2000ms +- take-screenshot: + part-id: ili9341 lcd display1 + compare-with: screenshots/3.png +version: 1.0 diff --git a/arduino/level4/calendar_display/screenshots/0.png b/arduino/level4/calendar_display/screenshots/0.png new file mode 100644 index 0000000000000000000000000000000000000000..e1d95f76d422ff4d9e58c04108bcf24a1c4b6d72 --- /dev/null +++ b/arduino/level4/calendar_display/screenshots/0.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9d1526e7cbf8e129ef3dfdf08f08de51a1cd59c0b287f32b02aee187172bf45 +size 1678 diff --git a/arduino/level4/calendar_display/screenshots/1.png b/arduino/level4/calendar_display/screenshots/1.png new file mode 100644 index 0000000000000000000000000000000000000000..40562eda96c86a86814d05c0b565ae6271540d20 --- /dev/null +++ b/arduino/level4/calendar_display/screenshots/1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:05a59359d8fb2305f46c2a5817369579e3d9639a12abc6efa97d0721a772f5f8 +size 1593 diff --git a/arduino/level4/calendar_display/screenshots/2.png b/arduino/level4/calendar_display/screenshots/2.png new file mode 100644 index 0000000000000000000000000000000000000000..e1d95f76d422ff4d9e58c04108bcf24a1c4b6d72 --- /dev/null +++ b/arduino/level4/calendar_display/screenshots/2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9d1526e7cbf8e129ef3dfdf08f08de51a1cd59c0b287f32b02aee187172bf45 +size 1678 diff --git a/arduino/level4/calendar_display/screenshots/3.png b/arduino/level4/calendar_display/screenshots/3.png new file mode 100644 index 0000000000000000000000000000000000000000..13ac04380fa191e944ffe5953085ccca21826090 --- /dev/null +++ b/arduino/level4/calendar_display/screenshots/3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e6fce3f810995563894698db031cd2e0c6ffa72f526b4c83c09b063b6e5efb0f +size 1577 diff --git a/arduino/level4/calendar_display/src/main.ino b/arduino/level4/calendar_display/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..646224617bc5742c855aa7b7cf963ef3524ef173 --- /dev/null +++ b/arduino/level4/calendar_display/src/main.ino @@ -0,0 +1,79 @@ +/** + Using an RTC, display the current date and day of the week on ili9341 LCD, and navigate days with buttons + 03 MAY 2025 by Blind Author +*/ + +#include +#include "RTClib.h" +#include +#include + +#define TFT_CS 10 +#define TFT_DC 9 +#define TFT_RST 8 + +Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); +RTC_DS3231 rtc; + +#define LEFT_BUTTON_PIN 3 +#define RIGHT_BUTTON_PIN 2 + +DateTime currentDate; +int dayOffset = 0; + +const char* daysOfWeek[] = { + "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" +}; + +void setup() { + Serial.begin(9600); + Wire.begin(); + + pinMode(LEFT_BUTTON_PIN, INPUT); + pinMode(RIGHT_BUTTON_PIN, INPUT); + + if (!rtc.begin()) { + Serial.println("Couldn't find RTC"); + while (1); + } + + if (rtc.lostPower()) { + Serial.println("RTC lost power, setting time!"); + rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); + } + + tft.begin(); + tft.fillScreen(ILI9341_BLACK); + displayDate(); +} + +void loop() { + if (digitalRead(LEFT_BUTTON_PIN) == HIGH) { + dayOffset--; + displayDate(); + delay(300); + } + + if (digitalRead(RIGHT_BUTTON_PIN) == HIGH) { + dayOffset++; + displayDate(); + delay(300); + } +} + +void displayDate() { + DateTime now = rtc.now(); + currentDate = now + TimeSpan(dayOffset, 0, 0, 0); + + tft.fillScreen(ILI9341_BLACK); + tft.setTextSize(3); + tft.setTextColor(ILI9341_WHITE); + tft.setCursor(10, 30); + + char buffer[20]; + sprintf(buffer, "%04d-%02d-%02d", currentDate.year(), currentDate.month(), currentDate.day()); + tft.println(buffer); + + tft.setCursor(10, 80); + tft.println(daysOfWeek[currentDate.dayOfTheWeek()]); +} diff --git a/arduino/level4/calendar_display/wokwi.toml b/arduino/level4/calendar_display/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level4/calendar_display/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level4/clock/description.md b/arduino/level4/clock/description.md new file mode 100644 index 0000000000000000000000000000000000000000..4554a5d082bcb05e1738ef751a82864e67bbc029 --- /dev/null +++ b/arduino/level4/clock/description.md @@ -0,0 +1,31 @@ +# Clock + +## Project Description +This is a Arduino project that show current time using 4-digit 7-segment display. + +## Hardware Components +- Arduino Uno +- 4-digit 7-segment display +- RTC module + +## Circuit Description +Circuit is designed to use a 4-digit 7-segment display and a RTC module. +For RTC module, the VCC pin is connected to arduino 5V, the GND pin to gnd3, the SDA pin to A4, and the SCL pin to A5. +In the 4-digit 7-segment display, digit pins dig1 ~ dig4 are connected to arduino pin2 ~ pin5, respectively. Segment pins A ~ G are connected to arduino pin6 ~ pin12. Colon pin is connected to pin13. The common pin of display is connected to 5v. + +## Expected Behavior +When the Arduino powers up, it should: +1. Check if the RTC module is available and initialize it +2. Set pin 2 ~ 13 mode as OUTPUT +3. Turn on the colon led +4. Continuously retrieve the current time from the RTC +5. Display current time to 4-digit 7-segment display, in the following format: "HH:MM" + +## Success Criteria +The test is successful when: +1. The correct time is shown to the 4-digit 7-segment display + +## Notes for Implementation +- The 7-segment display is common anode type, so the segment turns on when the pin reads LOW. +- Digits are activated when digit pins are HIGH. +- When using a 4-digit 7-segment display, be sure to specify '4-digit' at the beginning of the component type. \ No newline at end of file diff --git a/arduino/level4/clock/description_no_pin.md b/arduino/level4/clock/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..77e1765e3602b842e65ec75660d6a097a116d51d --- /dev/null +++ b/arduino/level4/clock/description_no_pin.md @@ -0,0 +1,31 @@ +# Clock + +## Project Description +This is a Arduino project that show current time using 4-digit 7-segment display. + +## Hardware Components +- Arduino Uno +- 4-digit 7-segment display +- RTC module + +## Circuit Description +Circuit is designed to use a 4-digit 7-segment display and a RTC module. +RTC module follows the standard wiring conventions defined by the I2C protocol. +In the 4-digit 7-segment display, digit pins dig1 to dig4 and segment pins A ~ G are connected to arduino digital pins. Colon pin is also connected to arduino digital pin. 4-digit 7-segment display has common anode configuration. + +## Expected Behavior +When the Arduino powers up, it should: +1. Check if the RTC module is available and initialize it +2. Set segment pins and digit pins mode as OUTPUT +3. Turn on the colon led +4. Continuously retrieve the current time from the RTC +5. Display current time to 4-digit 7-segment display, in the following format: "HH:MM" + +## Success Criteria +The test is successful when: +1. The correct time is shown to the 4-digit 7-segment display + +## Notes for Implementation +- The 7-segment display is common anode type, so the segment turns on when the pin reads LOW. +- Digits are activated when digit pins are HIGH. +- When using a 4-digit 7-segment display, be sure to specify '4-digit' at the beginning of the component type. \ No newline at end of file diff --git a/arduino/level4/clock/diagram.json b/arduino/level4/clock/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..e5943e02580069d546519573e44af03b1e84871c --- /dev/null +++ b/arduino/level4/clock/diagram.json @@ -0,0 +1,203 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Get the current time using an RTC sensor, and change into different timezones with button.", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -105, + "left": -67.8, + "attrs": {} + }, + { + "type": "wokwi-ds1307", + "id": "rtc module1", + "top": 138.6, + "left": 192.1, + "attrs": { + "initTime": "2024-11-24T04:48:57" + } + }, + { + "type": "wokwi-7segment", + "id": "7-segment display1", + "top": -234.18, + "left": 68.32, + "attrs": { + "digits": "4", + "colon": "1", + "commonPin": "anode" + } + } + ], + "connections": [ + [ + "rtc module1:SCL", + "arduino uno1:A5", + "green", + [ + "h0" + ] + ], + [ + "rtc module1:SDA", + "arduino uno1:A4", + "green", + [ + "h0" + ] + ], + [ + "rtc module1:5V", + "arduino uno1:5V", + "red", + [ + "h0" + ] + ], + [ + "rtc module1:GND", + "arduino uno1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "7-segment display1:DIG1", + "arduino uno1:2", + "green", + [ + "v-9.6", + "h-76.79", + "v86.4", + "h115.2", + "v9.6" + ] + ], + [ + "7-segment display1:DIG2", + "arduino uno1:3", + "green", + [ + "v-19.2", + "h-115.2", + "v105.6", + "h115.2" + ] + ], + [ + "7-segment display1:DIG3", + "arduino uno1:4", + "green", + [ + "v-28.8", + "h-134.4", + "v115.2", + "h105.6", + "v9.6" + ] + ], + [ + "7-segment display1:DIG4", + "arduino uno1:5", + "green", + [ + "v47.16", + "h-48" + ] + ], + [ + "7-segment display1:A", + "arduino uno1:6", + "orange", + [ + "v-38.4", + "h-115.2", + "v134.4", + "h105.6" + ] + ], + [ + "7-segment display1:B", + "arduino uno1:7", + "orange", + [ + "v-48", + "h-163.2", + "v153.6", + "h105.6" + ] + ], + [ + "7-segment display1:C", + "arduino uno1:8", + "orange", + [ + "v0" + ] + ], + [ + "7-segment display1:D", + "arduino uno1:9", + "orange", + [ + "v47.16", + "h-57.6" + ] + ], + [ + "7-segment display1:E", + "arduino uno1:10", + "orange", + [ + "v47.16", + "h-47.99", + "v19.2" + ] + ], + [ + "7-segment display1:F", + "arduino uno1:11", + "orange", + [ + "v-57.6", + "h-144", + "v172.8", + "h67.2" + ] + ], + [ + "7-segment display1:CLN", + "arduino uno1:13", + "green", + [ + "h0", + "v-67.2", + "h-192", + "v192", + "h57.6" + ] + ], + [ + "7-segment display1:G", + "arduino uno1:12", + "orange", + [ + "v37.56", + "h-115.2" + ] + ], + [ + "7-segment display1:COM", + "arduino uno1:5V", + "red", + [ + "v210.36", + "h-96" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level4/clock/diagram_breadboard.json b/arduino/level4/clock/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..f145201e79f3520194985c80eb6c2c28d289220e --- /dev/null +++ b/arduino/level4/clock/diagram_breadboard.json @@ -0,0 +1,379 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Get the current time using an RTC sensor, and change into different timezones with button.", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -358.2, + "left": -93.2, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -105, + "left": -67.8, + "attrs": {} + }, + { + "type": "wokwi-ds1307", + "id": "rtc module1", + "top": -311.9, + "left": 275.6, + "rotate": 270, + "attrs": { + "initTime": "2024-11-24T04:48:57" + } + }, + { + "type": "wokwi-7segment", + "id": "7-segment display1", + "top": -291.78, + "left": -27.68, + "attrs": { + "digits": "4", + "colon": "1", + "commonPin": "anode" + } + } + ], + "connections": [ + [ + "rtc module1:GND", + "breadboard1:39b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:5V", + "breadboard1:40b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:SDA", + "breadboard1:41b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:SCL", + "breadboard1:42b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:SQW", + "breadboard1:43b.g", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:A", + "breadboard1:13t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:B", + "breadboard1:17t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:C", + "breadboard1:15b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:D", + "breadboard1:13b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:E", + "breadboard1:12b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:F", + "breadboard1:14t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:G", + "breadboard1:16b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:DP", + "breadboard1:14b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:DIG1", + "breadboard1:12t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:DIG2", + "breadboard1:15t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:DIG3", + "breadboard1:16t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:DIG4", + "breadboard1:17b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:COM", + "breadboard1:18b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:CLN", + "breadboard1:18t.c", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:18b.j", + "breadboard1:bp.15", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:bp.1", + "arduino uno1:5V", + "red", + [ + "v-0.9", + "h-48.8", + "v288", + "h192" + ] + ], + [ + "breadboard1:bn.1", + "arduino uno1:GND.2", + "black", + [ + "v-1.3", + "h-39.2", + "v288", + "h192" + ] + ], + [ + "breadboard1:12t.b", + "arduino uno1:2", + "green", + [ + "v-67.2", + "h-153.6", + "v220.8", + "h288" + ] + ], + [ + "breadboard1:15t.b", + "arduino uno1:3", + "green", + [ + "v-76.8", + "h-192", + "v240", + "h288" + ] + ], + [ + "breadboard1:16t.b", + "arduino uno1:4", + "green", + [ + "v-86.4", + "h-211.2", + "v259.2", + "h278.4" + ] + ], + [ + "breadboard1:17b.j", + "arduino uno1:5", + "green", + [ + "v86.4", + "h57.6" + ] + ], + [ + "breadboard1:13t.b", + "arduino uno1:6", + "orange", + [ + "v-105.6", + "h48" + ] + ], + [ + "breadboard1:17t.b", + "arduino uno1:7", + "orange", + [ + "v-115.2", + "h28.8" + ] + ], + [ + "breadboard1:15b.j", + "arduino uno1:8", + "orange", + [ + "v86.4", + "h38.4" + ] + ], + [ + "breadboard1:13b.j", + "arduino uno1:9", + "orange", + [ + "v96", + "h48" + ] + ], + [ + "breadboard1:12b.j", + "arduino uno1:10", + "orange", + [ + "v86.4", + "h48" + ] + ], + [ + "breadboard1:14t.b", + "arduino uno1:11", + "orange", + [ + "v-134.4", + "h-38.4", + "v316.8", + "h57.6" + ] + ], + [ + "breadboard1:16b.j", + "arduino uno1:12", + "orange", + [ + "v86.4", + "h-9.6" + ] + ], + [ + "breadboard1:18t.b", + "arduino uno1:13", + "green", + [ + "v-153.6", + "h-96", + "v336", + "h57.6" + ] + ], + [ + "breadboard1:42b.i", + "arduino uno1:A5", + "green", + [ + "v355.2", + "h-134.4" + ] + ], + [ + "breadboard1:41b.i", + "arduino uno1:A4", + "green", + [ + "v326.4", + "h-134.4" + ] + ], + [ + "breadboard1:40b.i", + "breadboard1:bp.31", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:39b.i", + "breadboard1:bn.30", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level4/clock/platformio.ini b/arduino/level4/clock/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..df4b80305bbe895d07c0f1c0e74b60a1d2862746 --- /dev/null +++ b/arduino/level4/clock/platformio.ini @@ -0,0 +1,21 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + RTClib \ No newline at end of file diff --git a/arduino/level4/clock/scenario.yaml b/arduino/level4/clock/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2db4b3d9dafdbdfa34190146e97347c49e34383c --- /dev/null +++ b/arduino/level4/clock/scenario.yaml @@ -0,0 +1,218 @@ +author: Blind Author +description: 4-digit 7-segment displat clock +name: Clock +test-values: +- part-type: wokwi-7segment + attr-name: colon + value: "1" +- part-type: wokwi-ds1307 + attr-name: initTime + value: "2024-11-24T04:48:57" +steps: +- delay: 100ms +- wait-pin: + part-id: 7-segment display1 + pin: CLN + value: 0 +- wait-multi-pin: + timeout: 2000 + interval: 10 + pins: + - part-id: 7-segment display1 + pin: COM + value: 1 + - part-id: 7-segment display1 + pin: DIG1 + value: 1 + - part-id: 7-segment display1 + pin: DIG2 + value: 0 + - part-id: 7-segment display1 + pin: DIG3 + value: 0 + - part-id: 7-segment display1 + pin: DIG4 + value: 0 + - part-id: 7-segment display1 + pin: A + value: 0 + - part-id: 7-segment display1 + pin: B + value: 0 + - part-id: 7-segment display1 + pin: C + value: 0 + - part-id: 7-segment display1 + pin: D + value: 0 + - part-id: 7-segment display1 + pin: E + value: 0 + - part-id: 7-segment display1 + pin: F + value: 0 + - part-id: 7-segment display1 + pin: G + value: 1 +- wait-multi-pin: + timeout: 2000 + interval: 10 + pins: + - part-id: 7-segment display1 + pin: COM + value: 1 + - part-id: 7-segment display1 + pin: DIG1 + value: 0 + - part-id: 7-segment display1 + pin: DIG2 + value: 1 + - part-id: 7-segment display1 + pin: DIG3 + value: 0 + - part-id: 7-segment display1 + pin: DIG4 + value: 0 + - part-id: 7-segment display1 + pin: A + value: 1 + - part-id: 7-segment display1 + pin: B + value: 0 + - part-id: 7-segment display1 + pin: C + value: 0 + - part-id: 7-segment display1 + pin: D + value: 1 + - part-id: 7-segment display1 + pin: E + value: 1 + - part-id: 7-segment display1 + pin: F + value: 0 + - part-id: 7-segment display1 + pin: G + value: 0 +- wait-multi-pin: + timeout: 2000 + interval: 10 + pins: + - part-id: 7-segment display1 + pin: COM + value: 1 + - part-id: 7-segment display1 + pin: DIG1 + value: 0 + - part-id: 7-segment display1 + pin: DIG2 + value: 0 + - part-id: 7-segment display1 + pin: DIG3 + value: 1 + - part-id: 7-segment display1 + pin: DIG4 + value: 0 + - part-id: 7-segment display1 + pin: A + value: 1 + - part-id: 7-segment display1 + pin: B + value: 0 + - part-id: 7-segment display1 + pin: C + value: 0 + - part-id: 7-segment display1 + pin: D + value: 1 + - part-id: 7-segment display1 + pin: E + value: 1 + - part-id: 7-segment display1 + pin: F + value: 0 + - part-id: 7-segment display1 + pin: G + value: 0 +- wait-multi-pin: + timeout: 2000 + interval: 10 + pins: + - part-id: 7-segment display1 + pin: COM + value: 1 + - part-id: 7-segment display1 + pin: DIG1 + value: 0 + - part-id: 7-segment display1 + pin: DIG2 + value: 0 + - part-id: 7-segment display1 + pin: DIG3 + value: 0 + - part-id: 7-segment display1 + pin: DIG4 + value: 1 + - part-id: 7-segment display1 + pin: A + value: 0 + - part-id: 7-segment display1 + pin: B + value: 0 + - part-id: 7-segment display1 + pin: C + value: 0 + - part-id: 7-segment display1 + pin: D + value: 0 + - part-id: 7-segment display1 + pin: E + value: 0 + - part-id: 7-segment display1 + pin: F + value: 0 + - part-id: 7-segment display1 + pin: G + value: 0 +- delay: 1000ms +- wait-multi-pin: + timeout: 2000 + interval: 10 + pins: + - part-id: 7-segment display1 + pin: COM + value: 1 + - part-id: 7-segment display1 + pin: DIG1 + value: 0 + - part-id: 7-segment display1 + pin: DIG2 + value: 0 + - part-id: 7-segment display1 + pin: DIG3 + value: 0 + - part-id: 7-segment display1 + pin: DIG4 + value: 1 + - part-id: 7-segment display1 + pin: A + value: 0 + - part-id: 7-segment display1 + pin: B + value: 0 + - part-id: 7-segment display1 + pin: C + value: 0 + - part-id: 7-segment display1 + pin: D + value: 0 + - part-id: 7-segment display1 + pin: E + value: 1 + - part-id: 7-segment display1 + pin: F + value: 0 + - part-id: 7-segment display1 + pin: G + value: 0 +version: 1.0 diff --git a/arduino/level4/clock/src/main.ino b/arduino/level4/clock/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..163585ab32fb2054ea203d5812a685087705a584 --- /dev/null +++ b/arduino/level4/clock/src/main.ino @@ -0,0 +1,65 @@ +/** + Show current time in 4-digit 7-segment display + 04 May 2025 by Blind Author +*/ + +#include "RTClib.h" + +RTC_DS1307 rtc; + +const int digitPins[4] = {2, 3, 4, 5}; +const int segmentPins[7] = {6, 7, 8, 9, 10, 11, 12}; + +const byte digits[10][7] = { + {1,1,1,1,1,1,0}, + {0,1,1,0,0,0,0}, + {1,1,0,1,1,0,1}, + {1,1,1,1,0,0,1}, + {0,1,1,0,0,1,1}, + {1,0,1,1,0,1,1}, + {1,0,1,1,1,1,1}, + {1,1,1,0,0,0,0}, + {1,1,1,1,1,1,1}, + {1,1,1,1,0,1,1} +}; + +void setup() { + Serial.begin(9600); + for (int i=0; i<4; i++) { + pinMode(digitPins[i], OUTPUT); + } + + for (int i=0; i<7; i++) { + pinMode(segmentPins[i], OUTPUT); + } + + pinMode(13, OUTPUT); + digitalWrite(13, LOW); + + if (! rtc.begin()) { + Serial.println("Couldn't find RTC"); + Serial.flush(); + abort(); + } +} + +void loop() { + DateTime now = rtc.now(); + + int times[4] = { + now.hour() / 10, + now.hour() % 10, + now.minute() / 10, + now.minute() % 10 + }; + + for (int i=0; i<4; i++) { + for (int j=0; j<7; j++) { + digitalWrite(segmentPins[j], digits[times[i]][j] ? LOW : HIGH); + } + digitalWrite(digitPins[i], HIGH); + delay(5); + digitalWrite(digitPins[i], LOW); + } + +} \ No newline at end of file diff --git a/arduino/level4/clock/wokwi.toml b/arduino/level4/clock/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level4/clock/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level4/dday_counter/description.md b/arduino/level4/dday_counter/description.md new file mode 100644 index 0000000000000000000000000000000000000000..8ed4c6a65ce557614abc982057254da94385e21c --- /dev/null +++ b/arduino/level4/dday_counter/description.md @@ -0,0 +1,34 @@ +# Serial RTC sensor + +## Project Description +This is a simple Arduino project that compare RTC sensor time and serial input. + +## Hardware Components +- Arduino Uno +- ds1307 Real Time Clock module + +## Circuit Description +The RTC sensor is connected to the Arduino. The VCC pin is connected to 5V, the GND pin to gnd2, the SDA pin to A4, and the SCL pin to A5. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Check if the RTC module can begin +3. Read current time once with RTC module +4. Continuously read the serial input, which is a target datetime in ISO format +5. Calculate how much day is left until the target time, and print to the serial monitor in the following format: "D-{days}" + +## Success Criteria +The test is successful when: +1. Correct day left to the target datetime is printed in the serial monitor. + +## Notes for Implementation +- Get current time with RTC sensor only once, in the setup +- Use RTClib to generate RTC_DS1307 object and read the value. +- RTC module has I2C interface. + +## Variants +There may be variants with GND pin. + +## Test Inputs +Test input values are: "2025-04-11T09:38:00", "2025-06-11T09:38:00", "2025-03-03T09:38:00" \ No newline at end of file diff --git a/arduino/level4/dday_counter/description_no_pin.md b/arduino/level4/dday_counter/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..ba203ffdd2b1842c12263c2bc6fc0b8770d6743a --- /dev/null +++ b/arduino/level4/dday_counter/description_no_pin.md @@ -0,0 +1,34 @@ +# Serial RTC sensor + +## Project Description +This is a simple Arduino project that compare RTC sensor time and serial input. + +## Hardware Components +- Arduino Uno +- ds1307 Real Time Clock module + +## Circuit Description +The RTC sensor is connected to the Arduino. RTC sensor follows the standard wiring conventions defined by the I2C protocol. + +## Expected Behavior +When the Arduino powers up, it should: +1. Initialize serial communication +2. Check if the RTC module can begin +3. Read current time once with RTC module +4. Continuously read the serial input, which is a target datetime in ISO format +5. Calculate how much day is left until the target time, and print to the serial monitor in the following format: "D-{days}" + +## Success Criteria +The test is successful when: +1. Correct day left to the target datetime is printed in the serial monitor. + +## Notes for Implementation +- Get current time with RTC sensor only once, in the setup +- Use RTClib to generate RTC_DS1307 object and read the value. +- RTC module has I2C interface. + +## Variants +There may be variants with GND pin. + +## Test Inputs +Test input values are: "2025-04-11T09:38:00", "2025-06-11T09:38:00", "2025-03-03T09:38:00" \ No newline at end of file diff --git a/arduino/level4/dday_counter/diagram.json b/arduino/level4/dday_counter/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..41e554dddcc2a01bfc3bc9f2749ef5ec0555fc50 --- /dev/null +++ b/arduino/level4/dday_counter/diagram.json @@ -0,0 +1,67 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Compare RTC sensor time and serial input", + "config": { + "gnd_pin": "GND.2", + "vcc_pin": "5V" + }, + "parts": [ + { + "id": "arduino uno1", + "type": "wokwi-arduino-uno", + "top": 0, + "left": 20 + }, + { + "id": "rtc module1307", + "type": "wokwi-ds1307", + "top": 250, + "left": 220, + "attrs": { + "initTime": "2024-11-24T04:48:00" + } + } + ], + "connections": [ + [ + "arduino uno1:GND.2", + "rtc module1307:GND", + "black", + [ + "v20", + "*", + "v0" + ] + ], + [ + "arduino uno1:5V", + "rtc module1307:5V", + "red", + [ + "v0" + ] + ], + [ + "arduino uno1:A4", + "rtc module1307:SDA", + "green", + [ + "v16", + "h0", + "*", + "h-34" + ] + ], + [ + "arduino uno1:A5", + "rtc module1307:SCL", + "orange", + [ + "v20", + "*", + "h-30" + ] + ] + ] +} \ No newline at end of file diff --git a/arduino/level4/dday_counter/diagram_breadboard.json b/arduino/level4/dday_counter/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..448ade0256a65d0327336336a44427a1ccfc5372 --- /dev/null +++ b/arduino/level4/dday_counter/diagram_breadboard.json @@ -0,0 +1,126 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Compare RTC sensor time and serial input", + "config": { + "gnd_pin": "GND.2", + "vcc_pin": "5V" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": 208.2, + "left": -6.8, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 20, + "attrs": {} + }, + { + "type": "wokwi-ds1307", + "id": "rtc module1307", + "top": 295.1, + "left": 183.2, + "rotate": 90, + "attrs": { + "initTime": "2024-11-24T04:48:00" + } + } + ], + "connections": [ + [ + "rtc module1307:GND", + "breadboard1:26t.e", + "", + [ + "$bb" + ] + ], + [ + "rtc module1307:5V", + "breadboard1:25t.e", + "", + [ + "$bb" + ] + ], + [ + "rtc module1307:SDA", + "breadboard1:24t.e", + "", + [ + "$bb" + ] + ], + [ + "rtc module1307:SCL", + "breadboard1:23t.e", + "", + [ + "$bb" + ] + ], + [ + "rtc module1307:SQW", + "breadboard1:22t.e", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:26t.c", + "breadboard1:tn.20", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:tn.19", + "arduino uno1:GND.2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:25t.c", + "breadboard1:tp.17", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:tp.16", + "arduino uno1:5V", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:24t.c", + "arduino uno1:A4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:23t.c", + "arduino uno1:A5", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level4/dday_counter/platformio.ini b/arduino/level4/dday_counter/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..df4b80305bbe895d07c0f1c0e74b60a1d2862746 --- /dev/null +++ b/arduino/level4/dday_counter/platformio.ini @@ -0,0 +1,21 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + RTClib \ No newline at end of file diff --git a/arduino/level4/dday_counter/scenario.yaml b/arduino/level4/dday_counter/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d9f0dbfb4095dde2f2d64fe43a4f2a58e7a05830 --- /dev/null +++ b/arduino/level4/dday_counter/scenario.yaml @@ -0,0 +1,16 @@ +author: Blind Author +description: Compare RTC sensor time and serial input +name: Serial RTC sensor +test-values: +- part-type: wokwi-ds1307 + attr-name: initTime + value: "2024-11-24T04:48:57" +steps: +- wait-serial: Enter target datetime in format YYYY-MM-DDTHH:MM:SS +- write-serial: '2025-04-11T09:38:00' +- wait-serial: D-138 +- write-serial: '2025-06-11T09:38:00' +- wait-serial: D-199 +- write-serial: '2025-03-03T09:38:00' +- wait-serial: D-99 +version: 1.0 diff --git a/arduino/level4/dday_counter/src/main.ino b/arduino/level4/dday_counter/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..bb3055c95af2c9e6a4bbcccd76641de59bd002e4 --- /dev/null +++ b/arduino/level4/dday_counter/src/main.ino @@ -0,0 +1,45 @@ +/** + Compare RTC sensor time and serial input + 11 APR 2025 by Blind Author +*/ + +#include "RTClib.h" + +RTC_DS1307 rtc; +DateTime now; + +void setup () { + Serial.begin(115200); + + if (!rtc.begin()) { + Serial.println("Couldn't find RTC"); + Serial.flush(); + abort(); + } + + now = rtc.now(); + + Serial.println("Enter target datetime in format YYYY-MM-DDTHH:MM:SS"); +} + +void loop () { + + if (Serial.available()) { + String input = Serial.readStringUntil('\n'); + + int year = input.substring(0, 4).toInt(); + int month = input.substring(5, 7).toInt(); + int day = input.substring(8, 10).toInt(); + int hour = input.substring(11, 13).toInt(); + int minute = input.substring(14, 16).toInt(); + int second = input.substring(17, 19).toInt(); + + DateTime target(year, month, day, hour, minute, second); + + TimeSpan diff = target - now; + Serial.print("D-"); + Serial.println(abs(diff.days())); + } + + delay(500); +} diff --git a/arduino/level4/dday_counter/wokwi.toml b/arduino/level4/dday_counter/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level4/dday_counter/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level4/exercise_counter/description.md b/arduino/level4/exercise_counter/description.md new file mode 100644 index 0000000000000000000000000000000000000000..495eb6ba59d7568fa127ea28aeae798b31b198ec --- /dev/null +++ b/arduino/level4/exercise_counter/description.md @@ -0,0 +1,34 @@ +# Exercise Counter + +## Project Description +This is a motion counter that detects movement with an MPU6050 gyroscope and displays the count on a 1-digit 7-segment display, made with arduino uno. + +## Hardware Components +- Arduino Uno +- 7-segment display +- 220Ω resistor * 7 +- MPU6050 6-axis Accel & Gyro Sensor + +## Circuit Description +A 7-segment display and a mpu6050 sensor is connected to arduino uno. Pin A to G is connected to arduino pin 2 to 8 through 220Ω resistor, respectively. Common pin of 7-segment is connected to gnd2. For mpu6050 sensor, VCC and GND pin is connected to arduino 5v and gnd2 pin. SCL pin and SDA pin is connected to arduino pin A5 and A4. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set pins for 7-segments as OUTPUT +2. Check the connection of mpu6050 +3. Display number 0 on the 7-segment display +4. Continuously read the Y rotation value of mpu6050 +5. The count increases when the Y-axis rotation value exceeds 15000, and it does not increase again until the absolute value drops below 2000 +6. Continuously display the count on the 7-segment display + +## Success Criteria +The test is successful when: +1. The count increases only when the absolute Y-axis rotation value rises above 15000 after previously dropping below 2000. +2. The current count is correctly displayed on the 7-segment display. + +## Notes for Implementation +- Use MPU6050.h, Wire.h libraries. +- MPU6050 has I2C interface. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level4/exercise_counter/description_no_pin.md b/arduino/level4/exercise_counter/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..18332b74a49d1c3722a27addfa807e7d31b7d2ce --- /dev/null +++ b/arduino/level4/exercise_counter/description_no_pin.md @@ -0,0 +1,34 @@ +# Exercise Counter + +## Project Description +This is a motion counter that detects movement with an MPU6050 gyroscope and displays the count on a 1-digit 7-segment display, made with arduino uno. + +## Hardware Components +- Arduino Uno +- 7-segment display +- 220Ω resistor * 7 +- MPU6050 6-axis Accel & Gyro Sensor + +## Circuit Description +A 7-segment display and a mpu6050 sensor is connected to arduino uno. Pin A to G is connected to arduino digtial pins through 220Ω resistor, respectively. 7-segment display has common cathode configuration. MPU6050 sensor follows the standard wiring conventions defined by the I2C protocol. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set pins for 7-segments as OUTPUT +2. Check the connection of mpu6050 +3. Display number 0 on the 7-segment display +4. Continuously read the Y rotation value of mpu6050 +5. The count increases when the Y-axis rotation value exceeds 15000, and it does not increase again until the absolute value drops below 2000 +6. Continuously display the count on the 7-segment display + +## Success Criteria +The test is successful when: +1. The count increases only when the absolute Y-axis rotation value rises above 15000 after previously dropping below 2000. +2. The current count is correctly displayed on the 7-segment display. + +## Notes for Implementation +- Use MPU6050.h, Wire.h libraries. +- MPU6050 has I2C interface. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level4/exercise_counter/diagram.json b/arduino/level4/exercise_counter/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..4e79b4e9f14244aa032cbcece89388a48472327e --- /dev/null +++ b/arduino/level4/exercise_counter/diagram.json @@ -0,0 +1,272 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Motion counter that detects movement with an MPU6050 gyroscope and displays the count on a 1-digit 7-segment display", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-mpu6050", + "id": "mpu6050 6-axis accel & gyro sensor1", + "top": -63.38, + "left": 271.12, + "attrs": { + "rotationY": "0" + } + }, + { + "type": "wokwi-7segment", + "id": "7-segment display1", + "top": -158.22, + "left": 158.68, + "attrs": { + "common": "cathode" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -63.25, + "left": 115.2, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -72.85, + "left": 105.6, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -72.85, + "left": 201.6, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": -63.25, + "left": 192, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": -178.45, + "left": 105.6, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -188.05, + "left": 115.2, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": -178.45, + "left": 201.6, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": -188.05, + "left": 192, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "mpu6050 6-axis accel & gyro sensor1:VCC", + "arduino uno1:5V", + "red", + [ + "v-57.6", + "h-95.92" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:GND", + "arduino uno1:GND.2", + "black", + [ + "v-67.2", + "h-76.72" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SCL", + "arduino uno1:A5", + "green", + [ + "v-76.8", + "h19.28" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SDA", + "arduino uno1:A4", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:E", + "resistor2:2", + "green", + [ + "v0" + ] + ], + [ + "resistor1:2", + "7-segment display1:D", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:C", + "resistor4:1", + "green", + [ + "v0" + ] + ], + [ + "resistor3:1", + "7-segment display1:DP", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:G", + "resistor5:2", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:F", + "resistor6:2", + "green", + [ + "v0" + ] + ], + [ + "resistor8:1", + "7-segment display1:A", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:B", + "resistor7:1", + "green", + [ + "v0" + ] + ], + [ + "resistor8:2", + "arduino uno1:2", + "green", + [ + "v0" + ] + ], + [ + "resistor7:2", + "arduino uno1:3", + "green", + [ + "v0" + ] + ], + [ + "resistor4:2", + "arduino uno1:4", + "green", + [ + "v0" + ] + ], + [ + "resistor1:1", + "arduino uno1:5", + "green", + [ + "v48", + "h96" + ] + ], + [ + "resistor2:1", + "arduino uno1:6", + "green", + [ + "v48", + "h96" + ] + ], + [ + "resistor6:1", + "arduino uno1:7", + "green", + [ + "v0" + ] + ], + [ + "resistor5:1", + "arduino uno1:8", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:COM.1", + "arduino uno1:GND.2", + "green", + [ + "h0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level4/exercise_counter/diagram_breadboard.json b/arduino/level4/exercise_counter/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..78f6862d91c6ee3eb9309b29232f9b42062fab87 --- /dev/null +++ b/arduino/level4/exercise_counter/diagram_breadboard.json @@ -0,0 +1,473 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Motion counter that detects movement with an MPU6050 gyroscope and displays the count on a 1-digit 7-segment display", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -252.6, + "left": 60.4, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -9, + "left": 105, + "attrs": {} + }, + { + "type": "wokwi-mpu6050", + "id": "mpu6050 6-axis accel & gyro sensor1", + "top": -168.98, + "left": 347.92, + "attrs": { + "rotationY": "0" + } + }, + { + "type": "wokwi-7segment", + "id": "7-segment display1", + "top": -187.02, + "left": 216.28, + "attrs": { + "common": "cathode" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -101.65, + "left": 172.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -111.25, + "left": 163.2, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": -101.65, + "left": 249.6, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": -197.65, + "left": 163.2, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -207.25, + "left": 172.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": -197.65, + "left": 259.2, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": -207.25, + "left": 249.6, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "7-segment display1:COM.1", + "breadboard1:17b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:COM.2", + "breadboard1:17t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:A", + "breadboard1:18t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:B", + "breadboard1:19t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:C", + "breadboard1:18b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:D", + "breadboard1:16b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:E", + "breadboard1:15b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:F", + "breadboard1:16t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:G", + "breadboard1:15t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:DP", + "breadboard1:19b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor7:1", + "breadboard1:19t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor7:2", + "breadboard1:25t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor8:1", + "breadboard1:18t.a", + "", + [ + "$bb" + ] + ], + [ + "resistor8:2", + "breadboard1:24t.a", + "", + [ + "$bb" + ] + ], + [ + "resistor5:1", + "breadboard1:9t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor5:2", + "breadboard1:15t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor6:1", + "breadboard1:10t.a", + "", + [ + "$bb" + ] + ], + [ + "resistor6:2", + "breadboard1:16t.a", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:9b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:15b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:10b.j", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:16b.j", + "", + [ + "$bb" + ] + ], + [ + "resistor4:1", + "breadboard1:18b.j", + "", + [ + "$bb" + ] + ], + [ + "resistor4:2", + "breadboard1:24b.j", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:INT", + "breadboard1:29t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:AD0", + "breadboard1:30t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:XCL", + "breadboard1:31t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:XDA", + "breadboard1:32t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SDA", + "breadboard1:33t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SCL", + "breadboard1:34t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:GND", + "breadboard1:35t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:VCC", + "breadboard1:36t.e", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:17b.j", + "breadboard1:bn.13", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:24t.d", + "arduino uno1:2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:25t.d", + "arduino uno1:3", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:24b.h", + "arduino uno1:4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:10b.h", + "arduino uno1:5", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:9b.h", + "arduino uno1:6", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:10t.d", + "arduino uno1:7", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:9t.d", + "arduino uno1:8", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:36t.d", + "breadboard1:bp.30", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:35t.d", + "breadboard1:bn.28", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:34t.d", + "arduino uno1:A5", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:33t.d", + "arduino uno1:A4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:bn.1", + "arduino uno1:GND.2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:bp.1", + "arduino uno1:5V", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level4/exercise_counter/platformio.ini b/arduino/level4/exercise_counter/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..251035d4a40429903dcb9bf35bc3e0c86d1c8858 --- /dev/null +++ b/arduino/level4/exercise_counter/platformio.ini @@ -0,0 +1,21 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + MPU6050 \ No newline at end of file diff --git a/arduino/level4/exercise_counter/scenario.yaml b/arduino/level4/exercise_counter/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..16469ac3663ea0300868d2ec59fb1fc177c44c52 --- /dev/null +++ b/arduino/level4/exercise_counter/scenario.yaml @@ -0,0 +1,222 @@ +author: Blind Author +description: Motion counter that detects movement with an MPU6050 gyroscope and displays + the count on a 1-digit 7-segment display +name: Exercise Counter +test-values: +- part-type: wokwi-7segment + attr-name: common + value: cathode +- part-type: wokwi-mpu6050 + attr-name: rotationY + value: '0' +steps: +- delay: 100ms +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: 7-segment display1 + pin: COM + value: 0 + - part-id: 7-segment display1 + pin: A + value: 1 + - part-id: 7-segment display1 + pin: B + value: 1 + - part-id: 7-segment display1 + pin: C + value: 1 + - part-id: 7-segment display1 + pin: D + value: 1 + - part-id: 7-segment display1 + pin: E + value: 1 + - part-id: 7-segment display1 + pin: F + value: 1 + - part-id: 7-segment display1 + pin: G + value: 0 +- set-control: + part-id: mpu6050 6-axis accel & gyro sensor1 + control: accelY + value: 1.8 +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: 7-segment display1 + pin: COM + value: 0 + - part-id: 7-segment display1 + pin: A + value: 1 + - part-id: 7-segment display1 + pin: B + value: 1 + - part-id: 7-segment display1 + pin: C + value: 1 + - part-id: 7-segment display1 + pin: D + value: 1 + - part-id: 7-segment display1 + pin: E + value: 1 + - part-id: 7-segment display1 + pin: F + value: 1 + - part-id: 7-segment display1 + pin: G + value: 0 +- set-control: + part-id: mpu6050 6-axis accel & gyro sensor1 + control: rotationY + value: 130 +- delay: 500ms +- set-control: + part-id: mpu6050 6-axis accel & gyro sensor1 + control: rotationY + value: 0 +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: 7-segment display1 + pin: COM + value: 0 + - part-id: 7-segment display1 + pin: A + value: 0 + - part-id: 7-segment display1 + pin: B + value: 1 + - part-id: 7-segment display1 + pin: C + value: 1 + - part-id: 7-segment display1 + pin: D + value: 0 + - part-id: 7-segment display1 + pin: E + value: 0 + - part-id: 7-segment display1 + pin: F + value: 0 + - part-id: 7-segment display1 + pin: G + value: 0 +- set-control: + part-id: mpu6050 6-axis accel & gyro sensor1 + control: rotationY + value: 80 +- delay: 500ms +- set-control: + part-id: mpu6050 6-axis accel & gyro sensor1 + control: rotationY + value: 0 +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: 7-segment display1 + pin: COM + value: 0 + - part-id: 7-segment display1 + pin: A + value: 0 + - part-id: 7-segment display1 + pin: B + value: 1 + - part-id: 7-segment display1 + pin: C + value: 1 + - part-id: 7-segment display1 + pin: D + value: 0 + - part-id: 7-segment display1 + pin: E + value: 0 + - part-id: 7-segment display1 + pin: F + value: 0 + - part-id: 7-segment display1 + pin: G + value: 0 +- set-control: + part-id: mpu6050 6-axis accel & gyro sensor1 + control: rotationY + value: 150 +- delay: 500ms +- set-control: + part-id: mpu6050 6-axis accel & gyro sensor1 + control: rotationY + value: 0 +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: 7-segment display1 + pin: COM + value: 0 + - part-id: 7-segment display1 + pin: A + value: 1 + - part-id: 7-segment display1 + pin: B + value: 1 + - part-id: 7-segment display1 + pin: C + value: 0 + - part-id: 7-segment display1 + pin: D + value: 1 + - part-id: 7-segment display1 + pin: E + value: 1 + - part-id: 7-segment display1 + pin: F + value: 0 + - part-id: 7-segment display1 + pin: G + value: 1 +- set-control: + part-id: mpu6050 6-axis accel & gyro sensor1 + control: rotationY + value: 180 +- delay: 500ms +- set-control: + part-id: mpu6050 6-axis accel & gyro sensor1 + control: rotationY + value: 0 +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: 7-segment display1 + pin: COM + value: 0 + - part-id: 7-segment display1 + pin: A + value: 1 + - part-id: 7-segment display1 + pin: B + value: 1 + - part-id: 7-segment display1 + pin: C + value: 1 + - part-id: 7-segment display1 + pin: D + value: 1 + - part-id: 7-segment display1 + pin: E + value: 0 + - part-id: 7-segment display1 + pin: F + value: 0 + - part-id: 7-segment display1 + pin: G + value: 1 +version: 1.0 diff --git a/arduino/level4/exercise_counter/src/main.ino b/arduino/level4/exercise_counter/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..01b485e9bca52febea2b7ee8217459fb2bffe8dd --- /dev/null +++ b/arduino/level4/exercise_counter/src/main.ino @@ -0,0 +1,67 @@ +/** + Motion counter that detects movement with an MPU6050 gyroscope and displays the count on a 1-digit 7-segment display + 03 MAY 2025 by Blind Author +*/ + +#include +#include + +MPU6050 mpu; + +int count = 0; +bool moved = false; + +const int segmentPins[7] = {2, 3, 4, 5, 6, 7, 8}; + +const byte digits[10][7] = { + {1,1,1,1,1,1,0}, + {0,1,1,0,0,0,0}, + {1,1,0,1,1,0,1}, + {1,1,1,1,0,0,1}, + {0,1,1,0,0,1,1}, + {1,0,1,1,1,1,1}, + {1,1,1,0,0,0,0}, + {1,1,1,1,1,1,1}, + {1,1,1,1,0,1,1} +}; + +void setup() { + Wire.begin(); + mpu.initialize(); + + for (int i = 0; i < 7; i++) { + pinMode(segmentPins[i], OUTPUT); + } + + if (!mpu.testConnection()) { + Serial.println("MPU6050 failed!"); + while (1); + } + + displayDigit(0); +} + +void loop() { + int16_t gx, gy, gz; + mpu.getRotation(&gx, &gy, &gz); + + if (abs(gy) > 15000 && !moved) { + count++; + if (count > 9999) count = 0; + + displayDigit(count % 10); + moved = true; + } + + if (abs(gy) < 2000) { + moved = false; + } + + delay(50); +} + +void displayDigit(int num) { + for (int i = 0; i < 7; i++) { + digitalWrite(segmentPins[i], digits[num][i]); + } +} diff --git a/arduino/level4/exercise_counter/wokwi.toml b/arduino/level4/exercise_counter/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level4/exercise_counter/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level4/multiple_timezone/description.md b/arduino/level4/multiple_timezone/description.md new file mode 100644 index 0000000000000000000000000000000000000000..13e1290378a79c1e2a2fad1c56dae0ab84ee1253 --- /dev/null +++ b/arduino/level4/multiple_timezone/description.md @@ -0,0 +1,39 @@ +# Button RTC multiple timezone + +## Project Description +This is a Arduino project that different timestamps with a RTC module. + +## Hardware Components +- Arduino Uno +- Push Button * 4 +- 10kΩ resistor * 4 +- RTC module + +## Circuit Description +The RTC module is connected to the Arduino. The VCC pin is connected to 5V, the GND pin to gnd3, the SDA pin to A4, and the SCL pin to A5. There are four buttons: Button 1 is connected to Arduino pin2, button 2 is connected to pin3, button 3 is connected to pin4, and button 4 is connected to pin5. + +## Expected Behavior +When the Arduino powers up, it should: +1. Configure the button pin as an input +2. Initialize the serial monitor +3. Check if the RTC module is available and initialize it +4. Continuously retrieve the current time from the RTC +5. Check the state of buttons, and apply the corresponding timezone: Button 1 sets UTC+9, button 2 sets UTC+4, button 3 sets UTC-10, and button 4 sets UTC-5 +6. Print the resulting timestamp + +## Success Criteria +The test is successful when: +1. The UTC timestamp is printed when the button is not pressed +2. The UTC+9 timestamp is printed when the button 1 is pressed +3. The UTC+4 timestamp is printed when the button 2 is pressed +4. The UTC-10 timestamp is printed when the button 3 is pressed +5. The UTC-5 timestamp is printed when the button 4 is pressed + +## Notes for Implementation +- The button input will read HIGH when pressed. +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. +- Set the button ID corresponding to the button name, e.g., "push button1" for Button 1. +- The format of timestamp is YYYY-MM-DDTHH:MM:SS. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level4/multiple_timezone/description_no_pin.md b/arduino/level4/multiple_timezone/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..ae95ebe21ff05f4f8c3a7d0628568d1a47be65f9 --- /dev/null +++ b/arduino/level4/multiple_timezone/description_no_pin.md @@ -0,0 +1,39 @@ +# Button RTC multiple timezone + +## Project Description +This is a Arduino project that different timestamps with a RTC module. + +## Hardware Components +- Arduino Uno +- Push Button * 4 +- 10kΩ resistor * 4 +- RTC module + +## Circuit Description +The RTC module is connected to the Arduino, following the standard wiring conventions defined by the I2C protocol. Button 1 to button 4 are connected to arduino digital pins through 10kΩ resistor. Buttons use a pull-down resistor configuration. + +## Expected Behavior +When the Arduino powers up, it should: +1. Configure the button pin as an input +2. Initialize the serial monitor +3. Check if the RTC module is available and initialize it +4. Continuously retrieve the current time from the RTC +5. Check the state of buttons, and apply the corresponding timezone: Button 1 sets UTC+9, button 2 sets UTC+4, button 3 sets UTC-10, and button 4 sets UTC-5 +6. Print the resulting timestamp + +## Success Criteria +The test is successful when: +1. The UTC timestamp is printed when the button is not pressed +2. The UTC+9 timestamp is printed when the button 1 is pressed +3. The UTC+4 timestamp is printed when the button 2 is pressed +4. The UTC-10 timestamp is printed when the button 3 is pressed +5. The UTC-5 timestamp is printed when the button 4 is pressed + +## Notes for Implementation +- The button input will read HIGH when pressed. +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. +- Set the button ID corresponding to the button name, e.g., "push button1" for Button 1. +- The format of timestamp is YYYY-MM-DDTHH:MM:SS. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level4/multiple_timezone/diagram.json b/arduino/level4/multiple_timezone/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..d854df644f7afb2c9d4a59a879632a801458d7b1 --- /dev/null +++ b/arduino/level4/multiple_timezone/diagram.json @@ -0,0 +1,298 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Get the current time using an RTC sensor, and change into different timezones with button.", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-ds1307", + "id": "rtc module1", + "top": 244.2, + "left": 278.5, + "attrs": { + "initTime": "2024-11-24T04:48:00" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -125.4, + "left": 108.6, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -177.6, + "left": 124.25, + "rotate": 90, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button2", + "top": -125.4, + "left": 166.2, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button3", + "top": -125.4, + "left": 281.4, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button4", + "top": -125.4, + "left": 223.8, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -177.6, + "left": 181.85, + "rotate": 90, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -177.6, + "left": 297.05, + "rotate": 90, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": -177.6, + "left": 239.45, + "rotate": 90, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "rtc module1:SCL", + "arduino uno1:A5", + "green", + [ + "h0" + ] + ], + [ + "rtc module1:SDA", + "arduino uno1:A4", + "green", + [ + "h0" + ] + ], + [ + "rtc module1:5V", + "arduino uno1:5V", + "red", + [ + "h0" + ] + ], + [ + "rtc module1:GND", + "arduino uno1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "push button4:1.l", + "resistor1:2", + "green", + [ + "v0" + ] + ], + [ + "push button3:1.l", + "resistor2:2", + "green", + [ + "v0" + ] + ], + [ + "push button2:1.l", + "resistor4:2", + "green", + [ + "v0" + ] + ], + [ + "push button1:1.l", + "resistor3:2", + "green", + [ + "v0" + ] + ], + [ + "push button4:1.r", + "arduino uno1:5", + "green", + [ + "v0" + ] + ], + [ + "push button3:1.r", + "arduino uno1:4", + "green", + [ + "v0" + ] + ], + [ + "push button2:1.r", + "arduino uno1:3", + "green", + [ + "v57.8", + "h-38.4" + ] + ], + [ + "push button1:1.r", + "arduino uno1:2", + "green", + [ + "v0" + ] + ], + [ + "resistor1:1", + "arduino uno1:GND.2", + "green", + [ + "h0", + "v-9.6", + "h201.6", + "v384", + "h-182.4" + ] + ], + [ + "resistor2:1", + "arduino uno1:GND.2", + "green", + [ + "h0", + "v-9.6", + "h144", + "v384", + "h-182.4" + ] + ], + [ + "resistor4:1", + "arduino uno1:GND.2", + "green", + [ + "h0", + "v-9.6", + "h86.4", + "v384", + "h-192" + ] + ], + [ + "resistor3:1", + "arduino uno1:GND.2", + "green", + [ + "h0", + "v-9.6", + "h28.8", + "v384", + "h-182.4" + ] + ], + [ + "push button1:2.l", + "arduino uno1:5V", + "green", + [ + "v-9.6", + "h-173", + "v316.8", + "h192" + ] + ], + [ + "push button2:2.l", + "arduino uno1:5V", + "green", + [ + "v-19.2", + "h-230.6", + "v326.4", + "h192" + ] + ], + [ + "push button4:2.l", + "arduino uno1:5V", + "green", + [ + "v-19.2", + "h-288.2", + "v326.4", + "h192" + ] + ], + [ + "push button3:2.l", + "arduino uno1:5V", + "green", + [ + "v-19.2", + "h-345.8", + "v326.4", + "h192" + ] + ] + ] +} \ No newline at end of file diff --git a/arduino/level4/multiple_timezone/diagram_breadboard.json b/arduino/level4/multiple_timezone/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..952dca329bacd411954506e8ce129e3d6b87ead3 --- /dev/null +++ b/arduino/level4/multiple_timezone/diagram_breadboard.json @@ -0,0 +1,498 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Get the current time using an RTC sensor, and change into different timezone", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -22.2, + "left": 290.8, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-ds1307", + "id": "rtc module1", + "top": 24.1, + "left": 803.6, + "rotate": 270, + "attrs": { + "initTime": "2024-11-24T04:48:00" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": 47.4, + "left": 348.6, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 109.55, + "left": 316.8, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button2", + "top": 47.4, + "left": 444.6, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button3", + "top": 47.4, + "left": 540.6, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button4", + "top": 47.4, + "left": 636.6, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": 109.55, + "left": 412.8, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 109.55, + "left": 508.8, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 109.55, + "left": 604.8, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "breadboard1:bn.1", + "arduino uno1:GND.3", + "green", + [ + "v46.7", + "h-164" + ] + ], + [ + "breadboard1:bp.1", + "arduino uno1:5V", + "green", + [ + "v8.7", + "h-173.6" + ] + ], + [ + "rtc module1:GND", + "breadboard1:54b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:5V", + "breadboard1:55b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:SDA", + "breadboard1:56b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:SCL", + "breadboard1:57b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:SQW", + "breadboard1:58b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:1b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:7b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:11b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:17b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:21b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:27b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor4:1", + "breadboard1:31b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor4:2", + "breadboard1:37b.h", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:1b.i", + "breadboard1:bn.2", + "green", + [ + "v19.2", + "h28.8" + ] + ], + [ + "breadboard1:11b.i", + "breadboard1:bn.8", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:21b.i", + "breadboard1:bn.16", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:31b.i", + "breadboard1:bn.25", + "green", + [ + "v0" + ] + ], + [ + "push button1:1.l", + "breadboard1:9t.b", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.l", + "breadboard1:7t.b", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.r", + "breadboard1:9b.g", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.r", + "breadboard1:7b.g", + "", + [ + "$bb" + ] + ], + [ + "push button2:1.l", + "breadboard1:19t.b", + "", + [ + "$bb" + ] + ], + [ + "push button2:2.l", + "breadboard1:17t.b", + "", + [ + "$bb" + ] + ], + [ + "push button2:1.r", + "breadboard1:19b.g", + "", + [ + "$bb" + ] + ], + [ + "push button2:2.r", + "breadboard1:17b.g", + "", + [ + "$bb" + ] + ], + [ + "push button3:1.l", + "breadboard1:29t.b", + "", + [ + "$bb" + ] + ], + [ + "push button3:2.l", + "breadboard1:27t.b", + "", + [ + "$bb" + ] + ], + [ + "push button3:1.r", + "breadboard1:29b.g", + "", + [ + "$bb" + ] + ], + [ + "push button3:2.r", + "breadboard1:27b.g", + "", + [ + "$bb" + ] + ], + [ + "push button4:1.l", + "breadboard1:39t.b", + "", + [ + "$bb" + ] + ], + [ + "push button4:2.l", + "breadboard1:37t.b", + "", + [ + "$bb" + ] + ], + [ + "push button4:1.r", + "breadboard1:39b.g", + "", + [ + "$bb" + ] + ], + [ + "push button4:2.r", + "breadboard1:37b.g", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:9b.h", + "breadboard1:bp.6", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:19b.h", + "breadboard1:bp.15", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:29b.h", + "breadboard1:bp.23", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:39b.h", + "breadboard1:bp.31", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:7t.a", + "arduino uno1:2", + "green", + [ + "v-57.6", + "h-144" + ] + ], + [ + "breadboard1:17t.a", + "arduino uno1:3", + "green", + [ + "v-67.2", + "h-249.6" + ] + ], + [ + "breadboard1:27t.a", + "arduino uno1:4", + "green", + [ + "v-76.8", + "h-345.6" + ] + ], + [ + "breadboard1:37t.a", + "arduino uno1:5", + "green", + [ + "v-86.4", + "h-451.2" + ] + ], + [ + "breadboard1:57b.i", + "arduino uno1:A5", + "green", + [ + "v115.2", + "h-595.2" + ] + ], + [ + "breadboard1:56b.i", + "arduino uno1:A4", + "green", + [ + "v105.6", + "h-595.2" + ] + ], + [ + "breadboard1:55b.i", + "breadboard1:bp.45", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:54b.i", + "breadboard1:bn.44", + "green", + [ + "v0" + ] + ] + ] +} \ No newline at end of file diff --git a/arduino/level4/multiple_timezone/platformio.ini b/arduino/level4/multiple_timezone/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..df4b80305bbe895d07c0f1c0e74b60a1d2862746 --- /dev/null +++ b/arduino/level4/multiple_timezone/platformio.ini @@ -0,0 +1,21 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + RTClib \ No newline at end of file diff --git a/arduino/level4/multiple_timezone/scenario.yaml b/arduino/level4/multiple_timezone/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..af4eceefbd6d93b58222d1b1899e3a44730360f3 --- /dev/null +++ b/arduino/level4/multiple_timezone/scenario.yaml @@ -0,0 +1,43 @@ +author: Blind Author +description: Change timezone with button +name: Multiple Timezone +steps: +- delay: 100ms +- wait-serial: 2024-11-24T04:48 +- set-control: + control: pressed + part-id: push button1 + value: 1 +- wait-serial: 2024-11-24T13:48 +- set-control: + control: pressed + part-id: push button1 + value: 0 +- set-control: + control: pressed + part-id: push button2 + value: 1 +- wait-serial: 2024-11-24T08:48 +- set-control: + control: pressed + part-id: push button2 + value: 0 +- set-control: + control: pressed + part-id: push button3 + value: 1 +- wait-serial: 2024-11-23T18:48 +- set-control: + control: pressed + part-id: push button3 + value: 0 +- set-control: + control: pressed + part-id: push button4 + value: 1 +- wait-serial: 2024-11-23T23:48 +version: 1.0 +test-values: +- part-type: wokwi-ds1307 + attr-name: initTime + value: "2024-11-24T04:48:55" \ No newline at end of file diff --git a/arduino/level4/multiple_timezone/src/main.ino b/arduino/level4/multiple_timezone/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..c6c99c3d012f230f4a9c6c4b0b653d3a495ce9b1 --- /dev/null +++ b/arduino/level4/multiple_timezone/src/main.ino @@ -0,0 +1,41 @@ +/** + Press the button to change the timezone + 02 MAY 2025 by Blind Author +*/ + +#include "RTClib.h" + +RTC_DS1307 rtc; + +const int BUTTONS[4] = {2, 3, 4, 5}; +const int TIMEZONE[4] = {9, 4, -10, -5}; + +void setup () { + Serial.begin(115200); + + for (int i=0; i<4; i++) { + pinMode(BUTTONS[i], INPUT); + } + + if (! rtc.begin()) { + Serial.println("Couldn't find RTC"); + Serial.flush(); + abort(); + } +} + +void loop () { + DateTime now = rtc.now(); + + for (int i=0; i<4; i++) { + if (digitalRead(BUTTONS[i]) == HIGH) { + now = now + TimeSpan(0, TIMEZONE[i], 0, 0); + break; + } + } + + Serial.print(now.timestamp()); + + Serial.println(); + delay(500); +} diff --git a/arduino/level4/multiple_timezone/wokwi.toml b/arduino/level4/multiple_timezone/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level4/multiple_timezone/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level4/parking_spot_monitor/description.md b/arduino/level4/parking_spot_monitor/description.md new file mode 100644 index 0000000000000000000000000000000000000000..8878de63000869d3925baf6418a6362b8fff68cc --- /dev/null +++ b/arduino/level4/parking_spot_monitor/description.md @@ -0,0 +1,32 @@ +# Parking Spot Monitor + +## Project Description +This is an parking spot monitor project made with Arduino that detects vehicle presence using an ultrasonic sensor and shows the status with an RGB LED. + +## Hardware Components +- Arduino Uno +- 220Ω resistor * 3 +- RGB LED +- Ultrasonic Distance Sensor + +## Circuit Description +An ultrasonic distance sensor and a RGB led is connected to arduino uno. R, G, B pin of RGB led are connected to arduino pin4, pin3, pin2, through 220Ω resistor, respectively. COM pin of RGB led is connected to arduino gnd2. For ultrasonic distance sensor, GND and VCC pin are connected to arduino gnd2 and 5v, respectively. TRIG and ECHO pin is connected to pin8 and pin9. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set pin8, pin2 ~ pin4 as OUTPUT, and pin9 as INPUT +2. Continuously triger and read the distance sensor value +3. Calculate the distance +4. If distance is smaller than 50, turn on the red light of RGB led +5. If distance is greater than or equal to 50, turn on the green light of RGB led + +## Success Criteria +The test is successful when: +1. When the distance is smaller than 50, red light on the RGB led turned on. +2. When the distance is greater than or equal to 50, green light on the RGB led turned on. + +## Notes for Implementation +- To convert the distance sensor value to centimeters, divide it by 58. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level4/parking_spot_monitor/description_no_pin.md b/arduino/level4/parking_spot_monitor/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..2a584d1b6636b861083de87ae3ee89c5fd82ea7f --- /dev/null +++ b/arduino/level4/parking_spot_monitor/description_no_pin.md @@ -0,0 +1,32 @@ +# Parking Spot Monitor + +## Project Description +This is an parking spot monitor project made with Arduino that detects vehicle presence using an ultrasonic sensor and shows the status with an RGB LED. + +## Hardware Components +- Arduino Uno +- 220Ω resistor * 3 +- RGB LED +- Ultrasonic Distance Sensor + +## Circuit Description +An ultrasonic distance sensor and a RGB led is connected to arduino uno. R, G, B pin of RGB led are connected to arduino digital pins through 220Ω resistor. RGB LED uses common cathode configuration. For ultrasonic distance sensor, TRIG and ECHO pin is connected to arduino digital pins. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set RGB LED pins and TRIG pin as OUTPUT, and ECHO as INPUT +2. Continuously triger and read the distance sensor value +3. Calculate the distance +4. If distance is smaller than 50, turn on the red light of RGB led +5. If distance is greater than or equal to 50, turn on the green light of RGB led + +## Success Criteria +The test is successful when: +1. When the distance is smaller than 50, red light on the RGB led turned on. +2. When the distance is greater than or equal to 50, green light on the RGB led turned on. + +## Notes for Implementation +- To convert the distance sensor value to centimeters, divide it by 58. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level4/parking_spot_monitor/diagram.json b/arduino/level4/parking_spot_monitor/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..5568aaa0a42ab4b773fb175d2a1fb9f91e2b47fa --- /dev/null +++ b/arduino/level4/parking_spot_monitor/diagram.json @@ -0,0 +1,156 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Detects vehicle presence using an ultrasonic sensor and shows the status with an RGB LED", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -9, + "left": 105, + "attrs": {} + }, + { + "type": "wokwi-rgb-led", + "id": "rgb led1", + "top": -236, + "left": 327.5, + "attrs": { + "common": "cathode" + } + }, + { + "type": "wokwi-hc-sr04", + "id": "ultrasonic distance sensor1", + "top": -200.1, + "left": 111.1, + "attrs": { + "distance": "200" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -158.4, + "left": 306.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -158.4, + "left": 325.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -158.4, + "left": 335.45, + "rotate": 90, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "rgb led1:COM", + "arduino uno1:GND.2", + "green", + [ + "v76.4", + "h48.1", + "v249.6", + "h-115.2" + ] + ], + [ + "rgb led1:R", + "resistor1:1", + "green", + [ + "v0" + ] + ], + [ + "resistor2:1", + "rgb led1:G", + "green", + [ + "h0" + ] + ], + [ + "rgb led1:B", + "resistor3:1", + "green", + [ + "v0" + ] + ], + [ + "resistor3:2", + "arduino uno1:2", + "green", + [ + "h0" + ] + ], + [ + "resistor2:2", + "arduino uno1:3", + "green", + [ + "h0" + ] + ], + [ + "resistor1:2", + "arduino uno1:4", + "green", + [ + "h0" + ] + ], + [ + "ultrasonic distance sensor1:GND", + "arduino uno1:GND.2", + "black", + [ + "v0" + ] + ], + [ + "ultrasonic distance sensor1:VCC", + "arduino uno1:5V", + "red", + [ + "v0" + ] + ], + [ + "ultrasonic distance sensor1:TRIG", + "arduino uno1:8", + "green", + [ + "v0" + ] + ], + [ + "ultrasonic distance sensor1:ECHO", + "arduino uno1:9", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level4/parking_spot_monitor/diagram_breadboard.json b/arduino/level4/parking_spot_monitor/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..9f48a626f050894d2670ccb2afa165d44bf1bf35 --- /dev/null +++ b/arduino/level4/parking_spot_monitor/diagram_breadboard.json @@ -0,0 +1,267 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Detects vehicle presence using an ultrasonic sensor and shows the status with an RGB LED", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -271.8, + "left": 70, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -9, + "left": 105, + "attrs": {} + }, + { + "type": "wokwi-rgb-led", + "id": "rgb led1", + "top": -255.2, + "left": 375.5, + "attrs": { + "common": "cathode" + } + }, + { + "type": "wokwi-hc-sr04", + "id": "ultrasonic distance sensor1", + "top": -228.9, + "left": 159.1, + "attrs": { + "distance": "277" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -168, + "left": 354.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -168, + "left": 373.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -168, + "left": 383.45, + "rotate": 90, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "resistor3:1", + "breadboard1:34t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:34b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:33t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:33b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:31t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:31b.h", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:VCC", + "breadboard1:15b.h", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:TRIG", + "breadboard1:16b.h", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:ECHO", + "breadboard1:17b.h", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:GND", + "breadboard1:18b.h", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:R", + "breadboard1:31t.b", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:COM", + "breadboard1:32t.c", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:G", + "breadboard1:33t.b", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:B", + "breadboard1:34t.b", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:32t.e", + "breadboard1:bn.26", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:34b.i", + "arduino uno1:2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:33b.i", + "arduino uno1:3", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:31b.i", + "arduino uno1:4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:18b.i", + "breadboard1:bn.14", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:15b.i", + "breadboard1:bp.11", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:16b.i", + "arduino uno1:8", + "green", + [ + "v105.6", + "h38.4" + ] + ], + [ + "breadboard1:17b.i", + "arduino uno1:9", + "green", + [ + "v115.2", + "h19.2" + ] + ], + [ + "breadboard1:bp.1", + "arduino uno1:5V", + "green", + [ + "v315.9", + "h152.8" + ] + ], + [ + "breadboard1:bn.1", + "arduino uno1:GND.2", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level4/parking_spot_monitor/platformio.ini b/arduino/level4/parking_spot_monitor/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level4/parking_spot_monitor/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level4/parking_spot_monitor/scenario.yaml b/arduino/level4/parking_spot_monitor/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..da465f2bdb16db19cf8db532427f5ab222152ebb --- /dev/null +++ b/arduino/level4/parking_spot_monitor/scenario.yaml @@ -0,0 +1,95 @@ +author: Blind Author +description: Detects vehicle presence using an ultrasonic sensor and shows the status + with an RGB LED +name: Parking Spot Monitor +test-values: + - part-type: wokwi-rgb-led + attr-name: common + value: "cathode" +steps: +- delay: 100ms +- set-control: + control: distance + part-id: ultrasonic distance sensor1 + value: 300 +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: rgb led1 + pin: R + value: 0 + - part-id: rgb led1 + pin: G + value: 1 + - part-id: rgb led1 + pin: B + value: 0 + - part-id: rgb led1 + pin: COM + value: 0 +- set-control: + control: distance + part-id: ultrasonic distance sensor1 + value: 60 +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: rgb led1 + pin: R + value: 0 + - part-id: rgb led1 + pin: G + value: 1 + - part-id: rgb led1 + pin: B + value: 0 + - part-id: rgb led1 + pin: COM + value: 0 +- set-control: + control: distance + part-id: ultrasonic distance sensor1 + value: 40 +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: rgb led1 + pin: R + value: 1 + - part-id: rgb led1 + pin: G + value: 0 + - part-id: rgb led1 + pin: B + value: 0 + - part-id: rgb led1 + pin: COM + value: 0 +- set-control: + control: distance + part-id: ultrasonic distance sensor1 + value: 10 +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: rgb led1 + pin: R + value: 1 + - part-id: rgb led1 + pin: G + value: 0 + - part-id: rgb led1 + pin: B + value: 0 + - part-id: rgb led1 + pin: COM + value: 0 +version: 1.0 diff --git a/arduino/level4/parking_spot_monitor/src/main.ino b/arduino/level4/parking_spot_monitor/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..7b310b766a771e7335e84e79c2fd00f94443fe34 --- /dev/null +++ b/arduino/level4/parking_spot_monitor/src/main.ino @@ -0,0 +1,46 @@ +/** + Detects vehicle presence using an ultrasonic sensor and shows the status with an RGB LED + 09 MAY 2025 by Blind Author +*/ + +const int trigPin = 8; +const int echoPin = 9; + +const int redPin = 4; +const int greenPin = 3; +const int bluePin = 2; + +long duration; +int distance; + +void setup() { + pinMode(trigPin, OUTPUT); + pinMode(echoPin, INPUT); + pinMode(redPin, OUTPUT); + pinMode(greenPin, OUTPUT); + pinMode(bluePin, OUTPUT); +} + +void loop() { + digitalWrite(trigPin, LOW); + delayMicroseconds(2); + digitalWrite(trigPin, HIGH); + delayMicroseconds(10); + digitalWrite(trigPin, LOW); + + duration = pulseIn(echoPin, HIGH); + distance = duration / 58; + + if (distance < 50) { + digitalWrite(redPin, HIGH); + digitalWrite(greenPin, LOW); + digitalWrite(bluePin, LOW); + } + else { + digitalWrite(redPin, LOW); + digitalWrite(greenPin, HIGH); + digitalWrite(bluePin, LOW); + } + + delay(500); +} diff --git a/arduino/level4/parking_spot_monitor/wokwi.toml b/arduino/level4/parking_spot_monitor/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level4/parking_spot_monitor/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level4/piano_keyboard/description.md b/arduino/level4/piano_keyboard/description.md new file mode 100644 index 0000000000000000000000000000000000000000..c41ef5b01a7ec5293a798e5f6aaaa7f4188903ab --- /dev/null +++ b/arduino/level4/piano_keyboard/description.md @@ -0,0 +1,34 @@ +# Piano Keyboard + +## Project Description +This is an Arduino project that creates a piano keyboard using four push buttons and four buzzers corresponding to the notes Do, Re, Mi, and Fa. + +## Hardware Components +- Arduino Uno +- Push Button * 4 +- 10kΩ resistor * 4 +- Piezoelectric Buzzer * 4 + +## Circuit Description +Four piezo buzzers and four push buttons are connected to an Arduino Uno. Button 1 and Buzzer 1 correspond to the note Do, Button 2 and Buzzer 2 to Re, Button 3 and Buzzer 3 to Mi, and Button 4 and Buzzer 4 to Fa. Buttons 1 through 4 are connected to Arduino pins 2, 3, 4, and 5, respectively. When the button is not pressed, the input pin is connected to gnd3 through a 10kΩ resistor. When the button is pressed, the input pin is connected to 5v. +The positive pins of the buzzers are connected to Arduino pins 9, 10, 11, and 12, respectively, and their negative pins are connected to gnd3. + +## Expected Behavior +When the Arduino powers up, it should: +1. Configure button pins as INPUT +2. Configure buzzer pins as OUTPUT +3. Continuously monitor the button state, and if it reads HIGH, play a tone on the corresponding buzzer +4. If no button is pressed, keep all buzzers silent + +## Success Criteria +The test is successful when: +1. The buzzer plays a tone when the corresponding button is pressed. + +## Notes for Implementation +- The button input will read HIGH when it is pressed. +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. +- The frequencies of Do, Re, Mi, and Fa are 262 Hz, 294 Hz, 330 Hz, and 349 Hz, respectively. +- Only one button is pressed at a time. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level4/piano_keyboard/description_no_pin.md b/arduino/level4/piano_keyboard/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..baca7b6944d3a9dd7895218f3b1331194065cb25 --- /dev/null +++ b/arduino/level4/piano_keyboard/description_no_pin.md @@ -0,0 +1,34 @@ +# Piano Keyboard + +## Project Description +This is an Arduino project that creates a piano keyboard using four push buttons and four buzzers corresponding to the notes Do, Re, Mi, and Fa. + +## Hardware Components +- Arduino Uno +- Push Button * 4 +- 10kΩ resistor * 4 +- Piezoelectric Buzzer * 4 + +## Circuit Description +Four piezo buzzers and four push buttons are connected to an Arduino Uno. Button 1 and Buzzer 1 correspond to the note Do, Button 2 and Buzzer 2 to Re, Button 3 and Buzzer 3 to Mi, and Button 4 and Buzzer 4 to Fa. Buttons 1 through 4 are connected to Arduino digital pins and connected to ground through 10kΩ resistor. Buttons uses pull-down resistor configuration. +The positive pins of the buzzers are connected to Arduino digital pins. + +## Expected Behavior +When the Arduino powers up, it should: +1. Configure button pins as INPUT +2. Configure buzzer pins as OUTPUT +3. Continuously monitor the button state, and if it reads HIGH, play a tone on the corresponding buzzer +4. If no button is pressed, keep all buzzers silent + +## Success Criteria +The test is successful when: +1. The buzzer plays a tone when the corresponding button is pressed. + +## Notes for Implementation +- The button input will read HIGH when it is pressed. +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. +- The frequencies of Do, Re, Mi, and Fa are 262 Hz, 294 Hz, 330 Hz, and 349 Hz, respectively. +- Only one button is pressed at a time. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/arduino/level4/piano_keyboard/diagram.json b/arduino/level4/piano_keyboard/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..eafd5c827294a7e7debcc4486be488c000c5b20e --- /dev/null +++ b/arduino/level4/piano_keyboard/diagram.json @@ -0,0 +1,363 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Piano Keyboard", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 48.6, + "left": -87, + "attrs": {} + }, + { + "type": "wokwi-buzzer", + "id": "piezoelectric buzzer1", + "top": -132, + "left": 78.6, + "attrs": { + "volume": "0.1" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": 169.4, + "left": 259.2, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button2", + "top": -32.2, + "left": 259.2, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button3", + "top": 102.2, + "left": 259.2, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button4", + "top": 35, + "left": 259.2, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -24.85, + "left": 364.8, + "attrs": { + "value": "1000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": 42.35, + "left": 364.8, + "attrs": { + "value": "1000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 109.55, + "left": 364.8, + "attrs": { + "value": "1000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 176.75, + "left": 364.8, + "attrs": { + "value": "1000" + } + }, + { + "type": "wokwi-buzzer", + "id": "piezoelectric buzzer2", + "top": -132, + "left": 1.8, + "attrs": { + "volume": "0.1" + } + }, + { + "type": "wokwi-buzzer", + "id": "piezoelectric buzzer3", + "top": -132, + "left": -75, + "attrs": { + "volume": "0.1" + } + }, + { + "type": "wokwi-buzzer", + "id": "piezoelectric buzzer4", + "top": -132, + "left": -151.8, + "attrs": { + "volume": "0.1" + } + } + ], + "connections": [ + [ + "push button1:1.l", + "arduino uno1:2", + "green", + [ + "h-67.2", + "v-144", + "h-48" + ] + ], + [ + "push button2:1.l", + "arduino uno1:3", + "green", + [ + "h-57.6", + "v-86.4", + "h-57.6" + ] + ], + [ + "push button3:1.l", + "arduino uno1:4", + "green", + [ + "h-48", + "v-28.8", + "h-76.8" + ] + ], + [ + "push button4:1.l", + "arduino uno1:5", + "green", + [ + "h0" + ] + ], + [ + "piezoelectric buzzer1:2", + "arduino uno1:9", + "green", + [ + "v86.4", + "h-39.6" + ] + ], + [ + "piezoelectric buzzer1:1", + "arduino uno1:GND.2", + "green", + [ + "v76.8", + "h-211.2", + "v240", + "h188.1" + ] + ], + [ + "piezoelectric buzzer2:2", + "arduino uno1:10", + "green", + [ + "v86.4", + "h28.4" + ] + ], + [ + "piezoelectric buzzer3:2", + "arduino uno1:11", + "green", + [ + "v57.6", + "h86" + ] + ], + [ + "piezoelectric buzzer4:2", + "arduino uno1:12", + "green", + [ + "v67.2", + "h162.8" + ] + ], + [ + "piezoelectric buzzer2:1", + "arduino uno1:GND.2", + "green", + [ + "v76.8", + "h-134.4", + "v240", + "h182.4" + ] + ], + [ + "piezoelectric buzzer3:1", + "arduino uno1:GND.2", + "green", + [ + "v76.8", + "h-57.6", + "v240", + "h192" + ] + ], + [ + "piezoelectric buzzer4:1", + "arduino uno1:GND.2", + "green", + [ + "v76.8", + "h19.2", + "v240", + "h182.4" + ] + ], + [ + "push button2:1.r", + "resistor1:1", + "green", + [ + "v0" + ] + ], + [ + "push button4:1.r", + "resistor2:1", + "green", + [ + "v0" + ] + ], + [ + "push button3:1.r", + "resistor3:1", + "green", + [ + "v0" + ] + ], + [ + "push button1:1.r", + "resistor4:1", + "green", + [ + "v0" + ] + ], + [ + "resistor1:2", + "arduino uno1:GND.2", + "green", + [ + "v0", + "h37.2", + "v288", + "h-384" + ] + ], + [ + "resistor2:2", + "arduino uno1:GND.2", + "green", + [ + "v0", + "h37.2", + "v220.8", + "h-374.4" + ] + ], + [ + "resistor3:2", + "arduino uno1:GND.2", + "green", + [ + "v0", + "h37.2", + "v153.6", + "h-384" + ] + ], + [ + "resistor4:2", + "arduino uno1:GND.2", + "green", + [ + "v0", + "h37.2", + "v86.4", + "h-374.4" + ] + ], + [ + "push button1:2.r", + "arduino uno1:5V", + "green", + [ + "h153.8", + "v86.6", + "h-28.8" + ] + ], + [ + "push button3:2.r", + "arduino uno1:5V", + "green", + [ + "h153.8", + "v153.8", + "h-403.2" + ] + ], + [ + "push button4:2.r", + "arduino uno1:5V", + "green", + [ + "h153.8", + "v221", + "h-403.2" + ] + ], + [ + "push button2:2.r", + "arduino uno1:5V", + "green", + [ + "h153.8", + "v288.2", + "h-403.2" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level4/piano_keyboard/diagram_breadboard.json b/arduino/level4/piano_keyboard/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..84476a691c8f95368f5cf7ec01ba6c7a665fbf0e --- /dev/null +++ b/arduino/level4/piano_keyboard/diagram_breadboard.json @@ -0,0 +1,564 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Piano Keyboard", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -195, + "left": -93.2, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 48.6, + "left": -87, + "attrs": {} + }, + { + "type": "wokwi-buzzer", + "id": "piezoelectric buzzer1", + "top": -141.6, + "left": 145.8, + "attrs": { + "volume": "0.1" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -125.4, + "left": 223.8, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button2", + "top": -125.4, + "left": 291, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button3", + "top": -125.4, + "left": 358.2, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button4", + "top": -125.4, + "left": 425.4, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -33.6, + "left": 220.25, + "rotate": 90, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-buzzer", + "id": "piezoelectric buzzer2", + "top": -141.6, + "left": 78.6, + "attrs": { + "volume": "0.1" + } + }, + { + "type": "wokwi-buzzer", + "id": "piezoelectric buzzer3", + "top": -141.6, + "left": 11.4, + "attrs": { + "volume": "0.1" + } + }, + { + "type": "wokwi-buzzer", + "id": "piezoelectric buzzer4", + "top": -141.6, + "left": -55.8, + "attrs": { + "volume": "0.1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -33.6, + "left": 287.45, + "rotate": 90, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -33.6, + "left": 354.65, + "rotate": 90, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": -33.6, + "left": 421.85, + "rotate": 90, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "breadboard1:5b.i", + "breadboard1:bn.3", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:12b.i", + "breadboard1:bn.9", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:19b.i", + "breadboard1:bn.15", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:26b.i", + "breadboard1:bn.21", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:27b.i", + "arduino uno1:9", + "green", + [ + "v76.8", + "h-105.6" + ] + ], + [ + "breadboard1:20b.i", + "arduino uno1:10", + "green", + [ + "v67.2", + "h-48" + ] + ], + [ + "breadboard1:13b.i", + "arduino uno1:11", + "green", + [ + "v67.2", + "h9.6" + ] + ], + [ + "breadboard1:6b.i", + "arduino uno1:12", + "green", + [ + "v76.8", + "h67.2" + ] + ], + [ + "breadboard1:34t.a", + "arduino uno1:2", + "green", + [ + "v-76.8", + "h-38.4", + "v268.8", + "h-57.6" + ] + ], + [ + "breadboard1:41t.a", + "arduino uno1:3", + "green", + [ + "v-76.8", + "h-38.4", + "v288", + "h-138.4" + ] + ], + [ + "breadboard1:48t.a", + "arduino uno1:4", + "green", + [ + "v-76.8", + "h-38.4", + "v297.6", + "h-211.2" + ] + ], + [ + "breadboard1:55t.a", + "arduino uno1:5", + "green", + [ + "v-76.8", + "h-38.4", + "v307.2", + "h-288" + ] + ], + [ + "breadboard1:bn.50", + "arduino uno1:GND.3", + "green", + [ + "v257.9", + "h-413.6" + ] + ], + [ + "breadboard1:36b.h", + "breadboard1:bp.29", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:43b.h", + "breadboard1:bp.35", + "green", + [ + "v0" + ] + ], + [ + "piezoelectric buzzer4:1", + "breadboard1:5b.h", + "", + [ + "$bb" + ] + ], + [ + "piezoelectric buzzer4:2", + "breadboard1:6b.h", + "", + [ + "$bb" + ] + ], + [ + "piezoelectric buzzer3:1", + "breadboard1:12b.h", + "", + [ + "$bb" + ] + ], + [ + "piezoelectric buzzer3:2", + "breadboard1:13b.h", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.l", + "breadboard1:36t.b", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.l", + "breadboard1:34t.b", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.r", + "breadboard1:36b.g", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.r", + "breadboard1:34b.g", + "", + [ + "$bb" + ] + ], + [ + "push button2:1.l", + "breadboard1:43t.b", + "", + [ + "$bb" + ] + ], + [ + "push button2:2.l", + "breadboard1:41t.b", + "", + [ + "$bb" + ] + ], + [ + "push button2:1.r", + "breadboard1:43b.g", + "", + [ + "$bb" + ] + ], + [ + "push button2:2.r", + "breadboard1:41b.g", + "", + [ + "$bb" + ] + ], + [ + "push button4:1.l", + "breadboard1:57t.b", + "", + [ + "$bb" + ] + ], + [ + "push button4:2.l", + "breadboard1:55t.b", + "", + [ + "$bb" + ] + ], + [ + "push button4:1.r", + "breadboard1:57b.g", + "", + [ + "$bb" + ] + ], + [ + "push button4:2.r", + "breadboard1:55b.g", + "", + [ + "$bb" + ] + ], + [ + "push button3:1.l", + "breadboard1:50t.b", + "", + [ + "$bb" + ] + ], + [ + "push button3:2.l", + "breadboard1:48t.b", + "", + [ + "$bb" + ] + ], + [ + "push button3:1.r", + "breadboard1:50b.g", + "", + [ + "$bb" + ] + ], + [ + "push button3:2.r", + "breadboard1:48b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:34b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:bn.27", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:41b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:bn.33", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:48b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:bn.39", + "", + [ + "$bb" + ] + ], + [ + "resistor4:1", + "breadboard1:55b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor4:2", + "breadboard1:bn.45", + "", + [ + "$bb" + ] + ], + [ + "piezoelectric buzzer2:1", + "breadboard1:19b.h", + "", + [ + "$bb" + ] + ], + [ + "piezoelectric buzzer2:2", + "breadboard1:20b.h", + "", + [ + "$bb" + ] + ], + [ + "piezoelectric buzzer1:1", + "breadboard1:26b.h", + "", + [ + "$bb" + ] + ], + [ + "piezoelectric buzzer1:2", + "breadboard1:27b.h", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:50b.h", + "breadboard1:bp.40", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:57b.h", + "breadboard1:bp.46", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:bp.50", + "arduino uno1:5V", + "green", + [ + "v-0.9", + "h8.8", + "v278.4", + "h-441.6" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level4/piano_keyboard/platformio.ini b/arduino/level4/piano_keyboard/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level4/piano_keyboard/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level4/piano_keyboard/scenario.yaml b/arduino/level4/piano_keyboard/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a6c7f80dce9909f5d6feb2bb1686a91955095bd0 --- /dev/null +++ b/arduino/level4/piano_keyboard/scenario.yaml @@ -0,0 +1,126 @@ +author: Blind Author +description: LED lights up when the button is pressed +name: Button LED +steps: +- delay: 100ms +- expect-pin: + part-id: piezoelectric buzzer1 + pin: 2 + value: 0 +- expect-pin: + part-id: piezoelectric buzzer2 + pin: 2 + value: 0 +- expect-pin: + part-id: piezoelectric buzzer3 + pin: 2 + value: 0 +- expect-pin: + part-id: piezoelectric buzzer4 + pin: 2 + value: 0 +- set-control: + part-id: push button1 + control: pressed + value: 1 +- delay: 100ms +- wait-pin: + timeout: 1000 + interval: 100 + part-id: piezoelectric buzzer1 + pin: 2 + value: 1 +- expect-pin: + part-id: piezoelectric buzzer2 + pin: 2 + value: 0 +- expect-pin: + part-id: piezoelectric buzzer3 + pin: 2 + value: 0 +- expect-pin: + part-id: piezoelectric buzzer4 + pin: 2 + value: 0 +- set-control: + part-id: push button1 + control: pressed + value: 0 +- set-control: + part-id: push button2 + control: pressed + value: 1 +- delay: 100ms +- expect-pin: + part-id: piezoelectric buzzer1 + pin: 2 + value: 0 +- wait-pin: + timeout: 1000 + interval: 100 + part-id: piezoelectric buzzer2 + pin: 2 + value: 1 +- expect-pin: + part-id: piezoelectric buzzer3 + pin: 2 + value: 0 +- expect-pin: + part-id: piezoelectric buzzer4 + pin: 2 + value: 0 +- set-control: + part-id: push button2 + control: pressed + value: 0 +- set-control: + part-id: push button3 + control: pressed + value: 1 +- delay: 100ms +- expect-pin: + part-id: piezoelectric buzzer1 + pin: 2 + value: 0 +- expect-pin: + part-id: piezoelectric buzzer2 + pin: 2 + value: 0 +- wait-pin: + timeout: 1000 + interval: 100 + part-id: piezoelectric buzzer3 + pin: 2 + value: 1 +- expect-pin: + part-id: piezoelectric buzzer4 + pin: 2 + value: 0 +- set-control: + part-id: push button3 + control: pressed + value: 0 +- set-control: + part-id: push button4 + control: pressed + value: 1 +- delay: 100ms +- expect-pin: + part-id: piezoelectric buzzer1 + pin: 2 + value: 0 +- expect-pin: + part-id: piezoelectric buzzer2 + pin: 2 + value: 0 +- expect-pin: + part-id: piezoelectric buzzer3 + pin: 2 + value: 0 +- wait-pin: + timeout: 1000 + interval: 100 + part-id: piezoelectric buzzer4 + pin: 2 + value: 1 +version: 1.0 diff --git a/arduino/level4/piano_keyboard/src/main.ino b/arduino/level4/piano_keyboard/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..4a64003da419b1b9db9adade0bb9aaadf547a425 --- /dev/null +++ b/arduino/level4/piano_keyboard/src/main.ino @@ -0,0 +1,34 @@ +/** + Creating a keyboard using push buttons and buzzers. + 02 MAY 2025 by Blind Author +*/ + +const int BUTTONS[4] = {2, 3, 4, 5}; +const int BUZZERS[4] = {9, 10, 11, 12}; +const int TONES[4] = {262, 294, 330, 349}; + +int lastPressed = -1; + +void setup() { + for (int i = 0; i < 4; i++) { + pinMode(BUTTONS[i], INPUT); + pinMode(BUZZERS[i], OUTPUT); + } +} + +void loop() { + int pressed = -1; + for (int i = 0; i < 4; i++) { + if (digitalRead(BUTTONS[i]) == HIGH) { + pressed = i; + break; + } + } + + if (pressed != lastPressed) { + if (lastPressed != -1) noTone(BUZZERS[lastPressed]); + if (pressed != -1) tone(BUZZERS[pressed], TONES[pressed]); + + lastPressed = pressed; + } +} diff --git a/arduino/level4/piano_keyboard/wokwi.toml b/arduino/level4/piano_keyboard/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level4/piano_keyboard/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level4/smart_led_system/description.md b/arduino/level4/smart_led_system/description.md new file mode 100644 index 0000000000000000000000000000000000000000..d0171b3dccb11530fb7f628743414d6ff3e05701 --- /dev/null +++ b/arduino/level4/smart_led_system/description.md @@ -0,0 +1,32 @@ +# Smart LED System + +## Project Description +This is an Arduino project for a smart LED system that turns on the LED when the brightness measured by the photoresistor is low. + +## Hardware Components +- Arduino Uno +- LED * 5 +- 220Ω resistor * 5 +- Photoresistor * 5 + +## Circuit Description +Five LEDs and five photoresistors are connected to an Arduino Uno board. LEDs 1 to 5 are connected to Arduino pins 2 to 6 through 220Ω resistors, respectively. The cathode of each LED is connected to GND2. The AO pins of photoresistors 1 to 5 are connected to Arduino analog pins A0 to A4, respectively. The GND and VCC pins of each photoresistor are connected to GND2 and 5V on the Arduino. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set pin2 to pin6 as OUTPUT, and A0 to A4 as INPUT +2. Continuously read the photoresistor 1 to 5 values +3. Check if the sensor value is greater than the threshold, which is 500 +4. If the sensor value is greater than the threshold, turn the corresponding LED on. + +## Success Criteria +The test is successful when: +1. Only the LEDs corresponding to the photoresistors that measure brightness lower than a threshold turn on. + +## Notes for Implementation +- Threshold is 500. +- Compare the analog sensor value with the threshold, not the value changed to lux. +- Photoresistor1 corresponse to led1, photoresistor2 to led2, and so on. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level4/smart_led_system/description_no_pin.md b/arduino/level4/smart_led_system/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..759970e482889ef63327f527c2ee624201e6a8b6 --- /dev/null +++ b/arduino/level4/smart_led_system/description_no_pin.md @@ -0,0 +1,32 @@ +# Smart LED System + +## Project Description +This is an Arduino project for a smart LED system that turns on the LED when the brightness measured by the photoresistor is low. + +## Hardware Components +- Arduino Uno +- LED * 5 +- 220Ω resistor * 5 +- Photoresistor * 5 + +## Circuit Description +Five LEDs and five photoresistors are connected to an Arduino Uno board. LEDs 1 to 5 are connected to Arduino digital pins through 220Ω resistor. The AO pins of photoresistors 1 to 5 are connected to Arduino analog pins. + +## Expected Behavior +When the Arduino powers up, it should: +1. Set led pins as OUTPUT, and photoresistor pins as INPUT +2. Continuously read the photoresistor 1 to 5 values +3. Check if the sensor value is greater than the threshold, which is 500 +4. If the sensor value is greater than the threshold, turn the corresponding LED on. + +## Success Criteria +The test is successful when: +1. Only the LEDs corresponding to the photoresistors that measure brightness lower than a threshold turn on. + +## Notes for Implementation +- Threshold is 500. +- Compare the analog sensor value with the threshold, not the value changed to lux. +- Photoresistor1 corresponse to led1, photoresistor2 to led2, and so on. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/arduino/level4/smart_led_system/diagram.json b/arduino/level4/smart_led_system/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..ef4d38ba7d8c27707a044f1d85ed85c5b1e4284d --- /dev/null +++ b/arduino/level4/smart_led_system/diagram.json @@ -0,0 +1,430 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Turn on the corresponding LED when the brightness detected by the photoresistor is lower", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor1", + "top": 342.5, + "left": -24.5, + "rotate": 270, + "attrs": { + "lux": "105" + } + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor2", + "top": 342.5, + "left": 52.3, + "rotate": 270, + "attrs": { + "lux": "20000" + } + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor3", + "top": 342.5, + "left": 129.1, + "rotate": 270, + "attrs": { + "lux": "600" + } + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor4", + "top": 342.5, + "left": 205.9, + "rotate": 270, + "attrs": { + "lux": "10" + } + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor5", + "top": 342.5, + "left": 282.7, + "rotate": 270, + "attrs": { + "lux": "1000" + } + }, + { + "type": "wokwi-led", + "id": "led1", + "top": -166.8, + "left": 243.8, + "attrs": { + "color": "red", + "flip": "" + } + }, + { + "type": "wokwi-led", + "id": "led2", + "top": -166.8, + "left": 128.6, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-led", + "id": "led3", + "top": -166.8, + "left": 157.4, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-led", + "id": "led4", + "top": -166.8, + "left": 186.2, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-led", + "id": "led5", + "top": -166.8, + "left": 215, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -91.2, + "left": 239.45, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -91.2, + "left": 210.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -91.2, + "left": 181.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": -91.2, + "left": 153.05, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": -91.2, + "left": 124.25, + "rotate": 90, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "photoresistor1:AO", + "arduino uno1:A0", + "green", + [ + "v-67.2", + "h133.7", + "v-38.4" + ] + ], + [ + "photoresistor2:AO", + "arduino uno1:A1", + "green", + [ + "v-57.6", + "h66.5" + ] + ], + [ + "photoresistor3:AO", + "arduino uno1:A2", + "green", + [ + "v0" + ] + ], + [ + "photoresistor4:AO", + "arduino uno1:A3", + "green", + [ + "v-67.2", + "h-67.9" + ] + ], + [ + "photoresistor5:AO", + "arduino uno1:A4", + "green", + [ + "v-76.8", + "h-135.1" + ] + ], + [ + "photoresistor1:VCC", + "arduino uno1:5V", + "red", + [ + "v-76.8", + "h115.2" + ] + ], + [ + "photoresistor2:VCC", + "arduino uno1:5V", + "red", + [ + "v-76.8", + "h38.4" + ] + ], + [ + "photoresistor3:VCC", + "arduino uno1:5V", + "red", + [ + "v-76.8", + "h-38.4" + ] + ], + [ + "photoresistor4:VCC", + "arduino uno1:5V", + "red", + [ + "v-76.8", + "h-115.2" + ] + ], + [ + "photoresistor5:VCC", + "arduino uno1:5V", + "red", + [ + "v-76.8", + "h-192" + ] + ], + [ + "photoresistor1:GND", + "arduino uno1:GND.2", + "black", + [ + "v-67.2", + "h114.8" + ] + ], + [ + "photoresistor2:GND", + "arduino uno1:GND.2", + "black", + [ + "v-67.2", + "h38" + ] + ], + [ + "photoresistor3:GND", + "arduino uno1:GND.2", + "black", + [ + "v-67.2", + "h-48.4" + ] + ], + [ + "photoresistor4:GND", + "arduino uno1:GND.2", + "black", + [ + "v-67.2", + "h-115.6" + ] + ], + [ + "photoresistor5:GND", + "arduino uno1:GND.2", + "black", + [ + "v-67.2", + "h-192.4" + ] + ], + [ + "led2:A", + "resistor5:1", + "green", + [ + "v0" + ] + ], + [ + "led3:A", + "resistor4:1", + "green", + [ + "v0" + ] + ], + [ + "led4:A", + "resistor3:1", + "green", + [ + "v0" + ] + ], + [ + "led5:A", + "resistor2:1", + "green", + [ + "v0" + ] + ], + [ + "led1:A", + "resistor1:1", + "green", + [ + "v0" + ] + ], + [ + "resistor1:2", + "arduino uno1:2", + "green", + [ + "h0", + "v46.8", + "h-38.4" + ] + ], + [ + "led2:C", + "arduino uno1:GND.2", + "black", + [ + "v259.2", + "h29.2" + ] + ], + [ + "led3:C", + "arduino uno1:GND.2", + "black", + [ + "v0" + ] + ], + [ + "led4:C", + "arduino uno1:GND.2", + "black", + [ + "v259.2", + "h-28.4" + ] + ], + [ + "led5:C", + "arduino uno1:GND.2", + "black", + [ + "v259.2", + "h-57.2" + ] + ], + [ + "led1:C", + "arduino uno1:GND.2", + "black", + [ + "v259.2", + "h-95.6" + ] + ], + [ + "resistor5:2", + "arduino uno1:3", + "green", + [ + "h0", + "v46.8", + "h76.8" + ] + ], + [ + "resistor4:2", + "arduino uno1:4", + "green", + [ + "h0", + "v46.8", + "h38.4" + ] + ], + [ + "resistor3:2", + "arduino uno1:5", + "green", + [ + "h0" + ] + ], + [ + "resistor2:2", + "arduino uno1:6", + "green", + [ + "h-9.6", + "v46.8", + "h-28.8" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level4/smart_led_system/diagram_breadboard.json b/arduino/level4/smart_led_system/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..378eec225579f2c78d09cbd845b498c5a82f86b7 --- /dev/null +++ b/arduino/level4/smart_led_system/diagram_breadboard.json @@ -0,0 +1,463 @@ +{ + "version": 1, + "author": "Arduino-LLM", + "editor": "Blind Author and Blind Author", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 200, + "left": 20, + "attrs": {} + }, + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": 0, + "left": 100, + "attrs": {} + }, + { + "type": "wokwi-led", + "id": "led1", + "top": 50, + "left": 250, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-led", + "id": "led2", + "top": 50, + "left": 300, + "attrs": { + "color": "green" + } + }, + { + "type": "wokwi-led", + "id": "led3", + "top": 50, + "left": 350, + "attrs": { + "color": "blue" + } + }, + { + "type": "wokwi-led", + "id": "led4", + "top": 50, + "left": 400, + "attrs": { + "color": "yellow" + } + }, + { + "type": "wokwi-led", + "id": "led5", + "top": 50, + "left": 450, + "attrs": { + "color": "white" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 100, + "left": 500, + "attrs": { + "value": "220" + }, + "rotate": 90 + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": 100, + "left": 550, + "attrs": { + "value": "220" + }, + "rotate": 90 + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 100, + "left": 600, + "attrs": { + "value": "220" + }, + "rotate": 90 + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 100, + "left": 650, + "attrs": { + "value": "220" + }, + "rotate": 90 + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": 100, + "left": 700, + "attrs": { + "value": "220" + }, + "rotate": 90 + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor1", + "top": 410, + "left": 630, + "attrs": { + "lux": "105" + } + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor2", + "top": 440, + "left": 670, + "attrs": { + "lux": "20000" + } + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor3", + "top": 470, + "left": 710, + "attrs": { + "lux": "600" + } + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor4", + "top": 500, + "left": 750, + "attrs": { + "lux": "10" + } + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor5", + "top": 530, + "left": 790, + "attrs": { + "lux": "1000" + } + } + ], + "connections": [ + [ + "arduino uno1:2", + "breadboard1:10t.a", + "green", + [] + ], + [ + "breadboard1:10t.b", + "resistor1:1", + "blue", + [] + ], + [ + "resistor1:2", + "breadboard1:15t.a", + "green", + [] + ], + [ + "breadboard1:15t.b", + "led1:A", + "green", + [] + ], + [ + "led1:C", + "breadboard1:16t.d", + "green", + [] + ], + [ + "breadboard1:16t.e", + "arduino uno1:GND.2", + "black", + [] + ], + [ + "arduino uno1:3", + "breadboard1:20t.a", + "purple", + [] + ], + [ + "breadboard1:20t.b", + "resistor2:1", + "blue", + [] + ], + [ + "resistor2:2", + "breadboard1:25t.a", + "purple", + [] + ], + [ + "breadboard1:25t.b", + "led2:A", + "green", + [] + ], + [ + "led2:C", + "breadboard1:26t.d", + "green", + [] + ], + [ + "breadboard1:26t.e", + "arduino uno1:GND.2", + "black", + [] + ], + [ + "arduino uno1:4", + "breadboard1:30t.a", + "orange", + [] + ], + [ + "breadboard1:30t.b", + "resistor3:1", + "purple", + [] + ], + [ + "resistor3:2", + "breadboard1:35t.a", + "blue", + [] + ], + [ + "breadboard1:35t.b", + "led3:A", + "green", + [] + ], + [ + "led3:C", + "breadboard1:36t.d", + "green", + [] + ], + [ + "breadboard1:36t.e", + "arduino uno1:GND.2", + "black", + [] + ], + [ + "arduino uno1:5", + "breadboard1:40t.a", + "purple", + [] + ], + [ + "breadboard1:40t.b", + "resistor4:1", + "yellow", + [] + ], + [ + "resistor4:2", + "breadboard1:45t.a", + "blue", + [] + ], + [ + "breadboard1:45t.b", + "led4:A", + "green", + [] + ], + [ + "led4:C", + "breadboard1:46t.d", + "green", + [] + ], + [ + "breadboard1:46t.e", + "arduino uno1:GND.2", + "black", + [] + ], + [ + "arduino uno1:6", + "breadboard1:50t.a", + "yellow", + [] + ], + [ + "breadboard1:50t.b", + "resistor5:1", + "purple", + [] + ], + [ + "resistor5:2", + "breadboard1:55t.a", + "green", + [] + ], + [ + "breadboard1:55t.b", + "led5:A", + "green", + [] + ], + [ + "led5:C", + "breadboard1:56t.d", + "green", + [] + ], + [ + "breadboard1:56t.e", + "arduino uno1:GND.2", + "black", + [] + ], + [ + "arduino uno1:A0", + "breadboard1:60t.a", + "yellow", + [] + ], + [ + "breadboard1:60t.b", + "ldr1", + "green", + [] + ], + [ + "ldr1", + "breadboard1:60t.c", + "blue", + [] + ], + [ + "breadboard1:60t.d", + "arduino uno1:GND.2", + "black", + [] + ], + [ + "arduino uno1:A1", + "breadboard1:60t.e", + "green", + [] + ], + [ + "breadboard1:60b.f", + "ldr2", + "green", + [] + ], + [ + "ldr2", + "breadboard1:60b.g", + "yellow", + [] + ], + [ + "breadboard1:60b.h", + "arduino uno1:GND.2", + "black", + [] + ], + [ + "arduino uno1:A2", + "breadboard1:60b.i", + "blue", + [] + ], + [ + "breadboard1:60b.j", + "ldr3", + "yellow", + [] + ], + [ + "ldr3", + "breadboard1:60b.k", + "blue", + [] + ], + [ + "breadboard1:60b.l", + "arduino uno1:GND.2", + "black", + [] + ], + [ + "arduino uno1:A3", + "breadboard1:60b.m", + "blue", + [] + ], + [ + "breadboard1:60b.n", + "ldr4", + "orange", + [] + ], + [ + "ldr4", + "breadboard1:60b.o", + "blue", + [] + ], + [ + "breadboard1:60b.p", + "arduino uno1:GND.2", + "black", + [] + ], + [ + "arduino uno1:A4", + "breadboard1:60b.q", + "purple", + [] + ], + [ + "breadboard1:60b.r", + "ldr5", + "yellow", + [] + ], + [ + "ldr5", + "breadboard1:60b.s", + "purple", + [] + ], + [ + "breadboard1:60b.t", + "arduino uno1:GND.2", + "black", + [] + ] + ] +} \ No newline at end of file diff --git a/arduino/level4/smart_led_system/platformio.ini b/arduino/level4/smart_led_system/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level4/smart_led_system/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level4/smart_led_system/scenario.yaml b/arduino/level4/smart_led_system/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d44e3553f4dc73f6382b27448e5494f06756fe27 --- /dev/null +++ b/arduino/level4/smart_led_system/scenario.yaml @@ -0,0 +1,62 @@ +author: Blind Author +description: Turn on the corresponding LED when the brightness detected by the photoresistor is lower +name: Smart LED System +test-values: + - part-id: photoresistor1 + attr-name: lux + value: "105" + - part-id: photoresistor2 + attr-name: lux + value: "20000" + - part-id: photoresistor3 + attr-name: lux + value: "600" + - part-id: photoresistor4 + attr-name: lux + value: "10" + - part-id: photoresistor5 + attr-name: lux + value: "1000" +steps: +- delay: 100ms +- expect-pin: + part-id: led1 + pin: C + value: 0 +- expect-pin: + part-id: led2 + pin: C + value: 0 +- expect-pin: + part-id: led3 + pin: C + value: 0 +- expect-pin: + part-id: led4 + pin: C + value: 0 +- expect-pin: + part-id: led5 + pin: C + value: 0 +- expect-pin: + part-id: led1 + pin: A + value: 1 +- expect-pin: + part-id: led2 + pin: A + value: 0 +- expect-pin: + part-id: led3 + pin: A + value: 0 +- expect-pin: + part-id: led4 + pin: A + value: 1 +- expect-pin: + part-id: led5 + pin: A + value: 0 +version: 1.0 diff --git a/arduino/level4/smart_led_system/src/main.ino b/arduino/level4/smart_led_system/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..b592b1e464eb2279e2353b6b585ba109c3843ca3 --- /dev/null +++ b/arduino/level4/smart_led_system/src/main.ino @@ -0,0 +1,29 @@ +/** + Turn on the corresponding LED when the brightness detected by the photoresistor is lower + 07 MAY 2025 by Blind Author +*/ + +const int LDR_pins[] = {A0, A1, A2, A3, A4}; +const int led_pins[] = {2, 3, 4, 5, 6}; + +int threshold = 500; + +void setup() { + for (int i=0; i<5; i++) { + pinMode(LDR_pins[i], INPUT); + pinMode(led_pins[i], OUTPUT); + } +} + +void loop() { + for (int i=0; i<5; i++) { + int analogValue = analogRead(LDR_pins[i]); + if (analogValue > threshold) { + digitalWrite(led_pins[i], HIGH); + } else { + digitalWrite(led_pins[i], LOW); + } + } + + delay(1000); +} diff --git a/arduino/level4/smart_led_system/wokwi.toml b/arduino/level4/smart_led_system/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level4/smart_led_system/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/arduino/level4/traffic_light/description.md b/arduino/level4/traffic_light/description.md new file mode 100644 index 0000000000000000000000000000000000000000..1c9363a1edaf95a92c3bab39f9c6fa269fc23fb3 --- /dev/null +++ b/arduino/level4/traffic_light/description.md @@ -0,0 +1,37 @@ +# Traffic Light + +## Project Description +This project uses three LEDs to create a traffic light. When a pedestrian button is pressed, the traffic light changes to yellow and then red. + +## Hardware Components +- Arduino Uno +- Push Button +- 10kΩ resistor +- 220Ω resistor * 3 +- LED * 3 + +## Circuit Description +LED1 is red and connected to Arduino pin8 through a 220-ohm resistor. LED2 is yellow and connected to pin9 through a 220-ohm resistor. LED3 is green and connected to pin10 through a 220-ohm resistor. The cathode of each LED is connected to gnd2. +The input from the push button goes into Arduino pin2. When the button is not pressed, it is connected to gnd2 through a 10k ohm resistor; when pressed, it is connected to the 5V pin. + +## Expected Behavior +When the Arduino powers up, it should: +1. Configure the button pin as INPUT. +2. Configure three LED pins as OUTPUT. +3. Continuously monitor the button state. +4. If it is not pressed, turn the green LED3 on. +5. If it is pressed, turn the green LED3 off, and turn the yellow LED2 on for 1000ms, and then turn the red LED1 on for 2000ms. Lastly, turn the green LED3 on again. + +## Success Criteria +The test is successful when: +1. The green LED turns on when the button is not pressed. +2. The yellow LED and the red LED turns on sequentially when the button is pressed. + +## Notes for Implementation +- The button input will read HIGH when pressed. +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. +- Set the LED ID corresponding to the led name, e.g., "led1" for LED1. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". +- To specify color of the led, set the property name "color" to "red", "green" or "yellow". \ No newline at end of file diff --git a/arduino/level4/traffic_light/description_no_pin.md b/arduino/level4/traffic_light/description_no_pin.md new file mode 100644 index 0000000000000000000000000000000000000000..faee0faddc123c3b5bcaba897db6324f295ed95a --- /dev/null +++ b/arduino/level4/traffic_light/description_no_pin.md @@ -0,0 +1,37 @@ +# Traffic Light + +## Project Description +This project uses three LEDs to create a traffic light. When a pedestrian button is pressed, the traffic light changes to yellow and then red. + +## Hardware Components +- Arduino Uno +- Push Button +- 10kΩ resistor +- 220Ω resistor * 3 +- LED * 3 + +## Circuit Description +LED1 to LED3 corresponds to red, yellow and green, and are connected to arduino digital pins through 220Ω resistor. +The push button is connected to arduino digital pin, and also connected to ground through 10kΩ resistor. The push button uses pull-down resistor configuration. + +## Expected Behavior +When the Arduino powers up, it should: +1. Configure the button pin as INPUT. +2. Configure three LED pins as OUTPUT. +3. Continuously monitor the button state. +4. If it is not pressed, turn the green LED3 on. +5. If it is pressed, turn the green LED3 off, and turn the yellow LED2 on for 1000ms, and then turn the red LED1 on for 2000ms. Lastly, turn the green LED3 on again. + +## Success Criteria +The test is successful when: +1. The green LED turns on when the button is not pressed. +2. The yellow LED and the red LED turns on sequentially when the button is pressed. + +## Notes for Implementation +- The button input will read HIGH when pressed. +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. +- Set the LED ID corresponding to the led name, e.g., "led1" for LED1. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". +- To specify color of the led, set the property name "color" to "red", "green" or "yellow". \ No newline at end of file diff --git a/arduino/level4/traffic_light/diagram.json b/arduino/level4/traffic_light/diagram.json new file mode 100644 index 0000000000000000000000000000000000000000..66980761bbfd73980c98c00bb7f5c946520a829f --- /dev/null +++ b/arduino/level4/traffic_light/diagram.json @@ -0,0 +1,226 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Traffic light", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-led", + "id": "led1", + "top": -22.8, + "left": 301.4, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-led", + "id": "led2", + "top": -22.8, + "left": 339.8, + "attrs": { + "color": "yellow" + } + }, + { + "type": "wokwi-led", + "id": "led3", + "top": -22.8, + "left": 378.2, + "attrs": { + "color": "green" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": 111.8, + "left": 326.4, + "attrs": { + "color": "blue", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 177.6, + "left": 393.05, + "rotate": 90, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": 52.8, + "left": 297.05, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 52.8, + "left": 335.45, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 52.8, + "left": 373.85, + "rotate": 90, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "push button1:2.r", + "resistor1:1", + "black", + [ + "h0" + ] + ], + [ + "resistor1:2", + "arduino uno1:GND.2", + "black", + [ + "h0", + "v8.4", + "h-249.6" + ] + ], + [ + "resistor2:1", + "led1:A", + "red", + [ + "h0" + ] + ], + [ + "led2:A", + "resistor3:1", + "orange", + [ + "v0" + ] + ], + [ + "led3:A", + "resistor4:1", + "green", + [ + "v0" + ] + ], + [ + "resistor2:2", + "arduino uno1:8", + "red", + [ + "h0", + "v8.4", + "h9.6", + "v-124.8", + "h-182.4" + ] + ], + [ + "resistor3:2", + "arduino uno1:9", + "orange", + [ + "h0", + "v8.4", + "h9.6", + "v-134.4", + "h-230.4" + ] + ], + [ + "resistor4:2", + "arduino uno1:10", + "green", + [ + "h0", + "v8.4", + "h9.6", + "v-144", + "h-278.4" + ] + ], + [ + "led1:C", + "arduino uno1:GND.2", + "black", + [ + "v86.4", + "h125.2", + "v115.2", + "h-268.8" + ] + ], + [ + "led2:C", + "arduino uno1:GND.2", + "black", + [ + "v86.4", + "h86.8", + "v115.2", + "h-268.8" + ] + ], + [ + "led3:C", + "arduino uno1:GND.2", + "black", + [ + "v86.4", + "h48.4", + "v115.2", + "h-268.8" + ] + ], + [ + "push button1:1.r", + "arduino uno1:5V", + "red", + [ + "v0", + "h57.8", + "v105.6", + "h-288" + ] + ], + [ + "push button1:2.l", + "arduino uno1:2", + "green", + [ + "h-38.4", + "v-163", + "h-48" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level4/traffic_light/diagram_breadboard.json b/arduino/level4/traffic_light/diagram_breadboard.json new file mode 100644 index 0000000000000000000000000000000000000000..f2a783d39b48b1f6f0876b91ab6d671ff44e9c59 --- /dev/null +++ b/arduino/level4/traffic_light/diagram_breadboard.json @@ -0,0 +1,341 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Traffic light", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -22.2, + "left": 281.2, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": -28.2, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 119.45, + "left": 517, + "rotate": 180, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": 62.4, + "left": 325.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 62.4, + "left": 373.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 62.4, + "left": 421.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-led", + "id": "led1", + "top": 82.8, + "left": 330.2, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-led", + "id": "led2", + "top": 82.8, + "left": 378.2, + "attrs": { + "color": "yellow" + } + }, + { + "type": "wokwi-led", + "id": "led3", + "top": 82.8, + "left": 426.2, + "attrs": { + "color": "green" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": 47.4, + "left": 473.4, + "rotate": 90, + "attrs": { + "color": "blue", + "xray": "1" + } + } + ], + "connections": [ + [ + "breadboard1:6t.a", + "arduino uno1:8", + "red", + [ + "v-67.2", + "h-201.6" + ] + ], + [ + "breadboard1:11t.a", + "arduino uno1:9", + "orange", + [ + "v-76.8", + "h-259.2" + ] + ], + [ + "breadboard1:16t.a", + "arduino uno1:10", + "green", + [ + "v-86.4", + "h-316.8" + ] + ], + [ + "breadboard1:5b.j", + "breadboard1:bn.4", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:10b.j", + "breadboard1:bn.8", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:15b.j", + "breadboard1:bn.12", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:29b.j", + "breadboard1:bn.24", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:21b.h", + "breadboard1:bp.17", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:23t.a", + "arduino uno1:2", + "blue", + [ + "v-96", + "h-307.2" + ] + ], + [ + "breadboard1:bp.1", + "arduino uno1:5V", + "red", + [ + "v-29.7", + "h-180.8" + ] + ], + [ + "arduino uno1:GND.2", + "breadboard1:bn.1", + "black", + [ + "v-19.3", + "h157.5", + "v28.8" + ] + ], + [ + "led1:A", + "breadboard1:6b.i", + "", + [ + "$bb" + ] + ], + [ + "led1:C", + "breadboard1:5b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:6t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:6b.f", + "", + [ + "$bb" + ] + ], + [ + "led2:A", + "breadboard1:11b.i", + "", + [ + "$bb" + ] + ], + [ + "led2:C", + "breadboard1:10b.i", + "", + [ + "$bb" + ] + ], + [ + "led3:A", + "breadboard1:16b.i", + "", + [ + "$bb" + ] + ], + [ + "led3:C", + "breadboard1:15b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor4:1", + "breadboard1:16t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor4:2", + "breadboard1:16b.f", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:11t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:11b.f", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.l", + "breadboard1:23t.b", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.l", + "breadboard1:21t.b", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.r", + "breadboard1:23b.g", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.r", + "breadboard1:21b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:29b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:23b.i", + "", + [ + "$bb" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level4/traffic_light/diagram_breadboard_half.json b/arduino/level4/traffic_light/diagram_breadboard_half.json new file mode 100644 index 0000000000000000000000000000000000000000..3843d75b4a8c713d34c5ca0d4ba97d3dab7576e1 --- /dev/null +++ b/arduino/level4/traffic_light/diagram_breadboard_half.json @@ -0,0 +1,96 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Traffic light", + "parts": [ + { "type": "wokwi-breadboard-half", "id": "bb1", "top": -22.2, "left": 281.2, "attrs": {} }, + { "type": "wokwi-arduino-uno", "id": "uno", "top": -28.2, "left": -19.8, "attrs": {} }, + { + "type": "wokwi-resistor", + "id": "r1", + "top": 119.45, + "left": 517, + "rotate": 180, + "attrs": { "value": "10000" } + }, + { + "type": "wokwi-resistor", + "id": "r2", + "top": 62.4, + "left": 325.85, + "rotate": 90, + "attrs": { "value": "220" } + }, + { + "type": "wokwi-resistor", + "id": "r3", + "top": 62.4, + "left": 373.85, + "rotate": 90, + "attrs": { "value": "220" } + }, + { + "type": "wokwi-resistor", + "id": "r4", + "top": 62.4, + "left": 421.85, + "rotate": 90, + "attrs": { "value": "220" } + }, + { "type": "wokwi-led", "id": "led1", "top": 82.8, "left": 330.2, "attrs": { "color": "red" } }, + { + "type": "wokwi-led", + "id": "led2", + "top": 82.8, + "left": 378.2, + "attrs": { "color": "orange" } + }, + { + "type": "wokwi-led", + "id": "led3", + "top": 82.8, + "left": 426.2, + "attrs": { "color": "green" } + }, + { + "type": "wokwi-pushbutton", + "id": "btn1", + "top": 47.4, + "left": 473.4, + "rotate": 90, + "attrs": { "color": "blue", "xray": "1" } + } + ], + "connections": [ + [ "bb1:6t.a", "uno:8", "red", [ "v-67.2", "h-201.6" ] ], + [ "bb1:11t.a", "uno:9", "orange", [ "v-76.8", "h-259.2" ] ], + [ "bb1:16t.a", "uno:10", "green", [ "v-86.4", "h-316.8" ] ], + [ "bb1:5b.j", "bb1:bn.4", "black", [ "v0" ] ], + [ "bb1:10b.j", "bb1:bn.8", "black", [ "v0" ] ], + [ "bb1:15b.j", "bb1:bn.12", "black", [ "v0" ] ], + [ "bb1:29b.j", "bb1:bn.24", "black", [ "v0" ] ], + [ "bb1:21b.h", "bb1:bp.17", "red", [ "v0" ] ], + [ "bb1:23t.a", "uno:2", "blue", [ "v-96", "h-307.2" ] ], + [ "bb1:bp.1", "uno:5V", "red", [ "v-29.7", "h-180.8" ] ], + [ "uno:GND.2", "bb1:bn.1", "black", [ "v-19.3", "h157.5", "v28.8" ] ], + [ "r2:1", "bb1:6t.b", "", [ "$bb" ] ], + [ "r2:2", "bb1:6b.f", "", [ "$bb" ] ], + [ "r3:1", "bb1:11t.b", "", [ "$bb" ] ], + [ "r3:2", "bb1:11b.f", "", [ "$bb" ] ], + [ "r4:1", "bb1:16t.b", "", [ "$bb" ] ], + [ "r4:2", "bb1:16b.f", "", [ "$bb" ] ], + [ "led3:A", "bb1:16b.i", "", [ "$bb" ] ], + [ "led3:C", "bb1:15b.i", "", [ "$bb" ] ], + [ "led2:A", "bb1:11b.i", "", [ "$bb" ] ], + [ "led2:C", "bb1:10b.i", "", [ "$bb" ] ], + [ "led1:A", "bb1:6b.i", "", [ "$bb" ] ], + [ "led1:C", "bb1:5b.i", "", [ "$bb" ] ], + [ "btn1:1.l", "bb1:23t.b", "", [ "$bb" ] ], + [ "btn1:2.l", "bb1:21t.b", "", [ "$bb" ] ], + [ "btn1:1.r", "bb1:23b.g", "", [ "$bb" ] ], + [ "btn1:2.r", "bb1:21b.g", "", [ "$bb" ] ], + [ "r1:1", "bb1:29b.i", "", [ "$bb" ] ], + [ "r1:2", "bb1:23b.i", "", [ "$bb" ] ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/arduino/level4/traffic_light/platformio.ini b/arduino/level4/traffic_light/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..6ddde49f7e452934eb8b1282a2b8bbaa7986b403 --- /dev/null +++ b/arduino/level4/traffic_light/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino \ No newline at end of file diff --git a/arduino/level4/traffic_light/scenario.yaml b/arduino/level4/traffic_light/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5325d210c8fb98e09638eee1cc52b3d0893185f6 --- /dev/null +++ b/arduino/level4/traffic_light/scenario.yaml @@ -0,0 +1,109 @@ +author: Blind Author +description: Traffic light turns red when the button is pressed +name: Traffic light +steps: +- delay: 100ms +- expect-pin: + part-id: arduino uno1 + pin: 0 + value: 1 +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: led1 + pin: C + value: 0 + - part-id: led2 + pin: C + value: 0 + - part-id: led3 + pin: C + value: 0 + - part-id: led1 + pin: A + value: 0 + - part-id: led2 + pin: A + value: 0 + - part-id: led3 + pin: A + value: 1 +- set-control: + control: pressed + part-id: push button1 + value: 1 +- delay: 500ms +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: led1 + pin: C + value: 0 + - part-id: led2 + pin: C + value: 0 + - part-id: led3 + pin: C + value: 0 + - part-id: led1 + pin: A + value: 0 + - part-id: led2 + pin: A + value: 1 + - part-id: led3 + pin: A + value: 0 +- delay: 500ms +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: led1 + pin: C + value: 0 + - part-id: led2 + pin: C + value: 0 + - part-id: led3 + pin: C + value: 0 + - part-id: led1 + pin: A + value: 1 + - part-id: led2 + pin: A + value: 0 + - part-id: led3 + pin: A + value: 0 +- set-control: + control: pressed + part-id: push button1 + value: 0 +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: led1 + pin: C + value: 0 + - part-id: led2 + pin: C + value: 0 + - part-id: led3 + pin: C + value: 0 + - part-id: led1 + pin: A + value: 0 + - part-id: led2 + pin: A + value: 0 + - part-id: led3 + pin: A + value: 1 +version: 1.0 diff --git a/arduino/level4/traffic_light/src/main.ino b/arduino/level4/traffic_light/src/main.ino new file mode 100644 index 0000000000000000000000000000000000000000..77682a8e409e2385d8adfa3178db356a5c20ce25 --- /dev/null +++ b/arduino/level4/traffic_light/src/main.ino @@ -0,0 +1,32 @@ +/** + Creating a traffic light with leds and button. + 02 MAY 2025 by Blind Author +*/ + +const int BUTTON_PIN = 2; +const int RED_LED = 8; +const int YELLOW_LED = 9; +const int GREEN_LED = 10; + +void setup() { + pinMode(BUTTON_PIN, INPUT); + pinMode(RED_LED, OUTPUT); + pinMode(YELLOW_LED, OUTPUT); + pinMode(GREEN_LED, OUTPUT); +} + +void loop() { + + if (digitalRead(BUTTON_PIN)==HIGH) { + digitalWrite(GREEN_LED, LOW); + digitalWrite(YELLOW_LED, HIGH); + delay(1000); + digitalWrite(YELLOW_LED, LOW); + digitalWrite(RED_LED, HIGH); + delay(2000); + digitalWrite(RED_LED, LOW); + } + + digitalWrite(GREEN_LED, HIGH); + delay(500); +} diff --git a/arduino/level4/traffic_light/wokwi.toml b/arduino/level4/traffic_light/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/arduino/level4/traffic_light/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level1/7_segment_display_basic/.DS_Store b/esp32/level1/7_segment_display_basic/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a268db33cc70250297fe6a549fb33a161d083d96 Binary files /dev/null and b/esp32/level1/7_segment_display_basic/.DS_Store differ diff --git a/esp32/level1/7_segment_display_basic/description_esp.md b/esp32/level1/7_segment_display_basic/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..dfe6a0b0a3f16edd73d98c01d196983603b51795 --- /dev/null +++ b/esp32/level1/7_segment_display_basic/description_esp.md @@ -0,0 +1,31 @@ +# One Digit 7-segment Display + +## Project Description +This is an ESP32 project that show number 5 with digit 7-segment display. + +## Hardware Components +- ESP32 DevKit v1 +- 330Ω resistor * 8 +- 7-segment display + +## Circuit Description +Circuit is designed to use a 7-segment display. The 7-segment display is a common anode type, so the common pin is connected to 3V3. The A to G and DP pins are connected to Arduino digital pins 2, 4, 5, 12, 13, 14, 18, 19 through 330-ohm resistors. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Set 2, 4, 5, 12, 13, 14, 18, 19 pin as an output. +2. Taking into account that the display is common anode, set the corresponding pins to HIGH or LOW so that the number 5 appears on the 7-segment display. + +## Success Criteria +The test is successful when: +1. The number 5 appears on the 7-segment display. + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- The 7-segment display is a common anode type. + +## Variants +This project may have different variants with the segment pins connected to the different pins. + +## Attributes +- To use 330Ω resistor, set the property name "value" to "330 ohm". \ No newline at end of file diff --git a/esp32/level1/7_segment_display_basic/diagram_breadboard_esp.json b/esp32/level1/7_segment_display_basic/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..a6901b0873e5a2168e6789fd4ec1343d824a0829 --- /dev/null +++ b/esp32/level1/7_segment_display_basic/diagram_breadboard_esp.json @@ -0,0 +1,407 @@ +{ + "version": 1, + "author": "Blind Author", + "editor": "wokwi", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -127.8, + "left": 338.8, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 115.8, + "left": 527.4, + "attrs": {} + }, + { + "type": "wokwi-7segment", + "id": "7-segment display1", + "top": -62.22, + "left": 629.08, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 23.15, + "left": 672, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -72.85, + "left": 662.4, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 13.55, + "left": 662.4, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 23.15, + "left": 576, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": 13.55, + "left": 585.6, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -82.45, + "left": 576, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": -72.85, + "left": 585.6, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": -82.45, + "left": 672, + "attrs": { + "value": "330" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "breadboard1:38t.d", + "esp1:D2", + "green", + [ + "v134.4", + "h48" + ] + ], + [ + "breadboard1:39t.d", + "esp1:D4", + "green", + [ + "v144", + "h19.2" + ] + ], + [ + "breadboard1:38b.g", + "esp1:D5", + "green", + [ + "v105.6", + "h28.8" + ] + ], + [ + "breadboard1:24b.g", + "esp1:D12", + "green", + [ + "v0", + "h-57.6", + "v76.8", + "h201.6" + ] + ], + [ + "breadboard1:23b.h", + "esp1:D13", + "green", + [ + "v0", + "h-38.4", + "v76.8", + "h182.4" + ] + ], + [ + "breadboard1:24t.d", + "esp1:D14", + "green", + [ + "v144", + "h124.8" + ] + ], + [ + "breadboard1:23t.d", + "esp1:D18", + "green", + [ + "v153.6", + "h124.8" + ] + ], + [ + "breadboard1:39b.h", + "esp1:D19", + "green", + [ + "v38.4", + "h-38.4" + ] + ], + [ + "breadboard1:31b.j", + "esp1:3V3", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:COM.1", + "breadboard1:31b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:COM.2", + "breadboard1:31t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:A", + "breadboard1:32t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:B", + "breadboard1:33t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:C", + "breadboard1:32b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:D", + "breadboard1:30b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:E", + "breadboard1:29b.h", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:F", + "breadboard1:30t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:G", + "breadboard1:29t.c", + "", + [ + "$bb" + ] + ], + [ + "7-segment display1:DP", + "breadboard1:33b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:33b.j", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:39b.j", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:32t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:38t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:32b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:38b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor4:1", + "breadboard1:23b.j", + "", + [ + "$bb" + ] + ], + [ + "resistor4:2", + "breadboard1:29b.j", + "", + [ + "$bb" + ] + ], + [ + "resistor5:1", + "breadboard1:24b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor5:2", + "breadboard1:30b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor6:1", + "breadboard1:23t.a", + "", + [ + "$bb" + ] + ], + [ + "resistor6:2", + "breadboard1:29t.a", + "", + [ + "$bb" + ] + ], + [ + "resistor7:1", + "breadboard1:24t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor7:2", + "breadboard1:30t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor8:1", + "breadboard1:33t.a", + "", + [ + "$bb" + ] + ], + [ + "resistor8:2", + "breadboard1:39t.a", + "", + [ + "$bb" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level1/7_segment_display_basic/diagram_esp.json b/esp32/level1/7_segment_display_basic/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..8fefe6a244130e4ad3b6479d8962186b33854b59 --- /dev/null +++ b/esp32/level1/7_segment_display_basic/diagram_esp.json @@ -0,0 +1,254 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Use one digit 7-segment display", + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-7segment", + "id": "7-segment display1", + "top": 24.18, + "left": 408.28, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 128.75, + "left": 451.2, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -15.25, + "left": 451.2, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 109.55, + "left": 441.6, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 128.75, + "left": 355.2, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": 109.55, + "left": 364.8, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -15.25, + "left": 345.6, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": 3.95, + "left": 364.8, + "attrs": { + "value": "330" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": 3.95, + "left": 441.6, + "attrs": { + "value": "330" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "7-segment display1:F", + "resistor7:2", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:A", + "resistor8:1", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:G", + "resistor6:2", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:B", + "resistor2:1", + "green", + [ + "v0" + ] + ], + [ + "resistor5:2", + "7-segment display1:D", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:C", + "resistor3:1", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:E", + "resistor4:2", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:DP", + "resistor1:1", + "green", + [ + "v0" + ] + ], + [ + "7-segment display1:COM.1", + "esp1:3V3", + "green", + [ + "h0", + "v124.8" + ] + ], + [ + "resistor8:2", + "esp1:D2", + "green", + [ + "v-19.2", + "h-260.4" + ] + ], + [ + "resistor2:2", + "esp1:D4", + "green", + [ + "v-9.6", + "h-279.6" + ] + ], + [ + "resistor3:2", + "esp1:D5", + "green", + [ + "v0", + "h27.6", + "v-144", + "h-307.2" + ] + ], + [ + "resistor5:1", + "esp1:D12", + "green", + [ + "v-153.6", + "h-153.6" + ] + ], + [ + "resistor4:1", + "esp1:D13", + "green", + [ + "v-182.4", + "h-153.6" + ] + ], + [ + "resistor7:1", + "esp1:D14", + "green", + [ + "v-67.2", + "h-172.8" + ] + ], + [ + "resistor6:1", + "esp1:D18", + "green", + [ + "v-57.6", + "h-172.8" + ] + ], + [ + "resistor1:2", + "esp1:D19", + "green", + [ + "v-211.2", + "h-346.8" + ] + ] + ] +} \ No newline at end of file diff --git a/esp32/level1/7_segment_display_basic/platformio.ini b/esp32/level1/7_segment_display_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..931f8e51c8b316966aadabc57f6e4c0a1e61204c --- /dev/null +++ b/esp32/level1/7_segment_display_basic/platformio.ini @@ -0,0 +1,26 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 + +lib_deps = + Arduino \ No newline at end of file diff --git a/esp32/level1/7_segment_display_basic/scenario.yaml b/esp32/level1/7_segment_display_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..651ad81365d3d1b43a51d6fcf2f1ef95fe6b85c0 --- /dev/null +++ b/esp32/level1/7_segment_display_basic/scenario.yaml @@ -0,0 +1,37 @@ +author: Blind Author +description: Determine how long a switch is pressed +name: Serial Monitor +steps: +- delay: 10ms +- wait-multi-pin: + timeout: 5000 + interval: 100 + pins: + - part-id: '7-segment display1' + pin: 'COM' + value: 1 + - part-id: '7-segment display1' + pin: 'A' + value: 0 + - part-id: '7-segment display1' + pin: 'B' + value: 1 + - part-id: '7-segment display1' + pin: 'C' + value: 0 + - part-id: '7-segment display1' + pin: 'D' + value: 0 + - part-id: '7-segment display1' + pin: 'E' + value: 1 + - part-id: '7-segment display1' + pin: 'F' + value: 0 + - part-id: '7-segment display1' + pin: 'G' + value: 0 + - part-id: '7-segment display1' + pin: 'DP' + value: 1 +version: 1.0 diff --git a/esp32/level1/7_segment_display_basic/src/main_esp.cpp b/esp32/level1/7_segment_display_basic/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e760faa6586b513fe0ad306fad7282841db2df51 --- /dev/null +++ b/esp32/level1/7_segment_display_basic/src/main_esp.cpp @@ -0,0 +1,36 @@ +/** + Use one digit 7-segment display to show number 5 + 7 APR 2025 by Blind Author +*/ + +const int segA = 2; +const int segB = 4; +const int segC = 5; +const int segD = 12; +const int segE = 13; +const int segF = 14; +const int segG = 18; +const int segDP = 19; + +void setup() { + pinMode(segA, OUTPUT); + pinMode(segB, OUTPUT); + pinMode(segC, OUTPUT); + pinMode(segD, OUTPUT); + pinMode(segE, OUTPUT); + pinMode(segF, OUTPUT); + pinMode(segG, OUTPUT); + pinMode(segDP, OUTPUT); + + digitalWrite(segA, LOW); + digitalWrite(segB, HIGH); + digitalWrite(segC, LOW); + digitalWrite(segD, LOW); + digitalWrite(segE, HIGH); + digitalWrite(segF, LOW); + digitalWrite(segG, LOW); + digitalWrite(segDP, HIGH); +} + +void loop() { +} \ No newline at end of file diff --git a/esp32/level1/7_segment_display_basic/wokwi.toml b/esp32/level1/7_segment_display_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level1/7_segment_display_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level1/LCD_display_basic/.DS_Store b/esp32/level1/LCD_display_basic/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b88cd06c171a6d6832fc043fd03fd2cd657ca877 Binary files /dev/null and b/esp32/level1/LCD_display_basic/.DS_Store differ diff --git a/esp32/level1/LCD_display_basic/description_esp.md b/esp32/level1/LCD_display_basic/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..6564909b1b80dc4e688a764440e810493240d20e --- /dev/null +++ b/esp32/level1/LCD_display_basic/description_esp.md @@ -0,0 +1,26 @@ +# LCD Display Basic + +## Project Description +This is a simple ESP32 project that shows text to the ili9341 lcd display. + +## Hardware Components +- ESP32 DevKit v1 +- Ili9341 LCD Display + +## Circuit Description +Ili9341 LCD Display is connected to the ESP32 board. RST, D/C, CS, MOSI, MISO, SCK pin of LCD display is connected to esp32 pin 4, 2, 15, 23, 19, 18, respectively. GND pin of LCD display is connected to esp32 pin gnd1. VCC pin of LCD display is connected to esp32 pin 3V3. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Declare Adafruit_ILI9341 object +2. Begin display and change it to landscape mode +3. Fill the display with black color +4. Display 'Hello World!' at position (0, 0) in white color with text size 2. + +## Success Criteria +The test is successful when: +1. Text "Hello World!" is successfully printed to the display, with correct position, color, and size. + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- Use the following libraries: , , and . diff --git a/esp32/level1/LCD_display_basic/diagram_breadboard_esp.json b/esp32/level1/LCD_display_basic/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..916c7d062cf08417a915cfc50c11c4f3c5984b16 --- /dev/null +++ b/esp32/level1/LCD_display_basic/diagram_breadboard_esp.json @@ -0,0 +1,203 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Use lcd display", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": 45, + "left": -160.4, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 331.89, + "left": 1.49, + "attrs": {} + }, + { + "type": "wokwi-ili9341", + "id": "ili9341 lcd display1", + "top": -124, + "left": 47.7, + "attrs": {} + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "ili9341 lcd display1:VCC", + "breadboard1:25b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:GND", + "breadboard1:26b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:CS", + "breadboard1:27b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:RST", + "breadboard1:28b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:D/C", + "breadboard1:29b.f", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:28b.j", + "esp1:D4", + "green", + [ + "v105.6", + "h57.6", + "v28.8" + ] + ], + [ + "ili9341 lcd display1:MOSI", + "breadboard1:30b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:SCK", + "breadboard1:31b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:LED", + "breadboard1:32b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:MISO", + "breadboard1:33b.f", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:25b.i", + "breadboard1:bp.20", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:26b.i", + "breadboard1:bn.20", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:27b.j", + "esp1:D15", + "orange", + [ + "v105.6", + "h38.4" + ] + ], + [ + "breadboard1:29b.j", + "esp1:D2", + "green", + [ + "v96", + "h28.8" + ] + ], + [ + "breadboard1:30b.j", + "esp1:D23", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:31b.j", + "esp1:D18", + "green", + [ + "v67.2", + "h-28.8" + ] + ], + [ + "breadboard1:33b.j", + "esp1:D19", + "green", + [ + "v48", + "h-38.4" + ] + ], + [ + "breadboard1:bp.8", + "esp1:3V3", + "red", + [ + "v306.3", + "h191.2" + ] + ], + [ + "breadboard1:bn.12", + "esp1:GND.1", + "black", + [ + "v75.5", + "h104.8" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level1/LCD_display_basic/diagram_esp.json b/esp32/level1/LCD_display_basic/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..a5764963d4cfb5c4bd0a69456bfd19003f13bc26 --- /dev/null +++ b/esp32/level1/LCD_display_basic/diagram_esp.json @@ -0,0 +1,110 @@ +{ + "version": 1, + "author": "Blind Author", + "editor": "wokwi", + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 331.1, + "left": 4.6, + "attrs": {} + }, + { + "type": "wokwi-ili9341", + "id": "ili9341 lcd display1", + "top": 164, + "left": 249.3, + "attrs": {} + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "ili9341 lcd display1:GND", + "esp1:GND.1", + "black", + [ + "v22", + "h-46" + ] + ], + [ + "ili9341 lcd display1:SCK", + "esp1:D18", + "green", + [ + "v16", + "h-75" + ] + ], + [ + "ili9341 lcd display1:MISO", + "esp1:D19", + "limegreen", + [ + "v20", + "h-78" + ] + ], + [ + "ili9341 lcd display1:MOSI", + "esp1:D23", + "green", + [ + "v24", + "h-75" + ] + ], + [ + "ili9341 lcd display1:CS", + "esp1:D15", + "orange", + [ + "v32", + "h-64" + ] + ], + [ + "ili9341 lcd display1:D/C", + "esp1:D2", + "purple", + [ + "v36", + "h-84" + ] + ], + [ + "ili9341 lcd display1:RST", + "esp1:D4", + "green", + [ + "v33.69", + "h54.93" + ] + ], + [ + "ili9341 lcd display1:VCC", + "esp1:3V3", + "red", + [ + "v24.09", + "h-98.67", + "v14.31", + "h-93.03" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level1/LCD_display_basic/platformio.ini b/esp32/level1/LCD_display_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..18e73044048f5a127fa4232861a68ed185e649ac --- /dev/null +++ b/esp32/level1/LCD_display_basic/platformio.ini @@ -0,0 +1,30 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno +lib_deps = + Arduino + Adafruit ILI9341 + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 + +lib_deps = + Arduino + Adafruit ILI9341 \ No newline at end of file diff --git a/esp32/level1/LCD_display_basic/scenario.yaml b/esp32/level1/LCD_display_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..33cea086ec8a9b4acc826fffc73375ec3d34748e --- /dev/null +++ b/esp32/level1/LCD_display_basic/scenario.yaml @@ -0,0 +1,9 @@ +author: Blind Author +description: Use LCD display +name: LCD Display Basic +steps: +- delay: 4000ms +- take-screenshot: + part-id: ili9341 lcd display1 + compare-with: screenshots/0.png +version: 1.0 diff --git a/esp32/level1/LCD_display_basic/screenshots/0.png b/esp32/level1/LCD_display_basic/screenshots/0.png new file mode 100644 index 0000000000000000000000000000000000000000..b6960471609c1584928ab01ea53fe502d0426b78 --- /dev/null +++ b/esp32/level1/LCD_display_basic/screenshots/0.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:934059cdd6daa6b5895229b0ad5732f18d8a39beef481630705947bd8b4c4d7c +size 1301 diff --git a/esp32/level1/LCD_display_basic/src/main_esp.cpp b/esp32/level1/LCD_display_basic/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fd31a744048b354fcbf0bc06f617e2b7c54a5f0f --- /dev/null +++ b/esp32/level1/LCD_display_basic/src/main_esp.cpp @@ -0,0 +1,29 @@ +/** + Show text in ili9431 lcd display + 05 MAY 2025 by Blind Author +*/ + +#include +#include +#include +#include + +#define TFT_CS 15 +#define TFT_DC 2 +#define TFT_RST 4 + +Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); + +void setup() { + tft.begin(); + tft.setRotation(1); + tft.fillScreen(ILI9341_BLACK); + + tft.setCursor(0, 0); + tft.setTextColor(ILI9341_WHITE); + tft.setTextSize(2); + tft.println("Hello World!"); +} + +void loop() { +} \ No newline at end of file diff --git a/esp32/level1/LCD_display_basic/wokwi.toml b/esp32/level1/LCD_display_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level1/LCD_display_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level1/RTC_module_basic/.DS_Store b/esp32/level1/RTC_module_basic/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a2ba7ca4c00f4f2f08622c0cb24f7e1a348463ea Binary files /dev/null and b/esp32/level1/RTC_module_basic/.DS_Store differ diff --git a/esp32/level1/RTC_module_basic/description_esp.md b/esp32/level1/RTC_module_basic/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..10e5c4061fd2bdf8b8ae809d9b7d1e20d44084f1 --- /dev/null +++ b/esp32/level1/RTC_module_basic/description_esp.md @@ -0,0 +1,35 @@ +# RTC module + +## Project Description +This is a simple ESP32 project that uses RTC module to get current time. + +## Hardware Components +- ESP32 DevKit v1 +- RTC module + +## Circuit Description +The RTC module is connected to the ESP32. The VCC pin is connected to 5V, the GND pin to gnd2, the SDA pin to A4, and the SCL pin to A5. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Initialize serial communication +2. Check if the RTC module can begin +3. Read current time with RTC module +4. Print to the serial monitor in the following format: "Current time: YYYY/M/D (Day of the week) H:M:S" + +## Success Criteria +The test is successful when: +1. Correct day and time is printed in the serial monitor. + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- No actions are required in the loop function. +- Day of the week is one of the "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". +- Use RTClib to generate RTC_DS1307 object and read the value. +- RTC module has I2C interface. + +## Variants +There may be variants with GND pin. + +## Test Inputs +Test init value is: "2024-11-24T04:48:00" \ No newline at end of file diff --git a/esp32/level1/RTC_module_basic/diagram_breadboard_esp.json b/esp32/level1/RTC_module_basic/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..afb2ed2fece01e3ab3f9fed3c36439e64fbaa8d9 --- /dev/null +++ b/esp32/level1/RTC_module_basic/diagram_breadboard_esp.json @@ -0,0 +1,123 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Get the current time using an RTC sensor", + "config": { + "gnd_pin": "GND.2", + "vcc_pin": "5V" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "bb1", + "top": 390.6, + "left": -160.4, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 0, + "left": 20, + "attrs": {} + }, + { + "type": "wokwi-ds1307", + "id": "ds1307 real time clock module1307", + "top": 477.5, + "left": 154.4, + "rotate": 90, + "attrs": { + "initTime": "2024-11-24T04:48:00", + "rotate": "180" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "ds1307 real time clock module1307:GND", + "bb1:39t.e", + "", + [ + "$bb" + ] + ], + [ + "ds1307 real time clock module1307:5V", + "bb1:38t.e", + "", + [ + "$bb" + ] + ], + [ + "ds1307 real time clock module1307:SDA", + "bb1:37t.e", + "", + [ + "$bb" + ] + ], + [ + "ds1307 real time clock module1307:SCL", + "bb1:36t.e", + "", + [ + "$bb" + ] + ], + [ + "ds1307 real time clock module1307:SQW", + "bb1:35t.e", + "", + [ + "$bb" + ] + ], + [ + "esp1:D21", + "bb1:37t.c", + "green", + [ + "h0" + ] + ], + [ + "esp1:3V3", + "bb1:38t.c", + "green", + [ + "v4.7", + "h118.7" + ] + ], + [ + "esp1:D22", + "bb1:36t.c", + "green", + [ + "h0" + ] + ], + [ + "esp1:GND.2", + "bb1:39t.c", + "black", + [ + "h0" + ] + ] + ] +} \ No newline at end of file diff --git a/esp32/level1/RTC_module_basic/diagram_esp.json b/esp32/level1/RTC_module_basic/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..ec7b4929fa170632cd540e4c3fc9391fb51cc3fd --- /dev/null +++ b/esp32/level1/RTC_module_basic/diagram_esp.json @@ -0,0 +1,79 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Get the current time using an RTC sensor", + "config": { + "gnd_pin": "GND.2", + "vcc_pin": "5V" + }, + "parts": [ + { + "id": "esp1", + "type": "wokwi-esp32-devkit-v1", + "top": 0, + "left": 20 + }, + { + "id": "ds1307 real time clock module1307", + "type": "wokwi-ds1307", + "top": 250, + "left": 220, + "attrs": { + "initTime": "2024-11-24T04:48:00" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "esp1:GND.2", + "ds1307 real time clock module1307:GND", + "black", + [ + "v20", + "*", + "v0" + ] + ], + [ + "esp1:3V3", + "ds1307 real time clock module1307:5V", + "red", + [ + "v0" + ] + ], + [ + "esp1:D21", + "ds1307 real time clock module1307:SDA", + "green", + [ + "v16", + "h0", + "*", + "h-34" + ] + ], + [ + "esp1:D22", + "ds1307 real time clock module1307:SCL", + "orange", + [ + "v20", + "*", + "h-30" + ] + ] + ] +} \ No newline at end of file diff --git a/esp32/level1/RTC_module_basic/platformio.ini b/esp32/level1/RTC_module_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..7388892e627a275b18551e2a42665598dd6cd7dd --- /dev/null +++ b/esp32/level1/RTC_module_basic/platformio.ini @@ -0,0 +1,31 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + RTClib + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 + +lib_deps = + Arduino + RTClib \ No newline at end of file diff --git a/esp32/level1/RTC_module_basic/scenario.yaml b/esp32/level1/RTC_module_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4964e03194e68ee9661c4e14817ff690b664d1c2 --- /dev/null +++ b/esp32/level1/RTC_module_basic/scenario.yaml @@ -0,0 +1,11 @@ +author: Blind Author +description: Get the current time using an RTC sensor +name: RTC sensor +test-values: + - part-type: wokwi-ds1307 + attr-name: initTime + value: "2024-11-24T04:48:00" +steps: + - delay: 10ms + - wait-serial: 2024/11/24 (Sunday) 4:48:0 +version: 1.0 diff --git a/esp32/level1/RTC_module_basic/src/main_esp.cpp b/esp32/level1/RTC_module_basic/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..970102c69497306217b5180ebedd5bf4530be6d7 --- /dev/null +++ b/esp32/level1/RTC_module_basic/src/main_esp.cpp @@ -0,0 +1,43 @@ +/** + Get the current time using an RTC sensor + 10 APR 2025 by Blind Author +*/ + +#include + +#include "RTClib.h" + +RTC_DS1307 rtc; + +char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; + +void setup () { + Serial.begin(115200); + + if (!rtc.begin()) { + Serial.println("Couldn't find RTC"); + Serial.flush(); + abort(); + } + + DateTime now = rtc.now(); + + Serial.print("Current time: "); + Serial.print(now.year(), DEC); + Serial.print('/'); + Serial.print(now.month(), DEC); + Serial.print('/'); + Serial.print(now.day(), DEC); + Serial.print(" ("); + Serial.print(daysOfTheWeek[now.dayOfTheWeek()]); + Serial.print(") "); + Serial.print(now.hour(), DEC); + Serial.print(':'); + Serial.print(now.minute(), DEC); + Serial.print(':'); + Serial.print(now.second(), DEC); + Serial.println(); +} + +void loop () { +} diff --git a/esp32/level1/RTC_module_basic/wokwi.toml b/esp32/level1/RTC_module_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..501c19ba8999c32379bfedc1a8cd0604c59e3eeb --- /dev/null +++ b/esp32/level1/RTC_module_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/esp32doit-devkit-v1/firmware.elf" +firmware = ".pio/build/esp32doit-devkit-v1/firmware.bin" \ No newline at end of file diff --git a/esp32/level1/bar_led_basic/.DS_Store b/esp32/level1/bar_led_basic/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..01eda85198e88b659981f325a02c629636344c4a Binary files /dev/null and b/esp32/level1/bar_led_basic/.DS_Store differ diff --git a/esp32/level1/bar_led_basic/description_esp.md b/esp32/level1/bar_led_basic/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..953610d71973f179a100e5dd38fbb009433e7a80 --- /dev/null +++ b/esp32/level1/bar_led_basic/description_esp.md @@ -0,0 +1,33 @@ +# Bar LED + +## Project Description +This is a simple ESP32 project that turns on an bar graph LED. + +## Hardware Components +- ESP32 DevKit v1 +- Bar graph LED +- 220Ω resistor * 10 + +## Circuit Description +Anode pins 1~10 of bar graph LED are connected to pin2, pin4, pin5, pin12, pin13, pin14, pin18, pin19, pin21, pin22, respectively. The cathode pins 1 through 10 of the bar graph LED are connected to GND pin gnd1 through 220kΩ resistors. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Set pin2, pin4, pin5, pin12, pin13, pin14, pin18, pin19, pin21, pin22 pin mode as OUTPUT +2. Turn on the bar graph LEDs only up to the threshold, which is 6 + +## Success Criteria +The test is successful when: +1. Pins 1 to 6 of the bar graph LED anodes receive HIGH signals, while pins 7 to 10 receive LOW signals. + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- The LED should turn on immediately during setup and stay on +- No actions are required in the loop function +- The pin number used should match the circuit diagram + +## Variants +This project may have different variants with the bar graph LED connected to different pins or using bar graph LED of different colors. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/esp32/level1/bar_led_basic/diagram_breadboard_esp.json b/esp32/level1/bar_led_basic/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..b7b3e8d456bd4a623294e405c36a38eb8c5fd8b6 --- /dev/null +++ b/esp32/level1/bar_led_basic/diagram_breadboard_esp.json @@ -0,0 +1,608 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Turn on bar graph LED", + "config": { + "1_pin": 2, + "2_pin": 3, + "3_pin": 4, + "4_pin": 5, + "5_pin": 6, + "6_pin": 7, + "7_pin": 8, + "8_pin": 9, + "9_pin": 10, + "10_pin": 11, + "led_color": "lime", + "gnd_pin": "GND.1" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -156.6, + "left": 406, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 67.8, + "left": 623.4, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -34.45, + "left": 652.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-led-bar-graph", + "id": "bar graph led1", + "top": -101, + "left": 734.6, + "rotate": 90, + "attrs": { + "color": "lime" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -24.85, + "left": 662.4, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -15.25, + "left": 672, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 4.8, + "left": 709.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": -34.45, + "left": 796.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -24.85, + "left": 787.2, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": -15.25, + "left": 777.6, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": 4.8, + "left": 738.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor9", + "top": 4.8, + "left": 719.45, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor10", + "top": 4.8, + "left": 729.05, + "rotate": 90, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "bar graph led1:A1", + "breadboard1:39t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A2", + "breadboard1:38t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A3", + "breadboard1:37t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A4", + "breadboard1:36t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A5", + "breadboard1:35t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A6", + "breadboard1:34t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A7", + "breadboard1:33t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A8", + "breadboard1:32t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A9", + "breadboard1:31t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A10", + "breadboard1:30t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C1", + "breadboard1:39b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C2", + "breadboard1:38b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C3", + "breadboard1:37b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C4", + "breadboard1:36b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C5", + "breadboard1:35b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C6", + "breadboard1:34b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C7", + "breadboard1:33b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C8", + "breadboard1:32b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C9", + "breadboard1:31b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C10", + "breadboard1:30b.f", + "", + [ + "$bb" + ] + ], + [ + "resistor5:1", + "breadboard1:39b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor5:2", + "breadboard1:45b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor6:1", + "breadboard1:38b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor6:2", + "breadboard1:44b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor7:1", + "breadboard1:37b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor7:2", + "breadboard1:43b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:26b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:32b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:25b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:31b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:24b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:30b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor9:1", + "breadboard1:34b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor9:2", + "breadboard1:bn.27", + "", + [ + "$bb" + ] + ], + [ + "resistor10:1", + "breadboard1:35b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor10:2", + "breadboard1:bn.28", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:43b.j", + "breadboard1:bn.35", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:44b.i", + "breadboard1:bn.36", + "green", + [ + "v0" + ] + ], + [ + "resistor8:1", + "breadboard1:36b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor8:2", + "breadboard1:bn.29", + "", + [ + "$bb" + ] + ], + [ + "resistor4:1", + "breadboard1:33b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor4:2", + "breadboard1:bn.26", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:45b.h", + "breadboard1:bn.37", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:26b.j", + "breadboard1:bn.21", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:25b.i", + "breadboard1:bn.20", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:24b.h", + "breadboard1:bn.19", + "green", + [ + "v0" + ] + ], + [ + "esp1:GND.1", + "breadboard1:bn.24", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:30t.d", + "esp1:D22", + "green", + [ + "v-105.6", + "h48" + ] + ], + [ + "breadboard1:31t.d", + "esp1:D21", + "green", + [ + "v-115.2", + "h57.6" + ] + ], + [ + "breadboard1:32t.d", + "esp1:D19", + "green", + [ + "v-124.8", + "h57.6" + ] + ], + [ + "breadboard1:33t.d", + "esp1:D18", + "green", + [ + "v-134.4", + "h57.6" + ] + ], + [ + "breadboard1:34t.d", + "esp1:D14", + "green", + [ + "v-96", + "h57.6" + ] + ], + [ + "breadboard1:35t.d", + "esp1:D13", + "green", + [ + "v-105.6", + "h57.6" + ] + ], + [ + "breadboard1:36t.d", + "esp1:D12", + "green", + [ + "v-115.2", + "h67.2" + ] + ], + [ + "breadboard1:37t.d", + "esp1:D5", + "green", + [ + "v-86.4", + "h67.2" + ] + ], + [ + "breadboard1:38t.d", + "esp1:D4", + "green", + [ + "v-76.8", + "h67.2" + ] + ], + [ + "breadboard1:39t.d", + "esp1:D2", + "green", + [ + "v-96", + "h67.2" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level1/bar_led_basic/diagram_esp.json b/esp32/level1/bar_led_basic/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..8bb5f3edccacc7e62dc0cba773bbe58e784d7f3a --- /dev/null +++ b/esp32/level1/bar_led_basic/diagram_esp.json @@ -0,0 +1,412 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Turn on bar graph LED", + "config": { + "1_pin": 2, + "2_pin": 3, + "3_pin": 4, + "4_pin": 5, + "5_pin": 6, + "6_pin": 7, + "7_pin": 8, + "8_pin": 9, + "9_pin": 10, + "10_pin": 11, + "led_color": "lime", + "gnd_pin": "GND.1" + }, + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 67.8, + "left": 517.8, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 109.85, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": 129.05, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 119.45, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-led-bar-graph", + "id": "bar graph led1", + "top": 110.4, + "left": 849.6, + "attrs": { + "color": "lime" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 138.65, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": 148.25, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": 157.85, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": 167.45, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": 177.05, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor9", + "top": 186.65, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor10", + "top": 196.25, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "resistor1:2", + "bar graph led1:C1", + "green", + [ + "v0" + ] + ], + [ + "resistor2:2", + "bar graph led1:C2", + "green", + [ + "v0" + ] + ], + [ + "resistor3:2", + "bar graph led1:C3", + "green", + [ + "v0" + ] + ], + [ + "resistor4:2", + "bar graph led1:C4", + "green", + [ + "v0" + ] + ], + [ + "resistor5:2", + "bar graph led1:C5", + "green", + [ + "v0" + ] + ], + [ + "resistor6:2", + "bar graph led1:C6", + "green", + [ + "v0" + ] + ], + [ + "resistor7:2", + "bar graph led1:C7", + "green", + [ + "v0" + ] + ], + [ + "resistor8:2", + "bar graph led1:C8", + "green", + [ + "v0" + ] + ], + [ + "resistor9:2", + "bar graph led1:C9", + "green", + [ + "v0" + ] + ], + [ + "resistor10:2", + "bar graph led1:C10", + "green", + [ + "v0" + ] + ], + [ + "esp1:GND.1", + "resistor10:1", + "black", + [ + "v-28.8", + "h365.1", + "v153.6" + ] + ], + [ + "esp1:GND.1", + "resistor9:1", + "black", + [ + "v-28.8", + "h365.1", + "v144" + ] + ], + [ + "esp1:GND.1", + "resistor8:1", + "black", + [ + "v-28.8", + "h365.1", + "v134.4" + ] + ], + [ + "esp1:GND.1", + "resistor7:1", + "black", + [ + "v-28.8", + "h365.1", + "v124.8" + ] + ], + [ + "esp1:GND.1", + "resistor6:1", + "black", + [ + "v-28.8", + "h365.1", + "v115.2" + ] + ], + [ + "esp1:GND.1", + "resistor5:1", + "black", + [ + "v-28.8", + "h365.1", + "v105.6" + ] + ], + [ + "esp1:GND.1", + "resistor4:1", + "black", + [ + "v-28.8", + "h365.1", + "v96" + ] + ], + [ + "esp1:GND.1", + "resistor3:1", + "black", + [ + "v-28.8", + "h365.1", + "v86.4" + ] + ], + [ + "esp1:GND.1", + "resistor2:1", + "black", + [ + "v-28.8", + "h365.1", + "v76.8" + ] + ], + [ + "esp1:GND.1", + "resistor1:1", + "black", + [ + "v-28.8", + "h365.1", + "v67.2" + ] + ], + [ + "bar graph led1:A1", + "esp1:D2", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A2", + "esp1:D4", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A3", + "esp1:D5", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A4", + "esp1:D12", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A5", + "esp1:D13", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A6", + "esp1:D14", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A7", + "esp1:D18", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A8", + "esp1:D19", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A9", + "esp1:D21", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A10", + "esp1:D22", + "green", + [ + "h0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level1/bar_led_basic/platformio.ini b/esp32/level1/bar_led_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..4b14a0930ca6087c8284aacc90dcbfaa12d4fdb8 --- /dev/null +++ b/esp32/level1/bar_led_basic/platformio.ini @@ -0,0 +1,29 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 + +lib_deps = + Arduino \ No newline at end of file diff --git a/esp32/level1/bar_led_basic/scenario.yaml b/esp32/level1/bar_led_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f9322786d0a07c762fad62d7e0d17819eb010d7c --- /dev/null +++ b/esp32/level1/bar_led_basic/scenario.yaml @@ -0,0 +1,86 @@ +author: Blind Author +description: Turn on the bar graph LED +name: Bar graph LED +steps: +- delay: 1000ms +- expect-pin: + part-id: bar graph led1 + pin: C1 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C2 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C3 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C4 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C5 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C6 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C7 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C8 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C9 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: C10 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A1 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A2 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A3 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A4 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A5 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A6 + value: 1 +- expect-pin: + part-id: bar graph led1 + pin: A7 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A8 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A9 + value: 0 +- expect-pin: + part-id: bar graph led1 + pin: A10 + value: 0 +version: 1.0 diff --git a/esp32/level1/bar_led_basic/src/main_esp.cpp b/esp32/level1/bar_led_basic/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bda4fc9ba6c2641962a6d214ad3dbd4e40cd8c42 --- /dev/null +++ b/esp32/level1/bar_led_basic/src/main_esp.cpp @@ -0,0 +1,27 @@ +/** + Use bar LED + 10 APR 2025 by Blind Author +*/ + +#include + +int pinList[] = {2, 4, 5, 12, 13, 14, 18, 19, 21, 22}; + +int threshold = 6; + +void setup() { + for (int i=0; i<10; i++) { + pinMode(pinList[i], OUTPUT); + } + + for (int i=0; i<10; i++) { + if (i < threshold) { + digitalWrite(pinList[i], HIGH); + } else { + digitalWrite(pinList[i], LOW); + } + } +} + +void loop() { +} \ No newline at end of file diff --git a/esp32/level1/bar_led_basic/wokwi.toml b/esp32/level1/bar_led_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level1/bar_led_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level1/buzzer_basic/.DS_Store b/esp32/level1/buzzer_basic/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ca640bab781462206d41e16e40cf43e8e1b7990e Binary files /dev/null and b/esp32/level1/buzzer_basic/.DS_Store differ diff --git a/esp32/level1/buzzer_basic/description_esp.md b/esp32/level1/buzzer_basic/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..cc0da4ecdecb77a12fd86cee970129356d6d9900 --- /dev/null +++ b/esp32/level1/buzzer_basic/description_esp.md @@ -0,0 +1,27 @@ +# Piezo Buzzer + +## Project Description +This is a simple ESP32 project that uses piezoelectric buzzer to play 262Hz tone. + +## Hardware Components +- ESP32 DevKit v1 +- Piezoelectric buzzer + +## Circuit Description +The piezo buzzer is connected to the ESP32. The positive pin is connected to pin2, the negative pin to gnd1. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Set the pin mode as OUTPUT +2. Continuously play 262Hz tone + +## Success Criteria +The test is successful when: +1. Piezo buzzer runs successfuly + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- In the loop function, make buzzer play 262Hz tone + +## Variants +There may be variants with buzzer, GND pin number and the pitch of the sound being played. \ No newline at end of file diff --git a/esp32/level1/buzzer_basic/diagram_breadboard_esp.json b/esp32/level1/buzzer_basic/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..a6629147cb8ec77a2c5d54fe6c77ca2452557d5d --- /dev/null +++ b/esp32/level1/buzzer_basic/diagram_breadboard_esp.json @@ -0,0 +1,77 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Play tone with piezo buzzer", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -243, + "left": -198.8, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-buzzer", + "id": "piezoelectric buzzer1", + "top": -208.8, + "left": 88.2, + "attrs": { + "volume": "0.1" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "piezoelectric buzzer1:1", + "breadboard1:31b.f", + "", + [ + "$bb" + ] + ], + [ + "piezoelectric buzzer1:2", + "breadboard1:32b.f", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:31b.g", + "esp1:GND.1", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:32b.g", + "esp1:D2", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level1/buzzer_basic/diagram_esp.json b/esp32/level1/buzzer_basic/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..15be6810903007300f652590d2efda755db6ac2b --- /dev/null +++ b/esp32/level1/buzzer_basic/diagram_esp.json @@ -0,0 +1,54 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Play tone with piezo buzzer", + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-buzzer", + "id": "piezoelectric buzzer1", + "top": -141.6, + "left": 97.8, + "attrs": { + "volume": "0.1" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "piezoelectric buzzer1:1", + "esp1:GND.1", + "green", + [ + "v0" + ] + ], + [ + "piezoelectric buzzer1:2", + "esp1:D2", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level1/buzzer_basic/platformio.ini b/esp32/level1/buzzer_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..427aca4c4145d8fe873ae0607029adba08f16fe0 --- /dev/null +++ b/esp32/level1/buzzer_basic/platformio.ini @@ -0,0 +1,27 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno +lib_deps = + Arduino + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 +lib_deps = + Arduino \ No newline at end of file diff --git a/esp32/level1/buzzer_basic/scenario.yaml b/esp32/level1/buzzer_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..31e2db1ddea8414a7b831dabc015de55c0417509 --- /dev/null +++ b/esp32/level1/buzzer_basic/scenario.yaml @@ -0,0 +1,12 @@ +author: Blind Author +description: Control a servo motor +name: Servo Motor Control +steps: +- delay: 500ms +- wait-pin: + timeout: 1000 + interval: 100 + part-id: piezoelectric buzzer1 + pin: 2 + value: 1 +version: 1.0 diff --git a/esp32/level1/buzzer_basic/src/main_esp.cpp b/esp32/level1/buzzer_basic/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d2fdff6a01c7509a5eea978b5629269574e05792 --- /dev/null +++ b/esp32/level1/buzzer_basic/src/main_esp.cpp @@ -0,0 +1,17 @@ +/* + Use a piezoelectric buzzer to play 262Hz tone. + 4 APR 2025 by Blind Author +*/ + +#include + +const int BUZZER_PIN = 2; + +void setup() { + pinMode(BUZZER_PIN, OUTPUT); +} + +void loop() { + tone(BUZZER_PIN, 262, 250); +} + diff --git a/esp32/level1/buzzer_basic/wokwi.toml b/esp32/level1/buzzer_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level1/buzzer_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level1/distance_sensor_basic/.DS_Store b/esp32/level1/distance_sensor_basic/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..8531300c324ff724eac48146dece26ace4e36ec8 Binary files /dev/null and b/esp32/level1/distance_sensor_basic/.DS_Store differ diff --git a/esp32/level1/distance_sensor_basic/description_esp.md b/esp32/level1/distance_sensor_basic/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..c00351c3e85c3239f2e81f14a98f5c550c282258 --- /dev/null +++ b/esp32/level1/distance_sensor_basic/description_esp.md @@ -0,0 +1,28 @@ +# Distance Sensor + +## Project Description +This is a simple ESP32 project that uses Ultrasonic distance sensor to measure the distance. + +## Hardware Components +- ESP32 DevKit v1 +- Ultrasonic Distance Sensor + +## Circuit Description +The ultrasonic distance sensor is connected to the ESP32. The VCC pin is connected to 3V3, the GND pin to gnd1, the TRIG pin to pin4, and the ECHO pin to pin2. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Initialize serial communication +2. Continuously trigger and read the Ultrasonic distance sensor +3. Change the value to the centimeter and print in the format: "Distance in CM: {value}" + +## Success Criteria +The test is successful when: +1. Correct distance value in centimeter is printed in the serial monitor. + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- To convert the distance sensor value to centimeters, divide it by 58. + +## Variants +There may be variants with init distance value and ECHO, TRIG, GND pin number. \ No newline at end of file diff --git a/esp32/level1/distance_sensor_basic/diagram_breadboard_esp.json b/esp32/level1/distance_sensor_basic/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..2368c15c70d8f744ed7abc92cc1d92417a1ce9e1 --- /dev/null +++ b/esp32/level1/distance_sensor_basic/diagram_breadboard_esp.json @@ -0,0 +1,115 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read value of distance sensor", + "config": { + "distance_echo_pin": "2", + "distance_trig_pin": "3", + "gnd_pin": "GND.3", + "distance_init": "398" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -252.6, + "left": -64.4, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-hc-sr04", + "id": "ultrasonic distance sensor1", + "top": -228.9, + "left": 178.3, + "attrs": { + "distance": "398" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "ultrasonic distance sensor1:VCC", + "breadboard1:31b.f", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:TRIG", + "breadboard1:32b.f", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:ECHO", + "breadboard1:33b.f", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:GND", + "breadboard1:34b.f", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:34b.g", + "esp1:GND.1", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:31b.g", + "esp1:3V3", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:32b.g", + "esp1:D4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:33b.g", + "esp1:D2", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level1/distance_sensor_basic/diagram_esp.json b/esp32/level1/distance_sensor_basic/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..f176856038588dcce33fcadf95ac88a5c5e27427 --- /dev/null +++ b/esp32/level1/distance_sensor_basic/diagram_esp.json @@ -0,0 +1,72 @@ +{ + "version": 1, + "author": "Blind Author", + "editor": "wokwi", + "description": "Read value of distance sensor", + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "arduino uno1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-hc-sr04", + "id": "ultrasonic distance sensor1", + "top": 43.5, + "left": 288.9, + "rotate": 90, + "attrs": { + "distance": "398" + } + } + ], + "connections": [ + [ + "arduino uno1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "arduino uno1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "ultrasonic distance sensor1:VCC", + "arduino uno1:3V3", + "red", + [ + "h0" + ] + ], + [ + "ultrasonic distance sensor1:GND", + "arduino uno1:GND.1", + "black", + [ + "h0" + ] + ], + [ + "ultrasonic distance sensor1:TRIG", + "arduino uno1:D4", + "green", + [ + "h0" + ] + ], + [ + "ultrasonic distance sensor1:ECHO", + "arduino uno1:D2", + "green", + [ + "h0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level1/distance_sensor_basic/platformio.ini b/esp32/level1/distance_sensor_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..931f8e51c8b316966aadabc57f6e4c0a1e61204c --- /dev/null +++ b/esp32/level1/distance_sensor_basic/platformio.ini @@ -0,0 +1,26 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 + +lib_deps = + Arduino \ No newline at end of file diff --git a/esp32/level1/distance_sensor_basic/scenario.yaml b/esp32/level1/distance_sensor_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..df6bca32ace6e8c04cefc3d6687fea13049013f6 --- /dev/null +++ b/esp32/level1/distance_sensor_basic/scenario.yaml @@ -0,0 +1,12 @@ +author: Blind Author +description: Measure distance with Ultrasonic distance sensor +name: Distance Sensor +test-values: + - part-type: wokwi-hc-sr04 + attr-name: distance + value: "400" + esp_value: "398" +steps: +- delay: 10ms +- wait-serial: 'Distance in CM: 403' +version: 1.0 diff --git a/esp32/level1/distance_sensor_basic/src/main_esp.cpp b/esp32/level1/distance_sensor_basic/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b0b252d5a703671d9b99a24046ffcee9341f3cf0 --- /dev/null +++ b/esp32/level1/distance_sensor_basic/src/main_esp.cpp @@ -0,0 +1,26 @@ +/** + Measure distance with Ultrasonic distance sensor. + 3 APR 2025 by Blind Author +*/ +#include + +#define PIN_TRIG 4 +#define PIN_ECHO 2 + +void setup() { + Serial.begin(115200); + pinMode(PIN_TRIG, OUTPUT); + pinMode(PIN_ECHO, INPUT); +} + +void loop() { + digitalWrite(PIN_TRIG, HIGH); + delayMicroseconds(10); + digitalWrite(PIN_TRIG, LOW); + + int duration = pulseIn(PIN_ECHO, HIGH); + Serial.print("Distance in CM: "); + Serial.println(duration / 58); + + delay(500); +} \ No newline at end of file diff --git a/esp32/level1/distance_sensor_basic/wokwi.toml b/esp32/level1/distance_sensor_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level1/distance_sensor_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level1/humidity_sensor_basic/.DS_Store b/esp32/level1/humidity_sensor_basic/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b88cd06c171a6d6832fc043fd03fd2cd657ca877 Binary files /dev/null and b/esp32/level1/humidity_sensor_basic/.DS_Store differ diff --git a/esp32/level1/humidity_sensor_basic/description_esp.md b/esp32/level1/humidity_sensor_basic/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..2d07b3e374fc35e7284f149527b33a9a255b94e0 --- /dev/null +++ b/esp32/level1/humidity_sensor_basic/description_esp.md @@ -0,0 +1,25 @@ +# Humidity Sensor Basic + +## Project Description +This is a simple ESP32 project that uses dht22 sensor to measure the humidity. + +## Hardware Components +- ESP32 DevKit v1 +- DHT22 sensor + +## Circuit Description +The DHT22 sensor is connected to an ESP32. The VCC pin is connected to the 5V pin on the ESP32, and the GND pin is connected to the GND2 pin. The data pin is connected to digital pin 2 on the ESP32. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Initialize serial monitor +2. Initialize and begin DHT sensor +3. Continuously read the DHT sensor's humidity value +4. Print humidity to the serial monitor in the following format: "Humidity: {humidity value}", for example: "Humidity: 40.0" + +## Success Criteria +The test is successful when: +1. The correct humidity value is printed to the serial monitor. + +## Notes for Implementation +- Use Arduino.h library for arduino core. diff --git a/esp32/level1/humidity_sensor_basic/diagram_breadboard_esp.json b/esp32/level1/humidity_sensor_basic/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..5c030213910251e9a9d954b45a5b7f3cf12b3754 --- /dev/null +++ b/esp32/level1/humidity_sensor_basic/diagram_breadboard_esp.json @@ -0,0 +1,102 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read humidity sensor value", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "bb1", + "top": 275.4, + "left": -150.8, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-dht22", + "id": "dht22 sensor1", + "top": 211.5, + "left": 253.8, + "attrs": { + "humidity": "64.5" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "dht22 sensor1:VCC", + "bb1:42t.a", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:SDA", + "bb1:43t.a", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:NC", + "bb1:44t.a", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:GND", + "bb1:45t.a", + "", + [ + "$bb" + ] + ], + [ + "bb1:43t.c", + "esp1:D2", + "green", + [ + "v38.4", + "h0" + ] + ], + [ + "bb1:42t.c", + "esp1:3V3", + "red", + [ + "v0" + ] + ], + [ + "bb1:45t.c", + "esp1:GND.2", + "black", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level1/humidity_sensor_basic/diagram_esp.json b/esp32/level1/humidity_sensor_basic/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..1557c559e35ba5353103929e26d6255fdc7fe27c --- /dev/null +++ b/esp32/level1/humidity_sensor_basic/diagram_esp.json @@ -0,0 +1,69 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read humidity sensor value", + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-dht22", + "id": "dht22 sensor1", + "top": -201.3, + "left": 100.2, + "attrs": { + "humidity": "64.5" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "dht22 sensor1:VCC", + "esp1:3V3", + "red", + [ + "v48", + "h-134.4", + "v259.2", + "h182.4" + ] + ], + [ + "dht22 sensor1:GND", + "esp1:GND.2", + "black", + [ + "v48", + "h144", + "v268.8", + "h19.2" + ] + ], + [ + "dht22 sensor1:SDA", + "esp1:D2", + "green", + [ + "v76.8", + "h115.3" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level1/humidity_sensor_basic/platformio.ini b/esp32/level1/humidity_sensor_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..14cb4b1e4866c32d1af21fb5d40536896fecb830 --- /dev/null +++ b/esp32/level1/humidity_sensor_basic/platformio.ini @@ -0,0 +1,32 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno +lib_deps = + Arduino + DHT sensor library + DHT22 + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 + +lib_deps = + Arduino + DHT sensor library + DHT22 \ No newline at end of file diff --git a/esp32/level1/humidity_sensor_basic/scenario.yaml b/esp32/level1/humidity_sensor_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..25c616bc8beb5654f84672c4d09ce5875b85ce79 --- /dev/null +++ b/esp32/level1/humidity_sensor_basic/scenario.yaml @@ -0,0 +1,12 @@ +author: Blind Author +description: Read humidity sensor value +name: Humidity Sensor Basic +steps: +- delay: 100ms +- wait-serial: 'Humidity: 64.5' +test-values: +- attr-name: humidity + part-type: wokwi-dht22 + value: '64.5' + esp_value: '64.5' +version: 1.0 diff --git a/esp32/level1/humidity_sensor_basic/src/main_esp.cpp b/esp32/level1/humidity_sensor_basic/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ac2057ba7444dd0b6386e455f6e3e86ce20b949b --- /dev/null +++ b/esp32/level1/humidity_sensor_basic/src/main_esp.cpp @@ -0,0 +1,28 @@ +/** + Read the humidity sensor value + 03 MAY 2025 by Blind Author +*/ + +#include + +#include "DHT.h" + +#define DHTTYPE DHT22 + +#define DHTPIN 2 + +DHT dht(DHTPIN, DHTTYPE); + +void setup() { + Serial.begin(9600); + dht.begin(); +} + +void loop() { + float humidity = dht.readHumidity(); + + Serial.print("Humidity: "); + Serial.println(humidity); + + delay(1000); +} \ No newline at end of file diff --git a/esp32/level1/humidity_sensor_basic/wokwi.toml b/esp32/level1/humidity_sensor_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level1/humidity_sensor_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level1/led_RGB_basic/.DS_Store b/esp32/level1/led_RGB_basic/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..00afa14a2b57568db7029421611e80d2a1274151 Binary files /dev/null and b/esp32/level1/led_RGB_basic/.DS_Store differ diff --git a/esp32/level1/led_RGB_basic/description_esp.md b/esp32/level1/led_RGB_basic/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..9658494704181bf914d7f6eb09770413ab60a554 --- /dev/null +++ b/esp32/level1/led_RGB_basic/description_esp.md @@ -0,0 +1,33 @@ +# LED RGB + +## Project Description +This is a simple ESP32 project that turns on an RGB LED. + +## Hardware Components +- ESP32 DevKit v1 +- RGB LED +- 220Ω resistor * 3 + +## Circuit Description +The R, G, B pin of the RGB LED is connected to the pin5, pin4, pin2 pin of the ESP32 through a 220Ω current-limiting resistor. The common pin of the RGB LED is connected to 3V3. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Set pin5, pin4, pin2 pin mode to OUTPUT +2. Considering that the LED's common pin is connected to 3V3, turn on only the blue segment at full brightness. + +## Success Criteria +The test is successful when: +1. Only the blue light of the RGB LED is fully on. + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- The LED should turn on immediately during setup and stay on +- No actions are required in the loop function +- The pin number used should match the circuit diagram + +## Variants +This project may have different variants with the RGB LED connected to different pins. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/esp32/level1/led_RGB_basic/diagram_breadboard_esp.json b/esp32/level1/led_RGB_basic/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..0c05b1a676ea3ffb49723b9077973b22e8da2395 --- /dev/null +++ b/esp32/level1/led_RGB_basic/diagram_breadboard_esp.json @@ -0,0 +1,179 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Turn on RGB LED", + "config": { + "R_pin": 4, + "G_pin": 3, + "B_pin": 2 + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -137.4, + "left": 502, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 115.8, + "left": 527.4, + "attrs": {} + }, + { + "type": "wokwi-rgb-led", + "id": "rgb led1", + "top": -120.8, + "left": 653.9, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -33.6, + "left": 633.05, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -33.6, + "left": 652.25, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -33.6, + "left": 661.85, + "rotate": 90, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "rgb led1:R", + "breadboard1:15t.b", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:COM", + "breadboard1:16t.c", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:G", + "breadboard1:17t.b", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:B", + "breadboard1:18t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:15t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:15b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:17t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:17b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:18t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:18b.h", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:17b.j", + "esp1:D4", + "green", + [ + "v86.4", + "h76.8" + ] + ], + [ + "breadboard1:16t.e", + "esp1:3V3", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:15b.j", + "esp1:D5", + "green", + [ + "v0" + ] + ], + [ + "esp1:D2", + "breadboard1:18b.j", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level1/led_RGB_basic/diagram_esp.json b/esp32/level1/led_RGB_basic/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..76f823f0ea4c1d3812747a36da258012f68061a2 --- /dev/null +++ b/esp32/level1/led_RGB_basic/diagram_esp.json @@ -0,0 +1,132 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Turn on RGB LED", + "config": { + "R_pin": 4, + "G_pin": 3, + "B_pin": 2 + }, + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 115.8, + "left": 527.4, + "attrs": {} + }, + { + "type": "wokwi-rgb-led", + "id": "rgb led1", + "top": -92, + "left": 644.3, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 4.8, + "left": 623.45, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": 4.8, + "left": 642.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 4.8, + "left": 661.85, + "rotate": 90, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "arduino uno1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "arduino uno1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "rgb led1:COM", + "esp1:3V3", + "green", + [ + "v0" + ] + ], + [ + "rgb led1:R", + "resistor1:1", + "green", + [ + "v19.2" + ] + ], + [ + "resistor2:1", + "rgb led1:G", + "green", + [ + "h0" + ] + ], + [ + "resistor3:1", + "rgb led1:B", + "green", + [ + "h0" + ] + ], + [ + "resistor1:2", + "esp1:D5", + "green", + [ + "h0", + "v66", + "h86.4" + ] + ], + [ + "resistor2:2", + "esp1:D4", + "green", + [ + "h0", + "v56.4", + "h76.8" + ] + ], + [ + "resistor3:2", + "esp1:D2", + "green", + [ + "h0", + "v46.8", + "h76.8" + ] + ] + ] +} \ No newline at end of file diff --git a/esp32/level1/led_RGB_basic/platformio.ini b/esp32/level1/led_RGB_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..931f8e51c8b316966aadabc57f6e4c0a1e61204c --- /dev/null +++ b/esp32/level1/led_RGB_basic/platformio.ini @@ -0,0 +1,26 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 + +lib_deps = + Arduino \ No newline at end of file diff --git a/esp32/level1/led_RGB_basic/scenario.yaml b/esp32/level1/led_RGB_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9113a3e59c883f2523bb1719e51dd162aa185007 --- /dev/null +++ b/esp32/level1/led_RGB_basic/scenario.yaml @@ -0,0 +1,22 @@ +author: Blind Author +description: Show blue light with RGB LED +name: RGB LED +steps: +- delay: 500ms +- expect-pin: + part-id: rgb led1 + pin: R + value: 1 +- expect-pin: + part-id: rgb led1 + pin: G + value: 1 +- expect-pin: + part-id: rgb led1 + pin: B + value: 0 +- expect-pin: + part-id: rgb led1 + pin: COM + value: 1 +version: 1.0 diff --git a/esp32/level1/led_RGB_basic/src/main_esp.cpp b/esp32/level1/led_RGB_basic/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c9734b78c642a8eeab81aae431630954685ba38a --- /dev/null +++ b/esp32/level1/led_RGB_basic/src/main_esp.cpp @@ -0,0 +1,23 @@ +/** + Turns on a RGB LED connected to a specified pin. + 3 APR 2025 by Blind Author +*/ + +#include + +const int R = 5; +const int G = 4; +const int B = 2; + +void setup() { + pinMode(R, OUTPUT); + pinMode(G, OUTPUT); + pinMode(B, OUTPUT); + + analogWrite(R, 255); + analogWrite(G, 255); + analogWrite(B, 0); +} + +void loop() { +} diff --git a/esp32/level1/led_RGB_basic/wokwi.toml b/esp32/level1/led_RGB_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level1/led_RGB_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level1/led_blink_basic/.DS_Store b/esp32/level1/led_blink_basic/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..3789e86590c20247649770bb2e2d941faf10037a Binary files /dev/null and b/esp32/level1/led_blink_basic/.DS_Store differ diff --git a/esp32/level1/led_blink_basic/description_esp.md b/esp32/level1/led_blink_basic/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..3ebd820ce4ca189e6cebc97a163eb5e352141e64 --- /dev/null +++ b/esp32/level1/led_blink_basic/description_esp.md @@ -0,0 +1,32 @@ +# Blink LED + +## Project Description +This is a simple ESP32 project that makes an LED connected to a specific pin blink on and off at regular intervals. + +## Hardware Components +- ESP32 DevKit v1 +- LED +- 220Ω resistor +- Breadboard + +## Circuit Description +The LED is connected to pin of the ESP32 through a 220Ω current-limiting resistor. The anode of the LED is connected to pin 13 via the resistor. The cathode of the LED is connected to gnd1. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Set the pin 13 mode as OUTPUT +2. Begin blinking the LED with the following pattern: + - Turn ON for 1 second + - Turn OFF for 1 second + - Repeat indefinitely + +## Success Criteria +The test is successful when: +1. The LED turns on and off at regular 1-second intervals +2. The blinking pattern continues indefinitely + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". + +## Notes for Implementation +- Use Arduino.h library for arduino core. \ No newline at end of file diff --git a/esp32/level1/led_blink_basic/diagram_breadboard_esp.json b/esp32/level1/led_blink_basic/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..bf1c185e94ebf955cd5bfe3bd854d80081f88d89 --- /dev/null +++ b/esp32/level1/led_blink_basic/diagram_breadboard_esp.json @@ -0,0 +1,95 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Turn on LED", + "config": { + "led_pin": 13, + "led_color": "red", + "gnd_pin": "GND.2" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -156.6, + "left": 2.8, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 120, + "left": 20, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -15.25, + "left": 163.2, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-led", + "id": "led1", + "top": -80.4, + "left": 138.2, + "attrs": { + "color": "red" + } + } + ], + "connections": [ + [ + "led1:A", + "breadboard1:15b.f", + "", + [ + "$bb" + ] + ], + [ + "led1:C", + "breadboard1:14b.f", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:15b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:21b.i", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:14b.i", + "esp1:GND.2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:21b.j", + "esp1:D13", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level1/led_blink_basic/diagram_esp.json b/esp32/level1/led_blink_basic/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..331ba8539a180395fb4bd1511428fcf5149bd49a --- /dev/null +++ b/esp32/level1/led_blink_basic/diagram_esp.json @@ -0,0 +1,57 @@ +{ + "version": 1, + "author": "Blind Author", + "editor": "Blind Author", + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": -201, + "left": 9, + "attrs": {} + }, + { + "type": "wokwi-led", + "id": "led1", + "top": -301.2, + "left": 51.8, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -245.65, + "left": 86.4, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "esp1:D13", + "resistor2:2", + "green", + [ + "v0" + ] + ], + [ + "resistor2:1", + "led1:A", + "green", + [ + "v0" + ] + ], + [ + "esp1:GND.1", + "led1:C", + "black", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level1/led_blink_basic/platformio.ini b/esp32/level1/led_blink_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..931f8e51c8b316966aadabc57f6e4c0a1e61204c --- /dev/null +++ b/esp32/level1/led_blink_basic/platformio.ini @@ -0,0 +1,26 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 + +lib_deps = + Arduino \ No newline at end of file diff --git a/esp32/level1/led_blink_basic/scenario.yaml b/esp32/level1/led_blink_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..bc0bb61ff0d16983dc7aed707137cefe7b6b87b0 --- /dev/null +++ b/esp32/level1/led_blink_basic/scenario.yaml @@ -0,0 +1,49 @@ +author: Blind Author +description: Blink LED connected to a specific Arduino pin +name: Blink LED +steps: +- delay: 200ms +- wait-multi-pin: + timeout: 1300 + interval: 100 + pins: + - part-id: led1 + pin: C + value: 0 + - part-id: led1 + pin: A + value: 1 +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: led1 + pin: C + value: 0 + - part-id: led1 + pin: A + value: 0 +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: led1 + pin: C + value: 0 + - part-id: led1 + pin: A + value: 1 +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: led1 + pin: C + value: 0 + - part-id: led1 + pin: A + value: 0 +version: 1.0 diff --git a/esp32/level1/led_blink_basic/src/main_esp.cpp b/esp32/level1/led_blink_basic/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..309475ce1773a651a5b9318442c4866719cd9e1a --- /dev/null +++ b/esp32/level1/led_blink_basic/src/main_esp.cpp @@ -0,0 +1,19 @@ +/** + Turns on an LED connected to a specified pin. + 31 MAR 2025 by Blind Author +*/ + +#include + +const int LED_PIN = 13; + +void setup() { + pinMode(LED_PIN, OUTPUT); +} + +void loop() { + digitalWrite(LED_PIN, HIGH); + delay(1000); + digitalWrite(LED_PIN, LOW); + delay(1000); +} \ No newline at end of file diff --git a/esp32/level1/led_blink_basic/wokwi.toml b/esp32/level1/led_blink_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level1/led_blink_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level1/photoresistor_basic/.DS_Store b/esp32/level1/photoresistor_basic/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..65e06b1da3d0ba1279cd3a6b8ad6d086efd4bc52 Binary files /dev/null and b/esp32/level1/photoresistor_basic/.DS_Store differ diff --git a/esp32/level1/photoresistor_basic/description_esp.md b/esp32/level1/photoresistor_basic/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..67767b0d0375f5b64d64ac693cf3502d85494805 --- /dev/null +++ b/esp32/level1/photoresistor_basic/description_esp.md @@ -0,0 +1,28 @@ +# Photoresistor + +## Project Description +This is a simple ESP32 project that uses 4 pin photoresistoer sensor module to sense the light. + +## Hardware Components +- ESP32 DevKit v1 +- Photoresistor sensor module + +## Circuit Description +The photoresistor sensor module is connected to the ESP32. The VCC pin is connected to 3V3, the GND pin to gnd2, and the AO pin to pin 34. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Initialize serial communication +2. Continuously read the photoresistor sensor module, and print the value in the format: "LDR Value: {value}". + +## Success Criteria +The test is successful when: +1. Correct LDR value is printed in the serial monitor. + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- In the loop function, read the photoresistor, and print it to the serial monitor. +- Delay 500ms in every loop. + +## Variants +There may be variants with init lux value and pin number. \ No newline at end of file diff --git a/esp32/level1/photoresistor_basic/diagram_breadboard_esp.json b/esp32/level1/photoresistor_basic/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..cce8d12d5db8c535d20ad70501914e54ba3a55a9 --- /dev/null +++ b/esp32/level1/photoresistor_basic/diagram_breadboard_esp.json @@ -0,0 +1,107 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read value of photoresistor", + "config": { + "photoresistor_pin": "A2", + "lux_init": "500", + "gnd_pin": "GND.2" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -137.4, + "left": -26, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 87, + "left": 47.4, + "attrs": {} + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor1", + "top": -125.1, + "left": 90.5, + "rotate": 90, + "attrs": { + "lux": "500" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "photoresistor1:VCC", + "breadboard1:21b.g", + "", + [ + "$bb" + ] + ], + [ + "photoresistor1:GND", + "breadboard1:20b.g", + "", + [ + "$bb" + ] + ], + [ + "photoresistor1:DO", + "breadboard1:19b.g", + "", + [ + "$bb" + ] + ], + [ + "photoresistor1:AO", + "breadboard1:18b.g", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:21b.h", + "esp1:3V3", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:20b.h", + "esp1:GND.2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:18b.h", + "esp1:D34", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level1/photoresistor_basic/diagram_esp.json b/esp32/level1/photoresistor_basic/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..d902e31659d863939329271da33a550a87543e20 --- /dev/null +++ b/esp32/level1/photoresistor_basic/diagram_esp.json @@ -0,0 +1,68 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read value of photoresistor", + "config": { + "photoresistor_pin": "34", + "lux": "4950", + "gnd_pin": "GND.2" + }, + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 87, + "left": 47.4, + "attrs": {} + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor1", + "top": 3.2, + "left": 96.8, + "attrs": { + "lux": "4950" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "photoresistor1:VCC", + "esp1:3V3", + "red", + [ + "h76.8", + "v115.2" + ] + ], + [ + "photoresistor1:GND", + "esp1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "photoresistor1:AO", + "esp1:D34", + "green", + [ + "h0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level1/photoresistor_basic/platformio.ini b/esp32/level1/photoresistor_basic/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..931f8e51c8b316966aadabc57f6e4c0a1e61204c --- /dev/null +++ b/esp32/level1/photoresistor_basic/platformio.ini @@ -0,0 +1,26 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 + +lib_deps = + Arduino \ No newline at end of file diff --git a/esp32/level1/photoresistor_basic/scenario.yaml b/esp32/level1/photoresistor_basic/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fe9e8208726d0a6671d008c8fd46cb354b4b1c60 --- /dev/null +++ b/esp32/level1/photoresistor_basic/scenario.yaml @@ -0,0 +1,12 @@ +author: Blind Author +description: Read value of photoresistor +name: Photoresistor +test-values: + - part-type: wokwi-photoresistor-sensor + attr-name: lux + value: "500" + esp_value: "4950" +steps: +- delay: 10ms +- wait-serial: 'LDR Value: 250' +version: 1.0 diff --git a/esp32/level1/photoresistor_basic/src/main_esp.cpp b/esp32/level1/photoresistor_basic/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bac5474a965ea79c2d215e9817d19652398234b1 --- /dev/null +++ b/esp32/level1/photoresistor_basic/src/main_esp.cpp @@ -0,0 +1,19 @@ +/** + Read photoresistor value and write to serial monitor + 2 APR 2025 by Blind Author +*/ + +#include + +#define LDR_PIN 34 + +void setup() { + Serial.begin(9600); +} + +void loop() { + int ldrValue = analogRead(LDR_PIN); + Serial.print("LDR Value: "); + Serial.println(ldrValue); + delay(500); +} diff --git a/esp32/level1/photoresistor_basic/wokwi.toml b/esp32/level1/photoresistor_basic/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level1/photoresistor_basic/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level2/accelerometer/description_esp.md b/esp32/level2/accelerometer/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..3b7c847a6a6f335bfa787f97d78984d33b6c2bc9 --- /dev/null +++ b/esp32/level2/accelerometer/description_esp.md @@ -0,0 +1,31 @@ +# Accelerometer + +## Project Description +This is an ESP32 project that uses MPU6050 6-axis accelerometer & gyro sensor to measure the acceleration. + +## Hardware Components +- ESP32 DevKit v1 +- MPU6050 6-axis Accel & Gyro Sensor + +## Circuit Description +The MPU6050 sensor is connected to the ESP32. The VCC pin is connected to 3V3, the GND pin to gnd2, the SCL pin to pin22, and the SDA pin to pin21. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Initialize serial communication +2. Check if the MPU sensor can be initialized successfully, and print 'MPU6050 ready!' to the serial monitor +3. Continuously read the accelerometer data from the MPU6050 sensor +4. Print the X, Y, and Z axis acceleration values in m/s² to the serial monitor, for example: 'X: 2.45, Y: 1.96, Z: 3.43 m/s^2' + +## Success Criteria +The test is successful when: +1. Correct X, Y, Z accelerometer result is printed to the serial monitor. + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- Use Adafruit_MPU6050.h, Adafruit_Sensor.h, Wire.h libraries. +- Delay 500ms in every loop. +- MPU6050 has I2C interface. + +## Variants +There may be variants with GND connected to different pin. \ No newline at end of file diff --git a/esp32/level2/accelerometer/diagram_breadboard_esp.json b/esp32/level2/accelerometer/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..16382764fce18df72b4375ea2914e8f5fbf0da59 --- /dev/null +++ b/esp32/level2/accelerometer/diagram_breadboard_esp.json @@ -0,0 +1,160 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read value of MPU6050", + "config": { + "scl_pin": "A5", + "sda_pin": "A4", + "gnd_pin": "GND.3" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": 208.2, + "left": -189.2, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-mpu6050", + "id": "mpu6050 6-axis accel & gyro sensor1", + "top": 291.82, + "left": 117.52, + "attrs": {} + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:INT", + "breadboard1:31t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:AD0", + "breadboard1:32t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:XCL", + "breadboard1:33t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:XDA", + "breadboard1:34t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SDA", + "breadboard1:35t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SCL", + "breadboard1:36t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:GND", + "breadboard1:37t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:VCC", + "breadboard1:38t.e", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:38t.c", + "breadboard1:tp.30", + "green", + [ + "v0" + ] + ], + [ + "esp1:3V3", + "breadboard1:tp.25", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:37t.d", + "breadboard1:tn.29", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:36t.d", + "esp1:D22", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:35t.d", + "esp1:D21", + "green", + [ + "v0" + ] + ], + [ + "esp1:GND.2", + "breadboard1:tn.27", + "black", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level2/accelerometer/diagram_esp.json b/esp32/level2/accelerometer/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..c36a6a2173c5abe789d47813188d3a68836de1df --- /dev/null +++ b/esp32/level2/accelerometer/diagram_esp.json @@ -0,0 +1,77 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read value of MPU6050", + "config": { + "scl_pin": "A5", + "sda_pin": "A4", + "gnd_pin": "GND.3" + }, + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-mpu6050", + "id": "mpu6050 6-axis accel & gyro sensor1", + "top": 234.22, + "left": 117.52, + "attrs": {} + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "esp1:GND.2", + "mpu6050 6-axis accel & gyro sensor1:GND", + "black", + [ + "v38.3", + "h32.7" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:VCC", + "esp1:3V3", + "red", + [ + "v-38.4", + "h-67.12" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SCL", + "esp1:D22", + "green", + [ + "v-28.8", + "h67.28" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SDA", + "esp1:D21", + "green", + [ + "v-38.4", + "h67.28" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level2/accelerometer/platformio.ini b/esp32/level2/accelerometer/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..9f4f67caf072e2b7fb217a335a48546699ef7a89 --- /dev/null +++ b/esp32/level2/accelerometer/platformio.ini @@ -0,0 +1,30 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno +lib_deps = + Arduino + Adafruit MPU6050 + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 + +lib_deps = + Arduino + Adafruit MPU6050 \ No newline at end of file diff --git a/esp32/level2/accelerometer/scenario.yaml b/esp32/level2/accelerometer/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..25d55bd871207e58068e05777754d5428982a6f4 --- /dev/null +++ b/esp32/level2/accelerometer/scenario.yaml @@ -0,0 +1,45 @@ +author: Blind Author +description: Measure 3-axis acceleration with accelerometer +name: Accelerometer +steps: +- wait-serial: MPU6050 ready! +- set-control: + control: accelX + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 0.25 +- set-control: + control: accelY + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 0.2 +- set-control: + control: accelZ + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 0.35 +- wait-serial: 'X: 2.45, Y: 1.96, Z: 3.43 m/s^2' +- set-control: + control: accelX + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 1.35 +- set-control: + control: accelY + part-id: mpu6050 6-axis accel & gyro sensor1 + value: -1.15 +- set-control: + control: accelZ + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 2 +- wait-serial: 'X: 13.24, Y: -11.28, Z: 19.61 m/s^2' +- set-control: + control: accelX + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 2 +- set-control: + control: accelY + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 0.95 +- set-control: + control: accelZ + part-id: mpu6050 6-axis accel & gyro sensor1 + value: -0.85 +- wait-serial: 'X: 19.61, Y: 9.32, Z: -8.34 m/s^2' +version: 1.0 diff --git a/esp32/level2/accelerometer/src/main_esp.cpp b/esp32/level2/accelerometer/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7030ce23d86c46bb0a6b4fd357a7aa94090c2cc3 --- /dev/null +++ b/esp32/level2/accelerometer/src/main_esp.cpp @@ -0,0 +1,36 @@ +/** + Measure 3-axis acceleration with accelerometer + 10 APR 2025 by Blind Author +*/ + +#include +#include +#include +#include + +Adafruit_MPU6050 mpu; + +void setup(void) { + Serial.begin(115200); + + while (!mpu.begin()) { + Serial.println("MPU6050 not connected!"); + delay(1000); + } + Serial.println("MPU6050 ready!"); +} + +sensors_event_t event; + +void loop() { + mpu.getAccelerometerSensor()->getEvent(&event); + + Serial.print("X: "); + Serial.print(event.acceleration.x); + Serial.print(", Y: "); + Serial.print(event.acceleration.y); + Serial.print(", Z: "); + Serial.print(event.acceleration.z); + Serial.println(" m/s^2"); + delay(500); +} \ No newline at end of file diff --git a/esp32/level2/accelerometer/wokwi.toml b/esp32/level2/accelerometer/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level2/accelerometer/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level2/button_duration/.DS_Store b/esp32/level2/button_duration/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..49bdfad1df94c709b50af294031ea215eb1a6311 Binary files /dev/null and b/esp32/level2/button_duration/.DS_Store differ diff --git a/esp32/level2/button_duration/description_esp.md b/esp32/level2/button_duration/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..3948e9613bdc2ef67f4e40adf1186dd5cd462df5 --- /dev/null +++ b/esp32/level2/button_duration/description_esp.md @@ -0,0 +1,34 @@ +# Button Duration + +## Project Description +This is an ESP32 project that determines how long a switch is pressed + +## Hardware Components +- ESP32 DevKit v1 +- 10kΩ resistor +- Push Button + +## Circuit Description +Circuit is designed to use a pull-up resistor. When the button is not pressed, the pin4 pin is connected to 3V3 through a 10kΩ resistor. When the button is pressed, the pin4 pin is connected to gnd2. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Initialize serial communication +2. Configure the specified button pin as INPUT +3. Continuously monitor the button state and measure how long it is pressed +4. Print the duration in second, in the following format: "Button pressed duration: {duration}s" + +## Success Criteria +The test is successful when: +1. The pressed duration in seconds is correctly printed in the given format + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- Include a short delay in the loop to handle switch bouncing +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Variants +This project may have different variants with the pushbutton connected to different pins. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/esp32/level2/button_duration/diagram_breadboard_esp.json b/esp32/level2/button_duration/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..452dcc230edd90f1a87798d90d597424b26ac8b7 --- /dev/null +++ b/esp32/level2/button_duration/diagram_breadboard_esp.json @@ -0,0 +1,132 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Manage pull up registor button input", + "config": { + "button_pin": 4, + "gnd_pin": "GND.2" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -223.8, + "left": -35.6, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -144.6, + "left": 118.2, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -82.45, + "left": 86.4, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "push button1:1.l", + "breadboard1:19t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.l", + "breadboard1:17t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.r", + "breadboard1:19b.h", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.r", + "breadboard1:17b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:11b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:17b.i", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:11b.j", + "esp1:3V3", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:17t.b", + "esp1:D4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:19b.i", + "esp1:GND.2", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level2/button_duration/diagram_esp.json b/esp32/level2/button_duration/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..d26f32918b989238fe94c09ecb417fdcda678894 --- /dev/null +++ b/esp32/level2/button_duration/diagram_esp.json @@ -0,0 +1,86 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Manage pull up registor button input", + "config": { + "button_pin": 4, + "gnd_pin": "GND.2" + }, + "editor": "wokwi", + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -163.8, + "left": 79.8, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -92.05, + "left": 48, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "resistor1:2", + "push button1:2.r", + "green", + [ + "v0" + ] + ], + [ + "resistor1:1", + "esp1:3V3", + "green", + [ + "v0" + ] + ], + [ + "push button1:2.l", + "esp1:D4", + "green", + [ + "v0" + ] + ], + [ + "push button1:1.r", + "esp1:GND.2", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level2/button_duration/platformio.ini b/esp32/level2/button_duration/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..931f8e51c8b316966aadabc57f6e4c0a1e61204c --- /dev/null +++ b/esp32/level2/button_duration/platformio.ini @@ -0,0 +1,26 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 + +lib_deps = + Arduino \ No newline at end of file diff --git a/esp32/level2/button_duration/scenario.yaml b/esp32/level2/button_duration/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e983d2b2acfe7941a8cc376ebc7ad58b58b29321 --- /dev/null +++ b/esp32/level2/button_duration/scenario.yaml @@ -0,0 +1,26 @@ +author: Blind Author +description: Determine how long a switch is pressed +name: Button Duration +steps: +- delay: 300ms +- set-control: + control: pressed + part-id: push button1 + value: 1 +- delay: 1000ms +- set-control: + control: pressed + part-id: push button1 + value: 0 +- wait-serial: 'Button pressed duration: 1s' +- set-control: + control: pressed + part-id: push button1 + value: 1 +- delay: 3000ms +- set-control: + control: pressed + part-id: push button1 + value: 0 +- wait-serial: 'Button pressed duration: 3s' +version: 1.0 diff --git a/esp32/level2/button_duration/src/main_esp.cpp b/esp32/level2/button_duration/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..98fa9c404cc926ba34225235472c44577ba3b2df --- /dev/null +++ b/esp32/level2/button_duration/src/main_esp.cpp @@ -0,0 +1,35 @@ +/** + Determine how long a switch is pressed + 6 APR 2025 by Blind Author +*/ +#include + +const int inPin = 4; + +bool prevButtonState = HIGH; +unsigned long pressStartTime = 0; +unsigned long pressDuration = 0; + +void setup() { + pinMode(inPin, INPUT); + Serial.begin(9600); +} + +void loop() { + bool buttonState = digitalRead(inPin); + + if (prevButtonState == HIGH && buttonState == LOW) { + pressStartTime = millis(); + } + + if (prevButtonState == LOW && buttonState == HIGH) { + pressDuration = (millis() - pressStartTime) / 1000; + Serial.print("Button pressed duration: "); + Serial.print(pressDuration); + Serial.println("s"); + } + + prevButtonState = buttonState; + + delay(10); +} diff --git a/esp32/level2/button_duration/wokwi.toml b/esp32/level2/button_duration/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level2/button_duration/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level2/button_pulldown/.DS_Store b/esp32/level2/button_pulldown/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5b83aea94a1e325abb5b14e63a78c4835d5f5fc3 Binary files /dev/null and b/esp32/level2/button_pulldown/.DS_Store differ diff --git a/esp32/level2/button_pulldown/description_esp.md b/esp32/level2/button_pulldown/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..a1828927b877ce2880ad3afd542d61b793ffe22a --- /dev/null +++ b/esp32/level2/button_pulldown/description_esp.md @@ -0,0 +1,34 @@ +# Button Pulldown + +## Project Description +This is a simple ESP32 project that prints whether the button is pressed. + +## Hardware Components +- ESP32 DevKit v1 +- 10kΩ resistor +- Push Button + +## Circuit Description +Circuit is designed to use a pull-down resistor. When the button is not pressed, the pin4 pin is connected to gnd2 through a 10kΩ resistor. When the button is pressed, the pin4 pin is connected to 3V3. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Initialize serial communication +2. Configure the specified button pin as INPUT +3. Continuously check the button value, and print "Button pressed" if the value is HIGH, or print "Button not pressed" if the value is LOW. + +## Success Criteria +The test is successful when: +1. "Button pressed" is printed when the button is pressed +2. "Button not pressed" is printed when the button is not pressed + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- The pin number used should match the circuit diagram +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Variants +This project may have different variants with the pushbutton connected to different pins. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/esp32/level2/button_pulldown/diagram_breadboard_esp.json b/esp32/level2/button_pulldown/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..531b12d654c80530e73b2ee3366ceb96b6d01638 --- /dev/null +++ b/esp32/level2/button_pulldown/diagram_breadboard_esp.json @@ -0,0 +1,132 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Manage pull down registor button input", + "config": { + "button_pin": 4, + "gnd_pin": "GND.2" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -223.8, + "left": -35.6, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -144.6, + "left": 118.2, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -82.45, + "left": 86.4, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "breadboard1:17t.b", + "esp1:D4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:19b.i", + "esp1:3V3", + "green", + [ + "v0" + ] + ], + [ + "push button1:1.l", + "breadboard1:19t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.l", + "breadboard1:17t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.r", + "breadboard1:19b.h", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.r", + "breadboard1:17b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:11b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:17b.i", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:11b.j", + "esp1:GND.2", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level2/button_pulldown/diagram_copy.json b/esp32/level2/button_pulldown/diagram_copy.json new file mode 100644 index 0000000000000000000000000000000000000000..0c4e70d02f704a2780a2259073d9b147fcfc848a --- /dev/null +++ b/esp32/level2/button_pulldown/diagram_copy.json @@ -0,0 +1,58 @@ +{ + "version": 1, + "author": "Arduino-LLM", + "editor": "Blind Author and Blind Author", + "parts": [ + { + "type": "wokwi-arduino-uno", + "id": "arduino uno1", + "top": 200, + "left": 20, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": 150, + "left": 200, + "rotate": 90, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 100, + "left": 250, + "attrs": { + "value": "10k" + }, + "rotate": 90 + } + ], + "connections": [ + [ + "arduino uno1:4", + "push button1:1.l", + "yellow", + [] + ], + [ + "push button1:1.r", + "arduino uno1:5v", + "red", + [] + ], + [ + "push button1:1.l", + "resistor1:1", + "blue", + [] + ], + [ + "resistor1:2", + "arduino uno1:GND.1", + "black", + [] + ] + ] +} \ No newline at end of file diff --git a/esp32/level2/button_pulldown/diagram_esp.json b/esp32/level2/button_pulldown/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..54be0a0b8b808bcca3ce5171b9a7e7438369afac --- /dev/null +++ b/esp32/level2/button_pulldown/diagram_esp.json @@ -0,0 +1,85 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Manage pull down registor button input", + "config": { + "button_pin": 4, + "gnd_pin": "GND.2" + }, + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -144.6, + "left": 70.2, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -63.25, + "left": 38.4, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "resistor1:2", + "push button1:2.r", + "green", + [ + "v0" + ] + ], + [ + "resistor1:1", + "esp1:GND.2", + "green", + [ + "v0" + ] + ], + [ + "push button1:2.l", + "esp1:D4", + "green", + [ + "v0" + ] + ], + [ + "push button1:1.r", + "esp1:3V3", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level2/button_pulldown/platformio.ini b/esp32/level2/button_pulldown/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..931f8e51c8b316966aadabc57f6e4c0a1e61204c --- /dev/null +++ b/esp32/level2/button_pulldown/platformio.ini @@ -0,0 +1,26 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 + +lib_deps = + Arduino \ No newline at end of file diff --git a/esp32/level2/button_pulldown/scenario.yaml b/esp32/level2/button_pulldown/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..93e9a4c1f0fd5ab2208a7046ff53a720d438a200 --- /dev/null +++ b/esp32/level2/button_pulldown/scenario.yaml @@ -0,0 +1,17 @@ +author: Blind Author +description: Manage pull down registor button input +name: Serial Monitor +steps: +- delay: 10ms +- set-control: + control: pressed + part-id: push button1 + value: 1 +- wait-serial: Button pressed +- delay: 1000ms +- set-control: + control: pressed + part-id: push button1 + value: 0 +- wait-serial: Button not pressed +version: 1.0 diff --git a/esp32/level2/button_pulldown/src/main_esp.cpp b/esp32/level2/button_pulldown/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a56d272d2c280b0ae2d24022303f61afa50ab6fb --- /dev/null +++ b/esp32/level2/button_pulldown/src/main_esp.cpp @@ -0,0 +1,27 @@ +/** + Manage pull down registor button input + 1 APR 2025 by Blind Author +*/ +#include + +const int inputPin = 4; + +void setup() +{ + Serial.begin(9600); + pinMode(inputPin, INPUT); +} + +void loop() +{ + int val = digitalRead(inputPin); + + if (val == HIGH) { + Serial.println("Button pressed"); + } else + { + Serial.println("Button not pressed"); + } + + delay(1000); +} \ No newline at end of file diff --git a/esp32/level2/button_pulldown/wokwi.toml b/esp32/level2/button_pulldown/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level2/button_pulldown/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level2/button_pullup/.DS_Store b/esp32/level2/button_pullup/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..bfccac3b40a02d8706ea471bc42c9acdeac18d65 Binary files /dev/null and b/esp32/level2/button_pullup/.DS_Store differ diff --git a/esp32/level2/button_pullup/description_esp.md b/esp32/level2/button_pullup/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..dcc4c9f5e18741ece1ae80b2fc53e780920cf8fc --- /dev/null +++ b/esp32/level2/button_pullup/description_esp.md @@ -0,0 +1,34 @@ +# Button Pullup + +## Project Description +This is a simple ESP32 project that prints whether the button is pressed. + +## Hardware Components +- ESP32 DevKit v1 +- 10kΩ resistor +- Push Button + +## Circuit Description +Circuit is designed to use a pull-up resistor. When the button is not pressed, the pin4 pin is connected to 3V3 through a 10kΩ resistor. When the button is pressed, the pin4 pin is connected to gnd2. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Initialize serial communication +2. Configure the specified button pin as INPUT +3. Continuously check the button value, and print "Button pressed" if the value is LOW, or print "Button not pressed" if the value is HIGH. + +## Success Criteria +The test is successful when: +1. "Button pressed" is printed when the button is pressed +2. "Button not pressed" is printed when the button is not pressed + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- The pin number used should match the circuit diagram +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Variants +This project may have different variants with the pushbutton connected to different pins. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/esp32/level2/button_pullup/diagram_breadboard_esp.json b/esp32/level2/button_pullup/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..452dcc230edd90f1a87798d90d597424b26ac8b7 --- /dev/null +++ b/esp32/level2/button_pullup/diagram_breadboard_esp.json @@ -0,0 +1,132 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Manage pull up registor button input", + "config": { + "button_pin": 4, + "gnd_pin": "GND.2" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -223.8, + "left": -35.6, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -144.6, + "left": 118.2, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -82.45, + "left": 86.4, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "push button1:1.l", + "breadboard1:19t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.l", + "breadboard1:17t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.r", + "breadboard1:19b.h", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.r", + "breadboard1:17b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:11b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:17b.i", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:11b.j", + "esp1:3V3", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:17t.b", + "esp1:D4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:19b.i", + "esp1:GND.2", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level2/button_pullup/diagram_esp.json b/esp32/level2/button_pullup/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..d26f32918b989238fe94c09ecb417fdcda678894 --- /dev/null +++ b/esp32/level2/button_pullup/diagram_esp.json @@ -0,0 +1,86 @@ +{ + "version": 1, + "author": "Blind Author", + "description": "Manage pull up registor button input", + "config": { + "button_pin": 4, + "gnd_pin": "GND.2" + }, + "editor": "wokwi", + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -163.8, + "left": 79.8, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -92.05, + "left": 48, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "resistor1:2", + "push button1:2.r", + "green", + [ + "v0" + ] + ], + [ + "resistor1:1", + "esp1:3V3", + "green", + [ + "v0" + ] + ], + [ + "push button1:2.l", + "esp1:D4", + "green", + [ + "v0" + ] + ], + [ + "push button1:1.r", + "esp1:GND.2", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level2/button_pullup/platformio.ini b/esp32/level2/button_pullup/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..931f8e51c8b316966aadabc57f6e4c0a1e61204c --- /dev/null +++ b/esp32/level2/button_pullup/platformio.ini @@ -0,0 +1,26 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 + +lib_deps = + Arduino \ No newline at end of file diff --git a/esp32/level2/button_pullup/scenario.yaml b/esp32/level2/button_pullup/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..93e9a4c1f0fd5ab2208a7046ff53a720d438a200 --- /dev/null +++ b/esp32/level2/button_pullup/scenario.yaml @@ -0,0 +1,17 @@ +author: Blind Author +description: Manage pull down registor button input +name: Serial Monitor +steps: +- delay: 10ms +- set-control: + control: pressed + part-id: push button1 + value: 1 +- wait-serial: Button pressed +- delay: 1000ms +- set-control: + control: pressed + part-id: push button1 + value: 0 +- wait-serial: Button not pressed +version: 1.0 diff --git a/esp32/level2/button_pullup/src/main_esp.cpp b/esp32/level2/button_pullup/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d506ea2168ce95558aa7a09652a64c0f55ad82ce --- /dev/null +++ b/esp32/level2/button_pullup/src/main_esp.cpp @@ -0,0 +1,29 @@ +/** + Manage pull up registor button input + 1 APR 2025 by Blind Author +*/ + +#include + +const int inputPin = 4; + +void setup() +{ + Serial.begin(9600); + pinMode(inputPin, INPUT); +} + +void loop() +{ + int val = digitalRead(inputPin); + + if (val == LOW) + { + Serial.println("Button pressed"); + } else + { + Serial.println("Button not pressed"); + } + + delay(1000); +} \ No newline at end of file diff --git a/esp32/level2/button_pullup/wokwi.toml b/esp32/level2/button_pullup/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level2/button_pullup/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level2/distance_sensor/.DS_Store b/esp32/level2/distance_sensor/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b21857bf37f0ec419aad9addb74166936f686f9d Binary files /dev/null and b/esp32/level2/distance_sensor/.DS_Store differ diff --git a/esp32/level2/distance_sensor/diagram_breadboard_esp.json b/esp32/level2/distance_sensor/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..a8bca69c3220ffdf99fc18a5cf89e9be48d5b165 --- /dev/null +++ b/esp32/level2/distance_sensor/diagram_breadboard_esp.json @@ -0,0 +1,107 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read value of distance sensor", + "config": { + "distance_echo_pin": "2", + "distance_trig_pin": "4", + "gnd_pin": "GND.2", + "distance_init": "398" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "bb1", + "top": 333, + "left": -189.2, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-hc-sr04", + "id": "ultrasonic distance sensor1", + "top": 289.5, + "left": 216.7, + "attrs": { + "distance": "398" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "ultrasonic distance sensor1:VCC", + "bb1:48t.a", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:TRIG", + "bb1:49t.a", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:ECHO", + "bb1:50t.a", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:GND", + "bb1:51t.a", + "", + [ + "$bb" + ] + ], + [ + "esp1:D4", + "bb1:50t.c", + "green", + [ + "h0" + ] + ], + [ + "esp1:3V3", + "bb1:48t.c", + "green", + [ + "v0" + ] + ], + [ + "esp1:GND.2", + "bb1:51t.c", + "black", + [ + "h0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level2/distance_sensor/diagram_esp.json b/esp32/level2/distance_sensor/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..6bba9ae31360c31d0b23f3a7bad62823de612826 --- /dev/null +++ b/esp32/level2/distance_sensor/diagram_esp.json @@ -0,0 +1,77 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read value of distance sensor", + "config": { + "distance_echo_pin": "2", + "distance_trig_pin": "4", + "gnd_pin": "GND.2", + "distance_init": "398" + }, + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-hc-sr04", + "id": "ultrasonic distance sensor1", + "top": 43.5, + "left": 288.9, + "rotate": 90, + "attrs": { + "distance": "398" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "ultrasonic distance sensor1:VCC", + "esp1:3V3", + "red", + [ + "h0" + ] + ], + [ + "ultrasonic distance sensor1:GND", + "esp1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "ultrasonic distance sensor1:TRIG", + "esp1:D4", + "green", + [ + "h0" + ] + ], + [ + "ultrasonic distance sensor1:ECHO", + "esp1:D2", + "green", + [ + "h0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level2/distance_sensor/platformio.ini b/esp32/level2/distance_sensor/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..931f8e51c8b316966aadabc57f6e4c0a1e61204c --- /dev/null +++ b/esp32/level2/distance_sensor/platformio.ini @@ -0,0 +1,26 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 + +lib_deps = + Arduino \ No newline at end of file diff --git a/esp32/level2/distance_sensor/scenario.yaml b/esp32/level2/distance_sensor/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3f984d57dcc5c1a1880f405a14f278ca625c263e --- /dev/null +++ b/esp32/level2/distance_sensor/scenario.yaml @@ -0,0 +1,25 @@ +author: Blind Author +description: Measure distance with Ultrasonic distance sensor +name: Distance Sensor +steps: +- delay: 1000ms +- set-control: + part-id: ultrasonic distance sensor1 + control: distance + value: 400 + esp_value: 398 +- write-serial: '200' +- wait-serial: Measured distance is greater +- delay: 50ms +- write-serial: '400' +- wait-serial: Measured distance is greater +- delay: 50ms +- write-serial: '403' +- wait-serial: Measured distance is equal to the target +- delay: 50ms +- write-serial: '500' +- wait-serial: Measured distance is less +- delay: 50ms +- write-serial: '600' +- wait-serial: Measured distance is less +version: 1.0 diff --git a/esp32/level2/distance_sensor/src/main_esp.cpp b/esp32/level2/distance_sensor/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a537b75b67887e27e0bcd0f3ea705bc224d06556 --- /dev/null +++ b/esp32/level2/distance_sensor/src/main_esp.cpp @@ -0,0 +1,37 @@ +/** + Measure distance with Ultrasonic distance sensor. + 3 APR 2025 by Blind Author +*/ + +#include + +#define PIN_TRIG 4 +#define PIN_ECHO 2 + +void setup() { + Serial.begin(9600); + pinMode(PIN_TRIG, OUTPUT); + pinMode(PIN_ECHO, INPUT); +} + +void loop() { + digitalWrite(PIN_TRIG, HIGH); + delayMicroseconds(10); + digitalWrite(PIN_TRIG, LOW); + + int duration = pulseIn(PIN_ECHO, HIGH); + int centimeter = duration / 58; + + Serial.println("Enter a distance in cm to compare: "); + delay(200); + if (Serial.available() > 0) { + int inputNumber = Serial.parseInt(); + if (inputNumber > centimeter) { + Serial.println("Measured distance is less"); + } else if (inputNumber < centimeter) { + Serial.println("Measured distance is greater"); + } else { + Serial.println("Measured distance is equal to the target"); + } + } +} \ No newline at end of file diff --git a/esp32/level2/distance_sensor/wokwi.toml b/esp32/level2/distance_sensor/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level2/distance_sensor/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level2/gyroscope/description_esp.md b/esp32/level2/gyroscope/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..5a471672dcfbbaa690baa4438a772bfdfaca9492 --- /dev/null +++ b/esp32/level2/gyroscope/description_esp.md @@ -0,0 +1,31 @@ +# Gyroscope + +## Project Description +This is an ESP32 project that uses MPU6050 6-axis accelerometer & gyro sensor to measure the rotation. + +## Hardware Components +- ESP32 DevKit v1 +- MPU6050 6-axis Accel & Gyro Sensor + +## Circuit Description +The MPU6050 sensor is connected to the ESP32. The VCC pin is connected to 3V3, the GND pin to gnd2, the SCL pin to pin22, and the SDA pin to pin21. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Initialize serial communication +2. Check if the MPU sensor can be initialized successfully, and print 'MPU6050 ready!' to the serial monitor +3. Continuously read the gryoscope data from the MPU6050 sensor +4. Print the X, Y, and Z axis rotation values in rad/s to the serial monitor, for example: 'X: 1.13, Y: 2.97, Z: -2.01 rad/s' + +## Success Criteria +The test is successful when: +1. Correct X, Y, Z gyroscope result is printed to the serial monitor. + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- Use Adafruit_MPU6050.h, Adafruit_Sensor.h, Wire.h libraries. +- Delay 500ms in every loop. +- MPU6050 has I2C interface. + +## Variants +There may be variants with GND connected to different pin. \ No newline at end of file diff --git a/esp32/level2/gyroscope/diagram_breadboard_esp.json b/esp32/level2/gyroscope/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..1048fd2e13c9f53855bf1e149f19a50b570e5bbf --- /dev/null +++ b/esp32/level2/gyroscope/diagram_breadboard_esp.json @@ -0,0 +1,160 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read value of MPU6050", + "config": { + "scl_pin": "D22", + "sda_pin": "D21", + "gnd_pin": "GND.2" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": 208.2, + "left": -189.2, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-mpu6050", + "id": "mpu6050 6-axis accel & gyro sensor1", + "top": 291.82, + "left": 117.52, + "attrs": {} + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:INT", + "breadboard1:31t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:AD0", + "breadboard1:32t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:XCL", + "breadboard1:33t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:XDA", + "breadboard1:34t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SDA", + "breadboard1:35t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SCL", + "breadboard1:36t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:GND", + "breadboard1:37t.e", + "", + [ + "$bb" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:VCC", + "breadboard1:38t.e", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:38t.c", + "breadboard1:tp.30", + "green", + [ + "v0" + ] + ], + [ + "esp1:3V3", + "breadboard1:tp.25", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:37t.d", + "breadboard1:tn.29", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:36t.d", + "esp1:D22", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:35t.d", + "esp1:D21", + "green", + [ + "v0" + ] + ], + [ + "esp1:GND.2", + "breadboard1:tn.27", + "black", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level2/gyroscope/diagram_esp.json b/esp32/level2/gyroscope/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..868af9e87c9e4cf2d7b8f112fc808ff901094789 --- /dev/null +++ b/esp32/level2/gyroscope/diagram_esp.json @@ -0,0 +1,77 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read value of MPU6050", + "config": { + "scl_pin": "D22", + "sda_pin": "D21", + "gnd_pin": "GND.2" + }, + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-mpu6050", + "id": "mpu6050 6-axis accel & gyro sensor1", + "top": 234.22, + "left": 117.52, + "attrs": {} + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "esp1:GND.2", + "mpu6050 6-axis accel & gyro sensor1:GND", + "black", + [ + "v38.3", + "h32.7" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:VCC", + "esp1:3V3", + "red", + [ + "v-38.4", + "h-67.12" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SCL", + "esp1:D22", + "green", + [ + "v-28.8", + "h67.28" + ] + ], + [ + "mpu6050 6-axis accel & gyro sensor1:SDA", + "esp1:D21", + "green", + [ + "v-38.4", + "h67.28" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level2/gyroscope/platformio.ini b/esp32/level2/gyroscope/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..1fcd3d2ac9c62295169e4cf8707f566b4f6462af --- /dev/null +++ b/esp32/level2/gyroscope/platformio.ini @@ -0,0 +1,31 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + Adafruit MPU6050 + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 + +lib_deps = + Arduino + Adafruit MPU6050 \ No newline at end of file diff --git a/esp32/level2/gyroscope/scenario.yaml b/esp32/level2/gyroscope/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ffbb1cd31258c74ec3f879a7ee2eda9dcaea4dd9 --- /dev/null +++ b/esp32/level2/gyroscope/scenario.yaml @@ -0,0 +1,45 @@ +author: Blind Author +description: Measure 3-axis rotation with gyroscope +name: Gyroscope +steps: +- wait-serial: MPU6050 ready! +- set-control: + control: rotationX + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 65 +- set-control: + control: rotationY + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 170 +- set-control: + control: rotationZ + part-id: mpu6050 6-axis accel & gyro sensor1 + value: -115 +- wait-serial: 'X: 1.13, Y: 2.97, Z: -2.01 rad/s' +- set-control: + control: rotationX + part-id: mpu6050 6-axis accel & gyro sensor1 + value: -105 +- set-control: + control: rotationY + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 35 +- set-control: + control: rotationZ + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 205 +- wait-serial: 'X: -1.83, Y: 0.61, Z: 3.58 rad/s' +- set-control: + control: rotationX + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 220 +- set-control: + control: rotationY + part-id: mpu6050 6-axis accel & gyro sensor1 + value: -215 +- set-control: + control: rotationZ + part-id: mpu6050 6-axis accel & gyro sensor1 + value: 15 +- wait-serial: 'X: 3.84, Y: -3.75, Z: 0.26 rad/s' +version: 1.0 diff --git a/esp32/level2/gyroscope/src/main_esp.cpp b/esp32/level2/gyroscope/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a2c8c745dfb871a89e4d39e0093110945526dd0f --- /dev/null +++ b/esp32/level2/gyroscope/src/main_esp.cpp @@ -0,0 +1,35 @@ +/** + Measure 3-axis rotation with gyroscope + 10 APR 2025 by Blind Author +*/ +#include +#include +#include +#include + +Adafruit_MPU6050 mpu; + +void setup(void) { + Serial.begin(115200); + + while (!mpu.begin()) { + Serial.println("MPU6050 not connected!"); + delay(1000); + } + Serial.println("MPU6050 ready!"); +} + +sensors_event_t event; + +void loop() { + mpu.getGyroSensor()->getEvent(&event); + + Serial.print("X: "); + Serial.print(event.gyro.x); + Serial.print(", Y: "); + Serial.print(event.gyro.y); + Serial.print(", Z: "); + Serial.print(event.gyro.z); + Serial.println(" rad/s"); + delay(500); +} \ No newline at end of file diff --git a/esp32/level2/gyroscope/wokwi.toml b/esp32/level2/gyroscope/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level2/gyroscope/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level2/humidity_sensor/.DS_Store b/esp32/level2/humidity_sensor/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b88cd06c171a6d6832fc043fd03fd2cd657ca877 Binary files /dev/null and b/esp32/level2/humidity_sensor/.DS_Store differ diff --git a/esp32/level2/humidity_sensor/description_esp.md b/esp32/level2/humidity_sensor/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..d5eca0e0bcea1d8c8f9f34c96c535da2b0dc039c --- /dev/null +++ b/esp32/level2/humidity_sensor/description_esp.md @@ -0,0 +1,27 @@ +# Humidity Sensor + +## Project Description +This is a simple ESP32 project that reads humidity sensor value and check if it is above the threshold. + +## Hardware Components +- ESP32 DevKit v1 +- DHT22 sensor + +## Circuit Description +The DHT22 sensor is connected to an ESP32. The VCC pin is connected to the 3V3 pin on the ESP32, and the GND pin is connected to the GND2 pin. The data pin is connected to digital pin 2 on the ESP32. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Declare the threshold value, which is 50.0 +2. Initialize serial communication +3. Continuously read the DHT sensor's humidity value +4. Compare the humidity sensor value with the threshold, and print one of these: 'Humidity is below the threshold', 'Humidity is above the threshold' + +## Success Criteria +The test is successful when: +1. The correct compare result is printed to the serial monitor. + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- Serial input is always a float value. +- Threshold is 50.0. diff --git a/esp32/level2/humidity_sensor/diagram_breadboard_esp.json b/esp32/level2/humidity_sensor/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..16d379e1304d2d5c479399adf85b877f4fed85c7 --- /dev/null +++ b/esp32/level2/humidity_sensor/diagram_breadboard_esp.json @@ -0,0 +1,121 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read humidity sensor value", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -223.8, + "left": -93.2, + "attrs": {} + }, + { + "type": "wokwi-arduino-uno", + "id": "esp1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-dht22", + "id": "dht22 sensor1", + "top": -210.9, + "left": 100.2, + "attrs": { + "humidity": "64.5" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "dht22 sensor1:VCC", + "breadboard1:20b.g", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:SDA", + "breadboard1:21b.g", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:NC", + "breadboard1:22b.g", + "", + [ + "$bb" + ] + ], + [ + "dht22 sensor1:GND", + "breadboard1:23b.g", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:20b.h", + "breadboard1:bp.16", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:21b.h", + "esp1:D2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:23b.h", + "breadboard1:bn.18", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:bn.1", + "esp1:GND.2", + "green", + [ + "v238.7", + "h210.4" + ] + ], + [ + "breadboard1:bp.1", + "esp1:3V3", + "green", + [ + "v-0.9", + "h-20", + "v259.2", + "h230.4" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level2/humidity_sensor/diagram_esp.json b/esp32/level2/humidity_sensor/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..1557c559e35ba5353103929e26d6255fdc7fe27c --- /dev/null +++ b/esp32/level2/humidity_sensor/diagram_esp.json @@ -0,0 +1,69 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Read humidity sensor value", + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-dht22", + "id": "dht22 sensor1", + "top": -201.3, + "left": 100.2, + "attrs": { + "humidity": "64.5" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "dht22 sensor1:VCC", + "esp1:3V3", + "red", + [ + "v48", + "h-134.4", + "v259.2", + "h182.4" + ] + ], + [ + "dht22 sensor1:GND", + "esp1:GND.2", + "black", + [ + "v48", + "h144", + "v268.8", + "h19.2" + ] + ], + [ + "dht22 sensor1:SDA", + "esp1:D2", + "green", + [ + "v76.8", + "h115.3" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level2/humidity_sensor/platformio.ini b/esp32/level2/humidity_sensor/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..2d002a3eaebe315dc0405893a749aa3aea3b577c --- /dev/null +++ b/esp32/level2/humidity_sensor/platformio.ini @@ -0,0 +1,33 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +lib_deps = + Arduino + DHT sensor library + DHT22 + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 + +lib_deps = + Arduino + DHT sensor library + DHT22 \ No newline at end of file diff --git a/esp32/level2/humidity_sensor/scenario.yaml b/esp32/level2/humidity_sensor/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8ed362bc965ec4e7095012af1dbebe430ad7b419 --- /dev/null +++ b/esp32/level2/humidity_sensor/scenario.yaml @@ -0,0 +1,21 @@ +author: Blind Author +description: Read humidity sensor value +name: Humidity Sensor Basic +steps: + - delay: 100ms + - set-control: + part-id: dht22 sensor1 + control: humidity + value: 30.5 + - wait-serial: "Humidity is below the threshold" + - set-control: + part-id: dht22 sensor1 + control: humidity + value: 49.7 + - wait-serial: "Humidity is below the threshold" + - set-control: + part-id: dht22 sensor1 + control: humidity + value: 68.4 + - wait-serial: "Humidity is above the threshold" +version: 1.0 diff --git a/esp32/level2/humidity_sensor/src/main_esp.cpp b/esp32/level2/humidity_sensor/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b663577fd07900a3325ea7560ba004c25675f1fd --- /dev/null +++ b/esp32/level2/humidity_sensor/src/main_esp.cpp @@ -0,0 +1,31 @@ +/** + Read humidity sensor value and compare with the input value + 03 MAY 2025 by Blind Author +*/ +#include +#include "DHT.h" + +#define DHTTYPE DHT22 + +#define DHTPIN 2 + +DHT dht(DHTPIN, DHTTYPE); + +float threshold = 50.0; + +void setup() { + Serial.begin(9600); + dht.begin(); +} + +void loop() { + float humidity = dht.readHumidity(); + + if (humidity < threshold) { + Serial.println("Humidity is below the threshold"); + } else { + Serial.println("Humidity is above the threshold"); + } + + delay(1000); +} \ No newline at end of file diff --git a/esp32/level2/humidity_sensor/wokwi.toml b/esp32/level2/humidity_sensor/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level2/humidity_sensor/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level3/button_RGB_led/.DS_Store b/esp32/level3/button_RGB_led/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..af3f4fcf5b162fd8e8d187c785590223a5e87180 Binary files /dev/null and b/esp32/level3/button_RGB_led/.DS_Store differ diff --git a/esp32/level3/button_RGB_led/description_esp.md b/esp32/level3/button_RGB_led/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..5028879713b711e650f47f327f90de81de4ab158 --- /dev/null +++ b/esp32/level3/button_RGB_led/description_esp.md @@ -0,0 +1,38 @@ +# Button RGB LED + +## Project Description +This is a simple ESP32 project that turns on an LED connected to a specific pin. + +## Hardware Components +- ESP32 DevKit v1 +- RGB LED +- 220Ω resistor * 3 +- Push Button * 3 +- 10kΩ resistor * 3 + +## Circuit Description +The R, G, B pin of the RGB LED is connected to the ESP32 digital pins through a 220Ω current-limiting resistor. +RGB LED has common cathode configuration. Push button uses pull-up resistor configuration. The three buttons correspond to R, G, and B respectively, and are connected to ESP32 pin5, pin4, and pin2 for input. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Set LED pins to OUTPUT, and button pins to INPUT +2. Continuously read the button value +3. When a button is pressed, the corresponding color on the RGB LED lights up at full brightness. + +## Success Criteria +The test is successful when: +1. The pressed button and the corresponding RGB LED pin state line up perfectly. + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- Each button is configured with a pull-up resistor, resulting in a LOW signal when pressed. +- The RGB LED has a common cathode connected to GND, so a PWM value of 0 turns it off and 255 turns it fully on. +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Variants +This project may have different variants with the LED, button connected to different pins. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/esp32/level3/button_RGB_led/diagram_breadboard_esp.json b/esp32/level3/button_RGB_led/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..b51e0a99acfa2604b4893cb8b1a48acb9869806f --- /dev/null +++ b/esp32/level3/button_RGB_led/diagram_breadboard_esp.json @@ -0,0 +1,499 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Button RGB LED", + "config": { + "R_led_pin": 14, + "G_led_pin": 13, + "B_led_pin": 12, + "R_button_pin": 5, + "G_button_pin": 4, + "B_button_pin": 2 + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -195, + "left": -54.8, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 77.4, + "left": 85.8, + "attrs": {} + }, + { + "type": "wokwi-rgb-led", + "id": "rgb led1", + "top": -178.4, + "left": 125.9, + "attrs": { + "common": "cathode" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -91.2, + "left": 105.05, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -91.2, + "left": 124.25, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -91.2, + "left": 133.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -125.4, + "left": 262.2, + "rotate": 90, + "attrs": { + "color": "Red", + "key": "r" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button2", + "top": -125.4, + "left": 339, + "rotate": 90, + "attrs": { + "color": "LimeGreen", + "key": "g" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button3", + "top": -125.4, + "left": 415.8, + "rotate": 90, + "attrs": { + "color": "Blue", + "key": "b" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": -53.35, + "left": 248.2, + "rotate": 180, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": -53.35, + "left": 325, + "rotate": 180, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -53.35, + "left": 401.8, + "rotate": 180, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "resistor1:1", + "breadboard1:18t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:18b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:20t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:20b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:21t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:21b.h", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:18b.i", + "esp1:D14", + "green", + [ + "v76.8", + "h96" + ] + ], + [ + "breadboard1:20b.i", + "esp1:D13", + "green", + [ + "v67.2", + "h86.4" + ] + ], + [ + "breadboard1:21b.i", + "esp1:D12", + "green", + [ + "v57.6", + "h86.4" + ] + ], + [ + "breadboard1:19t.e", + "breadboard1:bn.15", + "green", + [ + "v0" + ] + ], + [ + "rgb led1:R", + "breadboard1:18t.b", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:COM", + "breadboard1:19t.c", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:G", + "breadboard1:20t.b", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:B", + "breadboard1:21t.b", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:bn.11", + "esp1:GND.1", + "green", + [ + "v0" + ] + ], + [ + "push button1:1.l", + "breadboard1:36t.b", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.l", + "breadboard1:34t.b", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.r", + "breadboard1:36b.g", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.r", + "breadboard1:34b.g", + "", + [ + "$bb" + ] + ], + [ + "push button2:1.l", + "breadboard1:44t.b", + "", + [ + "$bb" + ] + ], + [ + "push button2:2.l", + "breadboard1:42t.b", + "", + [ + "$bb" + ] + ], + [ + "push button2:1.r", + "breadboard1:44b.g", + "", + [ + "$bb" + ] + ], + [ + "push button2:2.r", + "breadboard1:42b.g", + "", + [ + "$bb" + ] + ], + [ + "push button3:1.l", + "breadboard1:52t.b", + "", + [ + "$bb" + ] + ], + [ + "push button3:2.l", + "breadboard1:50t.b", + "", + [ + "$bb" + ] + ], + [ + "push button3:1.r", + "breadboard1:52b.g", + "", + [ + "$bb" + ] + ], + [ + "push button3:2.r", + "breadboard1:50b.g", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:34t.a", + "breadboard1:bn.21", + "green", + [ + "v-19.2", + "h-67.2" + ] + ], + [ + "breadboard1:42t.a", + "breadboard1:bn.20", + "green", + [ + "v-28.8", + "h-153.6" + ] + ], + [ + "breadboard1:50t.a", + "breadboard1:bn.46", + "green", + [ + "v-19.2", + "h67.2" + ] + ], + [ + "breadboard1:30b.j", + "breadboard1:bp.28", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:38b.j", + "breadboard1:bp.32", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:46b.j", + "breadboard1:bp.38", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:bp.40", + "esp1:3V3", + "green", + [ + "v296.7", + "h-183.2" + ] + ], + [ + "resistor4:1", + "breadboard1:36b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor4:2", + "breadboard1:30b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor5:1", + "breadboard1:44b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor5:2", + "breadboard1:38b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor6:1", + "breadboard1:52b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor6:2", + "breadboard1:46b.i", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:36b.h", + "esp1:D5", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:44b.h", + "esp1:D4", + "green", + [ + "v115.2", + "h-67.2" + ] + ], + [ + "breadboard1:52b.h", + "esp1:D2", + "green", + [ + "v124.8", + "h-144" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level3/button_RGB_led/diagram_esp.json b/esp32/level3/button_RGB_led/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..4290e3950d4704f5471e37ee1059ec19ad4f9dbc --- /dev/null +++ b/esp32/level3/button_RGB_led/diagram_esp.json @@ -0,0 +1,295 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Button RGB LED", + "config": { + "R_led_pin": 14, + "G_led_pin": 13, + "B_led_pin": 12, + "R_button_pin": 5, + "G_button_pin": 4, + "B_button_pin": 2 + }, + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 125.4, + "left": -0.6, + "attrs": {} + }, + { + "type": "wokwi-rgb-led", + "id": "rgb led1", + "top": -44, + "left": 135.5, + "attrs": { + "common": "cathode" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 57.4, + "left": 113, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": 57.4, + "left": 132.2, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 57.4, + "left": 151.4, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": 38.3, + "left": 243.5, + "rotate": 90, + "attrs": { + "color": "Red", + "key": "r" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button2", + "top": 38.3, + "left": 291.5, + "rotate": 90, + "attrs": { + "color": "LimeGreen", + "key": "g" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button3", + "top": 38.3, + "left": 339.5, + "rotate": 90, + "attrs": { + "color": "Blue", + "key": "b" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 153.4, + "left": 257, + "rotate": 90, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": 153.4, + "left": 305, + "rotate": 90, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": 153.4, + "left": 353, + "rotate": 90, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "esp1:GND.1", + "rgb led1:COM", + "Black", + [ + "v-115.2", + "h38.1" + ] + ], + [ + "esp1:GND.1", + "push button1:2.l", + "Black", + [ + "h-0.3", + "v-115.2", + "h154.4" + ] + ], + [ + "push button1:2.l", + "push button2:2.l", + "Black", + [ + "v-9.6", + "h48" + ] + ], + [ + "push button2:2.l", + "push button3:2.l", + "Black", + [ + "v-9.6", + "h48" + ] + ], + [ + "rgb led1:R", + "resistor1:1", + "Red", + [ + "v0", + "h0" + ] + ], + [ + "rgb led1:B", + "resistor3:1", + "Blue", + [ + "v1", + "h11.2" + ] + ], + [ + "rgb led1:G", + "resistor2:1", + "Green", + [ + "v0", + "h33" + ] + ], + [ + "esp1:D14", + "resistor1:2", + "Red", + [ + "v-19.2", + "h0.6" + ] + ], + [ + "esp1:D12", + "resistor3:2", + "Blue", + [ + "v-19.2", + "h20" + ] + ], + [ + "esp1:D13", + "resistor2:2", + "Green", + [ + "v-28.8", + "h10.3" + ] + ], + [ + "push button1:1.r", + "esp1:D5", + "DarkSlateBlue", + [ + "v9.8", + "h-71.1" + ] + ], + [ + "push button2:1.r", + "esp1:D4", + "DarkSlateBlue", + [ + "v19.4", + "h-109.6" + ] + ], + [ + "push button3:1.r", + "esp1:D2", + "DarkSlateBlue", + [ + "v29", + "h-148.1" + ] + ], + [ + "esp1:3V3", + "resistor4:2", + "Red", + [ + "v19.1", + "h128.6" + ] + ], + [ + "resistor4:2", + "resistor5:2", + "Red", + [ + "v17.8", + "h48" + ] + ], + [ + "resistor5:2", + "resistor6:2", + "Red", + [ + "v17.8", + "h48" + ] + ], + [ + "resistor4:1", + "push button1:1.r", + "DarkSlateBlue", + [ + "h0" + ] + ], + [ + "resistor5:1", + "push button2:1.r", + "DarkSlateBlue", + [ + "h0" + ] + ], + [ + "resistor6:1", + "push button3:1.r", + "DarkSlateBlue", + [ + "h0" + ] + ] + ] +} \ No newline at end of file diff --git a/esp32/level3/button_RGB_led/platformio.ini b/esp32/level3/button_RGB_led/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..931f8e51c8b316966aadabc57f6e4c0a1e61204c --- /dev/null +++ b/esp32/level3/button_RGB_led/platformio.ini @@ -0,0 +1,26 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 + +lib_deps = + Arduino \ No newline at end of file diff --git a/esp32/level3/button_RGB_led/scenario.yaml b/esp32/level3/button_RGB_led/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7bd7d503f70eddfd3f9e7eae6910ae46a6873332 --- /dev/null +++ b/esp32/level3/button_RGB_led/scenario.yaml @@ -0,0 +1,77 @@ +author: Blind Author +description: LED lights up when the button is pressed +name: Button LED +test-values: +- part-id: rgb led1 + attr-name: common + value: "cathode" +steps: +- delay: 10ms +- set-control: + control: pressed + part-id: push button1 + value: 1 +- delay: 10ms +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: rgb led1 + pin: COM + value: 0 + - part-id: rgb led1 + pin: R + value: 1 + - part-id: rgb led1 + pin: G + value: 0 + - part-id: rgb led1 + pin: B + value: 0 +- set-control: + control: pressed + part-id: push button2 + value: 1 +- delay: 10ms +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: rgb led1 + pin: COM + value: 0 + - part-id: rgb led1 + pin: R + value: 1 + - part-id: rgb led1 + pin: G + value: 1 + - part-id: rgb led1 + pin: B + value: 0 +- set-control: + control: pressed + part-id: push button3 + value: 1 +- set-control: + control: pressed + part-id: push button1 + value: 0 +- delay: 10ms +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: rgb led1 + pin: COM + value: 0 + - part-id: rgb led1 + pin: R + value: 0 + - part-id: rgb led1 + pin: G + value: 1 + - part-id: rgb led1 + pin: B + value: 1 +version: 1.0 diff --git a/esp32/level3/button_RGB_led/src/main_esp.cpp b/esp32/level3/button_RGB_led/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8929350e348ac2b4356a7b60af9087ae9420e593 --- /dev/null +++ b/esp32/level3/button_RGB_led/src/main_esp.cpp @@ -0,0 +1,32 @@ +/** + Press the button to turn on the LED + 8 APR 2025 by Blind Author +*/ +#include + +const int BUTTON_R = 5; +const int BUTTON_G = 4; +const int BUTTON_B = 2; + +const int LED_R = 14; +const int LED_G = 13; +const int LED_B = 12; + +void setup() { + pinMode(BUTTON_B, INPUT); + pinMode(BUTTON_G, INPUT); + pinMode(BUTTON_R, INPUT); + + pinMode(LED_B, OUTPUT); + pinMode(LED_G, OUTPUT); + pinMode(LED_R, OUTPUT); +} + +void loop() { + if (digitalRead(BUTTON_R) == LOW) analogWrite(LED_R, 255); + else analogWrite(LED_R, 0); + if (digitalRead(BUTTON_G) == LOW) analogWrite(LED_G, 255); + else analogWrite(LED_G, 0); + if (digitalRead(BUTTON_B) == LOW) analogWrite(LED_B, 255); + else analogWrite(LED_B, 0); +} \ No newline at end of file diff --git a/esp32/level3/button_RGB_led/wokwi.toml b/esp32/level3/button_RGB_led/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level3/button_RGB_led/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level3/button_led/.DS_Store b/esp32/level3/button_led/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..3b0450f06e942d2cd9df447c33b8c0860b9a140c Binary files /dev/null and b/esp32/level3/button_led/.DS_Store differ diff --git a/esp32/level3/button_led/description_esp.md b/esp32/level3/button_led/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..303404ba7ef584a481bfea7f1af9d5d445c8df35 --- /dev/null +++ b/esp32/level3/button_led/description_esp.md @@ -0,0 +1,39 @@ +# Button Controlled LED + +## Project Description +This is a ESP32 project that controls an LED with a pushbutton. The LED will turn on only while the button is pressed and turn off when released. + +## Hardware Components +- ESP32 DevKit v1 +- Push Button +- 220Ω resistor +- LED + +## Circuit Description +The circuit consists of: +- A pushbutton connected to a digital pin. +- An LED connected to a digital output pin through a 220Ω current-limiting resistor +- The cathode (negative leg) of the LED is connected to ground + +## Expected Behavior +When the ESP32 powers up, it should: +1. Configure the button pin as INPUT +2. Configure the LED pin as OUTPUT +3. Continuously monitor the button state +4. Turn the LED ON when the button is pressed (reads LOW) +5. Turn the LED OFF when the button is released (reads HIGH) + +## Success Criteria +The test is successful when: +1. The LED turns on immediately when the button is pressed +2. The LED remains on only while the button is held down +3. The LED turns off immediately when the button is released + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- The button input will read LOW when pressed if using a pull-up resistor configuration +- Ensure proper current-limiting resistor for the LED based on its specifications +- When the button is not pressed, pin1.l is connected to pin1.r and pin2.l is connected to pin2.r. When the button is pressed, all the pins are connected together. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/esp32/level3/button_led/diagram_breadboard_esp.json b/esp32/level3/button_led/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..76ade967bd071be95d69592c5376754e9324cd49 --- /dev/null +++ b/esp32/level3/button_led/diagram_breadboard_esp.json @@ -0,0 +1,167 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Button LED", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -89.4, + "left": -6.8, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 200, + "left": 20, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 24, + "left": 114.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -10.2, + "left": 252.6, + "rotate": 90, + "attrs": {} + }, + { + "type": "wokwi-led", + "id": "led1", + "top": -51.6, + "left": 119, + "attrs": { + "color": "red" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "push button1:1.l", + "breadboard1:30t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.l", + "breadboard1:28t.c", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.r", + "breadboard1:30b.h", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.r", + "breadboard1:28b.h", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:bn.18", + "breadboard1:28t.b", + "green", + [ + "v0" + ] + ], + [ + "esp1:D2", + "breadboard1:30b.j", + "green", + [ + "v0" + ] + ], + [ + "esp1:GND.1", + "breadboard1:bn.9", + "black", + [ + "v0" + ] + ], + [ + "led1:A", + "breadboard1:14t.d", + "", + [ + "$bb" + ] + ], + [ + "led1:C", + "breadboard1:13t.d", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:bn.8", + "breadboard1:13t.e", + "green", + [ + "v0" + ] + ], + [ + "resistor1:1", + "breadboard1:14t.e", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:14b.i", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:14b.j", + "esp1:D13", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level3/button_led/diagram_esp.json b/esp32/level3/button_led/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..0913860e5af9602a540138159fe32c72e8c8c750 --- /dev/null +++ b/esp32/level3/button_led/diagram_esp.json @@ -0,0 +1,95 @@ +{ + "version": 1.0, + "author": "Blind Author", + "editor": "Blind Author", + "description": "Button LED", + "parts": [ + { + "id": "esp1", + "type": "wokwi-esp32-devkit-v1", + "top": 200, + "left": 20 + }, + { + "id": "resistor1", + "type": "wokwi-resistor", + "top": 75, + "left": 115, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "id": "push button1", + "type": "wokwi-pushbutton", + "top": 125, + "left": 180, + "rotate": 90 + }, + { + "id": "led1", + "type": "wokwi-led", + "left": 120, + "top": 0, + "attrs": { + "color": "red" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "esp1:GND.1", + "led1:C", + "black", + [] + ], + [ + "resistor1:1", + "led1:A", + "green", + [] + ], + [ + "esp1:D13", + "resistor1:2", + "green", + [ + "*", + "h0" + ] + ], + [ + "esp1:D2", + "push button1:1.r", + "red", + [ + "v-12", + "*", + "h0" + ] + ], + [ + "esp1:GND.1", + "push button1:2.l", + "red", + [ + "v-95", + "*", + "h0" + ] + ] + ] +} \ No newline at end of file diff --git a/esp32/level3/button_led/platformio.ini b/esp32/level3/button_led/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..931f8e51c8b316966aadabc57f6e4c0a1e61204c --- /dev/null +++ b/esp32/level3/button_led/platformio.ini @@ -0,0 +1,26 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 + +lib_deps = + Arduino \ No newline at end of file diff --git a/esp32/level3/button_led/scenario.yaml b/esp32/level3/button_led/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a7c16d7b8596ce6d6fb5f80afe08664397221e0e --- /dev/null +++ b/esp32/level3/button_led/scenario.yaml @@ -0,0 +1,61 @@ +author: Blind Author +description: LED lights up when the button is pressed +name: Button LED +steps: +- delay: 100ms +- set-control: + control: pressed + part-id: push button1 + value: 1 +- delay: 500ms +- expect-pin: + part-id: led1 + pin: C + value: 0 +- expect-pin: + part-id: led1 + pin: A + value: 1 +- delay: 500ms +- set-control: + control: pressed + part-id: push button1 + value: 0 +- delay: 300ms +- expect-pin: + part-id: led1 + pin: C + value: 0 +- expect-pin: + part-id: led1 + pin: A + value: 0 +- delay: 500ms +- set-control: + control: pressed + part-id: push button1 + value: 1 +- delay: 300ms +- expect-pin: + part-id: led1 + pin: C + value: 0 +- expect-pin: + part-id: led1 + pin: A + value: 1 +- delay: 500ms +- set-control: + control: pressed + part-id: push button1 + value: 0 +- delay: 300ms +- expect-pin: + part-id: led1 + pin: C + value: 0 +- expect-pin: + part-id: led1 + pin: A + value: 0 +version: 1.0 diff --git a/esp32/level3/button_led/src/main_esp.cpp b/esp32/level3/button_led/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..28d2fba6483eadf7a3be04c5036c59fe3bb1c249 --- /dev/null +++ b/esp32/level3/button_led/src/main_esp.cpp @@ -0,0 +1,29 @@ +/** + Press the button to turn on the LED + 31 Mar 2025 by Blind Author +*/ +#include + +const int BUTTON_PIN = 2; +const int LED_PIN = 13; + +void setup() { + Serial.begin(9600); + Serial.println("Button LED test starts"); + + pinMode(BUTTON_PIN, INPUT_PULLUP); + pinMode(LED_PIN, OUTPUT); +} + +void loop() { + int buttonState = digitalRead(BUTTON_PIN); + + if (buttonState == LOW) { + digitalWrite(LED_PIN, HIGH); + } + + else { + digitalWrite(LED_PIN, LOW); + } + +} \ No newline at end of file diff --git a/esp32/level3/button_led/wokwi.toml b/esp32/level3/button_led/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level3/button_led/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level3/photoresistor_bar_led/.DS_Store b/esp32/level3/photoresistor_bar_led/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b88cd06c171a6d6832fc043fd03fd2cd657ca877 Binary files /dev/null and b/esp32/level3/photoresistor_bar_led/.DS_Store differ diff --git a/esp32/level3/photoresistor_bar_led/description_esp.md b/esp32/level3/photoresistor_bar_led/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..461e0802cd6072c72249ecec0c75c256b6735d79 --- /dev/null +++ b/esp32/level3/photoresistor_bar_led/description_esp.md @@ -0,0 +1,31 @@ +# Photoresitor Bar LED + +## Project Description +This is an ESP32 project that lights up the bar LED according to the brightness level. + +## Hardware Components +- ESP32 DevKit v1 +- Bar graph LED +- 220Ω resistor * 10 +- Photoresistor + +## Circuit Description +Anode pins 1~10 of bar graph LED are connected to pin2, pin4, pin5, pin12, pin13, pin14, pin18, pin19, pin21, pin22, respectively. The cathode pins 1 through 10 of the bar graph LED are connected to GND pin gnd2 through 220kΩ resistors. The AO pin of the photoresistor is connected to the ESP32 34 pin, the GND pin is connected to gnd2, and the VCC pin is connected to 3V3. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Set pin2, pin4, pin5, pin12, pin13, pin14, pin18, pin19, pin21, pin22 pin mode as OUTPUT +2. Set photoresistor signal pin 34 as INPUT +3. Continuously read the photoresistor value, which ranges from 4095 to 0, and map it to a range of 0 to 10 +4. Turn on only the LEDs up to the mapped value, and turn off the rest. + +## Success Criteria +The test is successful when: +1. Anode of the bar LED pins whose number is smaller than the mapped value receive HIGH signals, while greater pins receive LOW signals. + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- Photoresistor's analog value ranges from 4095 to 0. The smaller the analog value, the brighter the light. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/esp32/level3/photoresistor_bar_led/diagram_breadboard_esp.json b/esp32/level3/photoresistor_bar_led/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..6ebbf45009e55537dbdf3be78cec6cd15b53fccf --- /dev/null +++ b/esp32/level3/photoresistor_bar_led/diagram_breadboard_esp.json @@ -0,0 +1,676 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Control bar LED with photoresistor", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -377.4, + "left": -208.4, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": -124.2, + "left": -10.2, + "attrs": {} + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor1", + "top": -365.1, + "left": -130.3, + "rotate": 90, + "attrs": { + "lux": "550" + } + }, + { + "type": "wokwi-led-bar-graph", + "id": "bar graph led1", + "top": -321.8, + "left": 129.8, + "rotate": 90, + "attrs": { + "color": "lime" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -254.95, + "left": 190.6, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -245.35, + "left": 181, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -235.75, + "left": 171.4, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": -216, + "left": 133.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": -216, + "left": 124.25, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -216, + "left": 114.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": -216, + "left": 105.05, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": -236.05, + "left": 67.2, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor9", + "top": -245.65, + "left": 57.6, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor10", + "top": -255.25, + "left": 48, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "bar graph led1:A1", + "breadboard1:40t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A2", + "breadboard1:39t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A3", + "breadboard1:38t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A4", + "breadboard1:37t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A5", + "breadboard1:36t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A6", + "breadboard1:35t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A7", + "breadboard1:34t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A8", + "breadboard1:33t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A9", + "breadboard1:32t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A10", + "breadboard1:31t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C1", + "breadboard1:40b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C2", + "breadboard1:39b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C3", + "breadboard1:38b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C4", + "breadboard1:37b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C5", + "breadboard1:36b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C6", + "breadboard1:35b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C7", + "breadboard1:34b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C8", + "breadboard1:33b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C9", + "breadboard1:32b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C10", + "breadboard1:31b.f", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:46b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:40b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:45b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:39b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:44b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:38b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor5:1", + "breadboard1:36b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor5:2", + "breadboard1:bn.29", + "", + [ + "$bb" + ] + ], + [ + "resistor4:1", + "breadboard1:37b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor4:2", + "breadboard1:bn.30", + "", + [ + "$bb" + ] + ], + [ + "resistor6:1", + "breadboard1:35b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor6:2", + "breadboard1:bn.28", + "", + [ + "$bb" + ] + ], + [ + "resistor7:1", + "breadboard1:34b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor7:2", + "breadboard1:bn.27", + "", + [ + "$bb" + ] + ], + [ + "resistor8:1", + "breadboard1:27b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor8:2", + "breadboard1:33b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor9:1", + "breadboard1:26b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor9:2", + "breadboard1:32b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor10:1", + "breadboard1:25b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor10:2", + "breadboard1:31b.g", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:27b.j", + "breadboard1:bn.21", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:26b.i", + "breadboard1:bn.20", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:25b.h", + "breadboard1:bn.19", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:44b.j", + "breadboard1:bn.35", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:45b.i", + "breadboard1:bn.36", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:46b.h", + "breadboard1:bn.37", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:40t.d", + "esp1:D2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:39t.d", + "esp1:D4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:38t.d", + "esp1:D5", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:37t.d", + "esp1:D12", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:36t.d", + "esp1:D13", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:35t.d", + "esp1:D14", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:34t.d", + "esp1:D18", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:33t.d", + "esp1:D19", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:32t.d", + "esp1:D21", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:31t.d", + "esp1:D22", + "green", + [ + "v0" + ] + ], + [ + "photoresistor1:VCC", + "breadboard1:17b.g", + "", + [ + "$bb" + ] + ], + [ + "photoresistor1:GND", + "breadboard1:16b.g", + "", + [ + "$bb" + ] + ], + [ + "photoresistor1:DO", + "breadboard1:15b.g", + "", + [ + "$bb" + ] + ], + [ + "photoresistor1:AO", + "breadboard1:14b.g", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:14b.h", + "esp1:D34", + "green", + [ + "v345.6", + "h259.2" + ] + ], + [ + "breadboard1:16b.h", + "breadboard1:bn.12", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:17b.h", + "breadboard1:bp.13", + "red", + [ + "v0" + ] + ], + [ + "breadboard1:bp.1", + "esp1:3V3", + "red", + [ + "v277.5", + "h316" + ] + ], + [ + "breadboard1:bn.1", + "esp1:GND.2", + "black", + [ + "v267.5", + "h325.6" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level3/photoresistor_bar_led/diagram_esp.json b/esp32/level3/photoresistor_bar_led/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..af05ad824ec90a0aebe27f9927ecaf82563c1014 --- /dev/null +++ b/esp32/level3/photoresistor_bar_led/diagram_esp.json @@ -0,0 +1,429 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Control bar LED with photoresistor", + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-photoresistor-sensor", + "id": "photoresistor1", + "top": -153.9, + "left": -187.9, + "rotate": 90, + "attrs": {} + }, + { + "type": "wokwi-led-bar-graph", + "id": "bar graph led1", + "top": -244.8, + "left": -24, + "attrs": { + "color": "lime" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -245.65, + "left": 28.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -236.05, + "left": 28.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -226.45, + "left": 28.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": -216.85, + "left": 28.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": -207.25, + "left": 28.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -197.65, + "left": 28.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": -188.05, + "left": 28.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": -178.45, + "left": 28.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor9", + "top": -168.85, + "left": 28.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor10", + "top": -159.25, + "left": 28.8, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "photoresistor1:AO", + "esp1:D34", + "green", + [ + "v19.2", + "h211.2", + "v296.9", + "h83.9" + ] + ], + [ + "photoresistor1:GND", + "esp1:GND.2", + "black", + [ + "v28.8", + "h-114.8", + "v316.4", + "h351.9" + ] + ], + [ + "photoresistor1:VCC", + "esp1:3V3", + "red", + [ + "v38.4", + "h-134.4", + "v307.2", + "h352" + ] + ], + [ + "resistor1:2", + "esp1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "resistor2:2", + "esp1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "resistor3:2", + "esp1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "resistor4:2", + "esp1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "resistor5:2", + "esp1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "resistor6:2", + "esp1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "resistor7:2", + "esp1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "resistor8:2", + "esp1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "resistor9:2", + "esp1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "resistor10:2", + "esp1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "esp1:D2", + "bar graph led1:A1", + "green", + [ + "v-105", + "h-294.1", + "v-144" + ] + ], + [ + "esp1:D4", + "bar graph led1:A2", + "green", + [ + "v-105", + "h-284.6", + "v-134.4" + ] + ], + [ + "esp1:D5", + "bar graph led1:A3", + "green", + [ + "v-105", + "h-275.1", + "v-124.8" + ] + ], + [ + "esp1:D12", + "bar graph led1:A4", + "green", + [ + "v-105", + "h-265.6", + "v-115.2" + ] + ], + [ + "esp1:D13", + "bar graph led1:A5", + "green", + [ + "v-105", + "h-256.1", + "v-105.59" + ] + ], + [ + "esp1:D14", + "bar graph led1:A6", + "green", + [ + "v-105", + "h-246.6", + "v-95.99" + ] + ], + [ + "esp1:D18", + "bar graph led1:A7", + "green", + [ + "v-105", + "h-230.6", + "v-86.39" + ] + ], + [ + "esp1:D19", + "bar graph led1:A8", + "green", + [ + "v-105", + "h-220.6", + "v-76.79" + ] + ], + [ + "esp1:D21", + "bar graph led1:A9", + "green", + [ + "v-105", + "h-211.1", + "v-67.19" + ] + ], + [ + "esp1:D22", + "bar graph led1:A10", + "green", + [ + "v-105", + "h-201.6", + "v-57.59" + ] + ], + [ + "resistor1:1", + "bar graph led1:C1", + "green", + [ + "v0" + ] + ], + [ + "resistor2:1", + "bar graph led1:C2", + "green", + [ + "v0" + ] + ], + [ + "resistor3:1", + "bar graph led1:C3", + "green", + [ + "v0" + ] + ], + [ + "resistor4:1", + "bar graph led1:C4", + "green", + [ + "v0" + ] + ], + [ + "resistor5:1", + "bar graph led1:C5", + "green", + [ + "v0" + ] + ], + [ + "resistor6:1", + "bar graph led1:C6", + "green", + [ + "v0" + ] + ], + [ + "resistor7:1", + "bar graph led1:C7", + "green", + [ + "v0" + ] + ], + [ + "resistor8:1", + "bar graph led1:C8", + "green", + [ + "v0" + ] + ], + [ + "resistor9:1", + "bar graph led1:C9", + "green", + [ + "v0" + ] + ], + [ + "resistor10:1", + "bar graph led1:C10", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level3/photoresistor_bar_led/platformio.ini b/esp32/level3/photoresistor_bar_led/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..931f8e51c8b316966aadabc57f6e4c0a1e61204c --- /dev/null +++ b/esp32/level3/photoresistor_bar_led/platformio.ini @@ -0,0 +1,26 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 + +lib_deps = + Arduino \ No newline at end of file diff --git a/esp32/level3/photoresistor_bar_led/scenario.yaml b/esp32/level3/photoresistor_bar_led/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..18c848a313d9d8ce108e76f010bd4bd524071a17 --- /dev/null +++ b/esp32/level3/photoresistor_bar_led/scenario.yaml @@ -0,0 +1,74 @@ +author: Blind Author +description: Control bar LED with photoresistor +name: Photoresistor Bar LED +test-values: +- part-type: wokwi-photoresistor-sensor + attr-name: lux + value: '550' +steps: +- delay: 500ms +- wait-multi-pin: + timeout: 1000 + interval: 200 + pins: + - part-id: bar graph led1 + pin: A1 + value: 1 + - part-id: bar graph led1 + pin: A2 + value: 1 + - part-id: bar graph led1 + pin: A3 + value: 1 + - part-id: bar graph led1 + pin: A4 + value: 1 + - part-id: bar graph led1 + pin: A5 + value: 1 + - part-id: bar graph led1 + pin: A6 + value: 1 + - part-id: bar graph led1 + pin: A7 + value: 1 + - part-id: bar graph led1 + pin: A8 + value: 0 + - part-id: bar graph led1 + pin: A9 + value: 0 + - part-id: bar graph led1 + pin: A10 + value: 0 + - part-id: bar graph led1 + pin: C1 + value: 0 + - part-id: bar graph led1 + pin: C2 + value: 0 + - part-id: bar graph led1 + pin: C3 + value: 0 + - part-id: bar graph led1 + pin: C4 + value: 0 + - part-id: bar graph led1 + pin: C5 + value: 0 + - part-id: bar graph led1 + pin: C6 + value: 0 + - part-id: bar graph led1 + pin: C7 + value: 0 + - part-id: bar graph led1 + pin: C8 + value: 0 + - part-id: bar graph led1 + pin: C9 + value: 0 + - part-id: bar graph led1 + pin: C10 + value: 0 +version: 1.0 diff --git a/esp32/level3/photoresistor_bar_led/src/main_esp.cpp b/esp32/level3/photoresistor_bar_led/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a7b72299f075445026c4fa337eafb56a7497580a --- /dev/null +++ b/esp32/level3/photoresistor_bar_led/src/main_esp.cpp @@ -0,0 +1,33 @@ +/** + Control bar LED with photoresistor + 06 MAY 2025 by Blind Author +*/ +#include + +const int analogPin = 34; +const int ledCount = 10; + +int ledPins[] = { + 2, 4, 5, 12, 13, 14, 18, 19, 21, 22 +}; + +void setup() { + for (int thisLed = 0; thisLed < ledCount; thisLed++) { + pinMode(ledPins[thisLed], OUTPUT); + } + pinMode(analogPin, INPUT); +} + +void loop() { + int sensorReading = analogRead(analogPin); + int ledLevel = map(sensorReading, 1023, 0, 0, ledCount); + + for (int thisLed = 0; thisLed < ledCount; thisLed++) { + if (thisLed < ledLevel) { + digitalWrite(ledPins[thisLed], HIGH); + } + else { + digitalWrite(ledPins[thisLed], LOW); + } + } +} \ No newline at end of file diff --git a/esp32/level3/photoresistor_bar_led/wokwi.toml b/esp32/level3/photoresistor_bar_led/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level3/photoresistor_bar_led/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level3/potentiometer_bar_led/.DS_Store b/esp32/level3/potentiometer_bar_led/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b88cd06c171a6d6832fc043fd03fd2cd657ca877 Binary files /dev/null and b/esp32/level3/potentiometer_bar_led/.DS_Store differ diff --git a/esp32/level3/potentiometer_bar_led/description_esp.md b/esp32/level3/potentiometer_bar_led/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..b188e66201cbf0e3d41d3b900370a62a5a449e05 --- /dev/null +++ b/esp32/level3/potentiometer_bar_led/description_esp.md @@ -0,0 +1,34 @@ +# Potentiometer Bar LED + +## Project Description +This is a simple ESP32 project that controls bar graph LED with a potentiometer. + +## Hardware Components +- ESP32 DevKit v1 +- Bar graph LED +- 220Ω resistor * 10 +- Potentiometer + +## Circuit Description +Anode pins 1~10 of bar graph LED are connected to pin2, pin4, pin5, pin12, pin13, pin14, pin18, pin19, pin21, pin22, respectively. The cathode pins 1 through 10 of the bar graph LED are connected to GND pin gnd1 through 220kΩ resistors. The SIG pin of the potentiometer is connected to the pin34, the GND pin is connected to gnd1, and the VCC pin is connected to 3V3. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Set pin2, pin4, pin5, pin12, pin13, pin14, pin18, pin19, pin21, pin22 pin mode as OUTPUT +2. Set potentiometer signal pin 34 as INPUT +3. Continuously read the potentiometer value, which ranges from 0 to 4095, and map it to a range of 0 to 10 +4. Turn on only the LEDs up to the mapped value, and turn off the rest. + +## Success Criteria +The test is successful when: +1. Anode of the bar LED pins whose number is smaller than the mapped value receive HIGH signals, while greater pins receive LOW signals. + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- Potentiometer value ranges from 0 to 4095. + +## Variants +This project may have different variants with the LED, potentiometer connected to different pins or using LEDs of different colors. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/esp32/level3/potentiometer_bar_led/diagram_breadboard_esp.json b/esp32/level3/potentiometer_bar_led/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..9cbed6d654691dff1a657378565dda01496ea34c --- /dev/null +++ b/esp32/level3/potentiometer_bar_led/diagram_breadboard_esp.json @@ -0,0 +1,690 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Control bar LED with potentiometer", + "config": { + "1_pin": 2, + "2_pin": 3, + "3_pin": 4, + "4_pin": 5, + "5_pin": 6, + "6_pin": 7, + "7_pin": 8, + "8_pin": 9, + "9_pin": 10, + "10_pin": 11, + "led_color": "lime", + "gnd_pin": "GND.1", + "vcc_pin": "5V", + "potentiometer_sig_pin": "A0" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -156.6, + "left": 406, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 91.1, + "left": 503.8, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -34.45, + "left": 652.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-led-bar-graph", + "id": "bar graph led1", + "top": -101, + "left": 734.6, + "rotate": 90, + "attrs": { + "color": "lime" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -24.85, + "left": 662.4, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -15.25, + "left": 672, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 4.8, + "left": 709.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": -34.45, + "left": 796.8, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": -24.85, + "left": 787.2, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": -15.25, + "left": 777.6, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": 4.8, + "left": 738.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor9", + "top": 4.8, + "left": 719.45, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor10", + "top": 4.8, + "left": 729.05, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-potentiometer", + "id": "potentiometer1", + "top": -106.9, + "left": 479.8, + "attrs": { + "value": "615" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "breadboard1:43b.j", + "breadboard1:bn.35", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:44b.i", + "breadboard1:bn.36", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:45b.h", + "breadboard1:bn.37", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:26b.j", + "breadboard1:bn.21", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:25b.i", + "breadboard1:bn.20", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:24b.h", + "breadboard1:bn.19", + "green", + [ + "v0" + ] + ], + [ + "esp1:GND.1", + "breadboard1:bn.24", + "black", + [ + "v0" + ] + ], + [ + "breadboard1:30t.d", + "esp1:D22", + "green", + [ + "v-105.6", + "h48" + ] + ], + [ + "breadboard1:31t.d", + "esp1:D21", + "green", + [ + "v-115.2", + "h57.6" + ] + ], + [ + "breadboard1:32t.d", + "esp1:D19", + "green", + [ + "v-124.8", + "h57.6" + ] + ], + [ + "breadboard1:33t.d", + "esp1:D18", + "green", + [ + "v-134.4", + "h57.6" + ] + ], + [ + "breadboard1:34t.d", + "esp1:D14", + "green", + [ + "v-96", + "h57.6" + ] + ], + [ + "breadboard1:35t.d", + "esp1:D13", + "green", + [ + "v-105.6", + "h57.6" + ] + ], + [ + "breadboard1:36t.d", + "esp1:D12", + "green", + [ + "v-115.2", + "h67.2" + ] + ], + [ + "breadboard1:37t.d", + "esp1:D5", + "green", + [ + "v-86.4", + "h67.2" + ] + ], + [ + "breadboard1:38t.d", + "esp1:D4", + "green", + [ + "v-76.8", + "h67.2" + ] + ], + [ + "breadboard1:39t.d", + "esp1:D2", + "green", + [ + "v-96", + "h67.2" + ] + ], + [ + "breadboard1:11b.h", + "breadboard1:bp.8", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:10b.h", + "esp1:D34", + "blue", + [ + "v307.2", + "h316.8" + ] + ], + [ + "breadboard1:9b.h", + "breadboard1:bn.6", + "green", + [ + "v0" + ] + ], + [ + "esp1:3V3", + "breadboard1:bp.9", + "red", + [ + "v76.7", + "h-236.2" + ] + ], + [ + "resistor1:1", + "breadboard1:24b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:30b.g", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A1", + "breadboard1:39t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A2", + "breadboard1:38t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A3", + "breadboard1:37t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A4", + "breadboard1:36t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A5", + "breadboard1:35t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A6", + "breadboard1:34t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A7", + "breadboard1:33t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A8", + "breadboard1:32t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A9", + "breadboard1:31t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:A10", + "breadboard1:30t.e", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C1", + "breadboard1:39b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C2", + "breadboard1:38b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C3", + "breadboard1:37b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C4", + "breadboard1:36b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C5", + "breadboard1:35b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C6", + "breadboard1:34b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C7", + "breadboard1:33b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C8", + "breadboard1:32b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C9", + "breadboard1:31b.f", + "", + [ + "$bb" + ] + ], + [ + "bar graph led1:C10", + "breadboard1:30b.f", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:25b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:31b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:32b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:26b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor4:1", + "breadboard1:33b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor4:2", + "breadboard1:bn.26", + "", + [ + "$bb" + ] + ], + [ + "resistor5:1", + "breadboard1:39b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor5:2", + "breadboard1:45b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor6:1", + "breadboard1:38b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor6:2", + "breadboard1:44b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor7:1", + "breadboard1:37b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor7:2", + "breadboard1:43b.i", + "", + [ + "$bb" + ] + ], + [ + "resistor8:1", + "breadboard1:36b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor8:2", + "breadboard1:bn.29", + "", + [ + "$bb" + ] + ], + [ + "resistor9:1", + "breadboard1:34b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor9:2", + "breadboard1:bn.27", + "", + [ + "$bb" + ] + ], + [ + "resistor10:1", + "breadboard1:35b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor10:2", + "breadboard1:bn.28", + "", + [ + "$bb" + ] + ], + [ + "potentiometer1:GND", + "breadboard1:9b.f", + "", + [ + "$bb" + ] + ], + [ + "potentiometer1:SIG", + "breadboard1:10b.f", + "", + [ + "$bb" + ] + ], + [ + "potentiometer1:VCC", + "breadboard1:11b.f", + "", + [ + "$bb" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level3/potentiometer_bar_led/diagram_esp.json b/esp32/level3/potentiometer_bar_led/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..9bad4fab8d19b7c38187030c679ae5a1e6816d72 --- /dev/null +++ b/esp32/level3/potentiometer_bar_led/diagram_esp.json @@ -0,0 +1,448 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Control bar LED with potentiometer", + "config": { + "1_pin": 2, + "2_pin": 4, + "3_pin": 5, + "4_pin": 12, + "5_pin": 13, + "6_pin": 14, + "7_pin": 18, + "8_pin": 19, + "9_pin": 21, + "10_pin": 22, + "led_color": "lime", + "gnd_pin": "GND.1", + "potentiometer_sig_pin": "34", + "vcc_pin": "3v3" + }, + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 67.8, + "left": 517.8, + "attrs": {} + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": 109.85, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": 129.05, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": 119.45, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-led-bar-graph", + "id": "bar graph led1", + "top": 110.4, + "left": 849.6, + "attrs": { + "color": "lime" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": 138.65, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": 148.25, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor6", + "top": 157.85, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor7", + "top": 167.45, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor8", + "top": 177.05, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor9", + "top": 186.65, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor10", + "top": 196.25, + "left": 920.2, + "rotate": 180, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-potentiometer", + "id": "potentiometer1", + "top": 325.1, + "left": 662.2, + "attrs": {} + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "resistor1:2", + "bar graph led1:C1", + "green", + [ + "v0" + ] + ], + [ + "resistor3:2", + "bar graph led1:C2", + "green", + [ + "v0" + ] + ], + [ + "resistor2:2", + "bar graph led1:C3", + "green", + [ + "v0" + ] + ], + [ + "resistor4:2", + "bar graph led1:C4", + "green", + [ + "v0" + ] + ], + [ + "resistor5:2", + "bar graph led1:C5", + "green", + [ + "v0" + ] + ], + [ + "resistor6:2", + "bar graph led1:C6", + "green", + [ + "v0" + ] + ], + [ + "resistor7:2", + "bar graph led1:C7", + "green", + [ + "v0" + ] + ], + [ + "resistor8:2", + "bar graph led1:C8", + "green", + [ + "v0" + ] + ], + [ + "resistor9:2", + "bar graph led1:C9", + "green", + [ + "v0" + ] + ], + [ + "resistor10:2", + "bar graph led1:C10", + "green", + [ + "v0" + ] + ], + [ + "esp1:GND.1", + "resistor10:1", + "black", + [ + "v-28.8", + "h365.1", + "v153.6" + ] + ], + [ + "esp1:GND.1", + "resistor9:1", + "black", + [ + "v-28.8", + "h365.1", + "v144" + ] + ], + [ + "esp1:GND.1", + "resistor8:1", + "black", + [ + "v-28.8", + "h365.1", + "v134.4" + ] + ], + [ + "esp1:GND.1", + "resistor7:1", + "black", + [ + "v-28.8", + "h365.1", + "v124.8" + ] + ], + [ + "esp1:GND.1", + "resistor6:1", + "black", + [ + "v-28.8", + "h365.1", + "v115.2" + ] + ], + [ + "esp1:GND.1", + "resistor5:1", + "black", + [ + "v-28.8", + "h365.1", + "v105.6" + ] + ], + [ + "esp1:GND.1", + "resistor4:1", + "black", + [ + "v-28.8", + "h365.1", + "v96" + ] + ], + [ + "esp1:GND.1", + "resistor2:1", + "black", + [ + "v-28.8", + "h365.1", + "v86.4" + ] + ], + [ + "esp1:GND.1", + "resistor3:1", + "black", + [ + "v-28.8", + "h365.1", + "v76.8" + ] + ], + [ + "esp1:GND.1", + "resistor1:1", + "black", + [ + "v-28.8", + "h365.1", + "v67.2" + ] + ], + [ + "bar graph led1:A1", + "esp1:D2", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A2", + "esp1:D4", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A3", + "esp1:D5", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A4", + "esp1:D12", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A5", + "esp1:D13", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A6", + "esp1:D14", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A7", + "esp1:D18", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A8", + "esp1:D19", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A9", + "esp1:D21", + "green", + [ + "h0" + ] + ], + [ + "bar graph led1:A10", + "esp1:D22", + "green", + [ + "h0" + ] + ], + [ + "potentiometer1:VCC", + "esp1:3V3", + "red", + [ + "v0" + ] + ], + [ + "potentiometer1:SIG", + "esp1:D34", + "green", + [ + "v0" + ] + ], + [ + "potentiometer1:GND", + "esp1:GND.1", + "black", + [ + "v0", + "h-201.6", + "v-345.6", + "h144" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level3/potentiometer_bar_led/platformio.ini b/esp32/level3/potentiometer_bar_led/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..a97a95ea397a86776d0eb918f2084fe7fd542dce --- /dev/null +++ b/esp32/level3/potentiometer_bar_led/platformio.ini @@ -0,0 +1,25 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +monitor_speed = 115200 +lib_deps = + Arduino \ No newline at end of file diff --git a/esp32/level3/potentiometer_bar_led/scenario.yaml b/esp32/level3/potentiometer_bar_led/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..75b07c5aaca924062144d8e1efdab45f8cb9b273 --- /dev/null +++ b/esp32/level3/potentiometer_bar_led/scenario.yaml @@ -0,0 +1,142 @@ +author: Blind Author +description: Control bar LED with potentiometer +name: Potentiometer bar LED +steps: +- delay: 1000ms +- set-control: + control: position + part-id: potentiometer1 + value: 0.6 +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: bar graph led1 + pin: A1 + value: 1 + - part-id: bar graph led1 + pin: A2 + value: 1 + - part-id: bar graph led1 + pin: A3 + value: 1 + - part-id: bar graph led1 + pin: A4 + value: 1 + - part-id: bar graph led1 + pin: A5 + value: 1 + - part-id: bar graph led1 + pin: A6 + value: 1 + - part-id: bar graph led1 + pin: A7 + value: 0 + - part-id: bar graph led1 + pin: A8 + value: 0 + - part-id: bar graph led1 + pin: A9 + value: 0 + - part-id: bar graph led1 + pin: A10 + value: 0 + - part-id: bar graph led1 + pin: C1 + value: 0 + - part-id: bar graph led1 + pin: C2 + value: 0 + - part-id: bar graph led1 + pin: C3 + value: 0 + - part-id: bar graph led1 + pin: C4 + value: 0 + - part-id: bar graph led1 + pin: C5 + value: 0 + - part-id: bar graph led1 + pin: C6 + value: 0 + - part-id: bar graph led1 + pin: C7 + value: 0 + - part-id: bar graph led1 + pin: C8 + value: 0 + - part-id: bar graph led1 + pin: C9 + value: 0 + - part-id: bar graph led1 + pin: C10 + value: 0 +- set-control: + control: position + part-id: potentiometer1 + value: 0.3 +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: bar graph led1 + pin: A1 + value: 1 + - part-id: bar graph led1 + pin: A2 + value: 1 + - part-id: bar graph led1 + pin: A3 + value: 1 + - part-id: bar graph led1 + pin: A4 + value: 0 + - part-id: bar graph led1 + pin: A5 + value: 0 + - part-id: bar graph led1 + pin: A6 + value: 0 + - part-id: bar graph led1 + pin: A7 + value: 0 + - part-id: bar graph led1 + pin: A8 + value: 0 + - part-id: bar graph led1 + pin: A9 + value: 0 + - part-id: bar graph led1 + pin: A10 + value: 0 + - part-id: bar graph led1 + pin: C1 + value: 0 + - part-id: bar graph led1 + pin: C2 + value: 0 + - part-id: bar graph led1 + pin: C3 + value: 0 + - part-id: bar graph led1 + pin: C4 + value: 0 + - part-id: bar graph led1 + pin: C5 + value: 0 + - part-id: bar graph led1 + pin: C6 + value: 0 + - part-id: bar graph led1 + pin: C7 + value: 0 + - part-id: bar graph led1 + pin: C8 + value: 0 + - part-id: bar graph led1 + pin: C9 + value: 0 + - part-id: bar graph led1 + pin: C10 + value: 0 +version: 1.0 diff --git a/esp32/level3/potentiometer_bar_led/src/main_esp.cpp b/esp32/level3/potentiometer_bar_led/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..70bb3cb0068bcf2b6f151cd43621b40e8e9abcc3 --- /dev/null +++ b/esp32/level3/potentiometer_bar_led/src/main_esp.cpp @@ -0,0 +1,33 @@ +/** + Control bar LED with potentiometer + 10 APR 2025 by Blind Author +*/ +#include + +const int analogPin = 34; +const int ledCount = 10; + +int ledPins[] = { + 2, 4, 5, 12, 13, 14, 18, 19, 21, 22 +}; + +void setup() { + for (int thisLed = 0; thisLed < ledCount; thisLed++) { + pinMode(ledPins[thisLed], OUTPUT); + } + pinMode(analogPin, INPUT); +} + +void loop() { + int sensorReading = analogRead(analogPin); + int ledLevel = map(sensorReading, 0, 4095, 0, ledCount); + + for (int thisLed = 0; thisLed < ledCount; thisLed++) { + if (thisLed < ledLevel) { + digitalWrite(ledPins[thisLed], HIGH); + } + else { + digitalWrite(ledPins[thisLed], LOW); + } + } +} \ No newline at end of file diff --git a/esp32/level3/potentiometer_bar_led/wokwi.toml b/esp32/level3/potentiometer_bar_led/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level3/potentiometer_bar_led/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level4/binary_led/.DS_Store b/esp32/level4/binary_led/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b88cd06c171a6d6832fc043fd03fd2cd657ca877 Binary files /dev/null and b/esp32/level4/binary_led/.DS_Store differ diff --git a/esp32/level4/binary_led/description_esp.md b/esp32/level4/binary_led/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..933f4dc826b37c26aedbdb08b47f64ec53fc7c8a --- /dev/null +++ b/esp32/level4/binary_led/description_esp.md @@ -0,0 +1,29 @@ +# Binary LED + +## Project Description +This is an ESP32 project that uses 5 LEDs to display the binary form of a number received over serial. + +## Hardware Components +- ESP32 DevKit v1 +- 220Ω resistor * 5 +- LED * 5 + +## Circuit Description +Five LEDs are connected to ESP32. LED 1 to 5 are connected to ESP32 pin2, pin4, pin5, pin12, pin13 through 220Ω resistor, respectively. Cathode pin of each LEDs are connected to gnd2. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Set pin2, pin4, pin5, pin12, pin13 pin mode as OUTPUT +3. Continuously read the serial monitor, which ranges from 0 to 31 +4. With LED1 as the LSB and LED5 as the MSB, light up the LEDs that represent 1s in the binary form of the input number + +## Success Criteria +The test is successful when: +1. When a number is entered via serial input, LEDs corresponding to the bits set to 1 in its binary representation are turned on. + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- Serial input ranges from 0 to 31. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/esp32/level4/binary_led/diagram_breadboard_esp.json b/esp32/level4/binary_led/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..0c0febba50a6dd82725f6bc35ae20dfd575067e3 --- /dev/null +++ b/esp32/level4/binary_led/diagram_breadboard_esp.json @@ -0,0 +1,385 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Use 5 LEDs to display the binary form of a number received over serial", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -291, + "left": 2.8, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-led", + "id": "led1", + "top": -272.4, + "left": 215, + "attrs": { + "color": "red", + "flip": "" + } + }, + { + "type": "wokwi-led", + "id": "led2", + "top": -272.4, + "left": 176.6, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-led", + "id": "led3", + "top": -272.4, + "left": 138.2, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-led", + "id": "led4", + "top": -272.4, + "left": 99.8, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-led", + "id": "led5", + "top": -272.4, + "left": 61.4, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -187.2, + "left": 210.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -187.2, + "left": 172.25, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -187.2, + "left": 133.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": -187.2, + "left": 95.45, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": -187.2, + "left": 57.05, + "rotate": 90, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "led5:A", + "breadboard1:7t.b", + "", + [ + "$bb" + ] + ], + [ + "led5:C", + "breadboard1:6t.b", + "", + [ + "$bb" + ] + ], + [ + "led4:A", + "breadboard1:11t.b", + "", + [ + "$bb" + ] + ], + [ + "led4:C", + "breadboard1:10t.b", + "", + [ + "$bb" + ] + ], + [ + "led3:A", + "breadboard1:15t.b", + "", + [ + "$bb" + ] + ], + [ + "led3:C", + "breadboard1:14t.b", + "", + [ + "$bb" + ] + ], + [ + "led2:A", + "breadboard1:19t.b", + "", + [ + "$bb" + ] + ], + [ + "led2:C", + "breadboard1:18t.b", + "", + [ + "$bb" + ] + ], + [ + "led1:A", + "breadboard1:23t.b", + "", + [ + "$bb" + ] + ], + [ + "led1:C", + "breadboard1:22t.b", + "", + [ + "$bb" + ] + ], + [ + "resistor5:1", + "breadboard1:7t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor5:2", + "breadboard1:7b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor4:1", + "breadboard1:11t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor4:2", + "breadboard1:11b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor3:1", + "breadboard1:15t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:15b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:19t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:19b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:23t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:23b.h", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:6t.d", + "breadboard1:bn.4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:10t.d", + "breadboard1:bn.7", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:14t.d", + "breadboard1:bn.11", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:18t.d", + "breadboard1:bn.14", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:22t.d", + "breadboard1:bn.17", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:23b.j", + "esp1:D2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:19b.j", + "esp1:D4", + "green", + [ + "v115.2", + "h28.8" + ] + ], + [ + "breadboard1:15b.j", + "esp1:D5", + "green", + [ + "v124.8", + "h57.6" + ] + ], + [ + "breadboard1:11b.j", + "esp1:D12", + "green", + [ + "v105.6", + "h76.8" + ] + ], + [ + "breadboard1:7b.j", + "esp1:D13", + "green", + [ + "v115.2", + "h105.6" + ] + ], + [ + "breadboard1:bn.1", + "esp1:GND.2", + "black", + [ + "v267.5", + "h124" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level4/binary_led/diagram_esp.json b/esp32/level4/binary_led/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..eceab053cf5d29ab88c17fdcded23dd68ca6629e --- /dev/null +++ b/esp32/level4/binary_led/diagram_esp.json @@ -0,0 +1,261 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Use 5 LEDs to display the binary form of a number received over serial", + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 0, + "left": 0, + "attrs": {} + }, + { + "type": "wokwi-led", + "id": "led1", + "top": -166.8, + "left": 243.8, + "attrs": { + "color": "red", + "flip": "" + } + }, + { + "type": "wokwi-led", + "id": "led2", + "top": -166.8, + "left": 215, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-led", + "id": "led3", + "top": -166.8, + "left": 186.2, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-led", + "id": "led4", + "top": -166.8, + "left": 147.8, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-led", + "id": "led5", + "top": -166.8, + "left": 119, + "attrs": { + "color": "red" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -91.2, + "left": 239.45, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -91.2, + "left": 210.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -91.2, + "left": 181.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor4", + "top": -91.2, + "left": 153.05, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor5", + "top": -91.2, + "left": 124.25, + "rotate": 90, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "led1:A", + "resistor1:1", + "green", + [ + "v0" + ] + ], + [ + "resistor1:2", + "esp1:D2", + "green", + [ + "h0", + "v46.8", + "h-38.4" + ] + ], + [ + "led2:C", + "esp1:GND.2", + "black", + [ + "v57.6", + "h-191.6", + "v182.4", + "h131.1" + ] + ], + [ + "led3:C", + "esp1:GND.2", + "black", + [ + "v57.6", + "h-162.8", + "v258.7" + ] + ], + [ + "led4:C", + "esp1:GND.2", + "black", + [ + "v57.6", + "h-124.4", + "v182.4", + "h131.1" + ] + ], + [ + "led5:C", + "esp1:GND.2", + "black", + [ + "v57.6", + "h-95.6", + "v182.4", + "h131.1" + ] + ], + [ + "led1:C", + "esp1:GND.2", + "black", + [ + "v57.6", + "h-220.4", + "v182.4", + "h131.1" + ] + ], + [ + "led2:A", + "resistor2:1", + "green", + [ + "v0" + ] + ], + [ + "resistor2:2", + "esp1:D4", + "green", + [ + "h0" + ] + ], + [ + "led3:A", + "resistor3:1", + "green", + [ + "v0" + ] + ], + [ + "resistor3:2", + "esp1:D5", + "green", + [ + "h0" + ] + ], + [ + "led4:A", + "resistor4:1", + "green", + [ + "v0" + ] + ], + [ + "resistor4:2", + "esp1:D12", + "green", + [ + "h0" + ] + ], + [ + "resistor5:1", + "led5:A", + "green", + [ + "h0" + ] + ], + [ + "resistor5:2", + "esp1:D13", + "green", + [ + "h0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level4/binary_led/platformio.ini b/esp32/level4/binary_led/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..b684c45c413f1156343277a395e69b64e693c7e5 --- /dev/null +++ b/esp32/level4/binary_led/platformio.ini @@ -0,0 +1,24 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +lib_deps = + Arduino \ No newline at end of file diff --git a/esp32/level4/binary_led/scenario.yaml b/esp32/level4/binary_led/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c2faa0bf8723a4cdfb103deb49828521ac9a3347 --- /dev/null +++ b/esp32/level4/binary_led/scenario.yaml @@ -0,0 +1,109 @@ +author: Blind Author +description: Use 5 LEDs to display the binary form of a number received over serial +name: Binary LED +steps: +- delay: 500ms +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: led1 + pin: C + value: 0 + - part-id: led2 + pin: C + value: 0 + - part-id: led3 + pin: C + value: 0 + - part-id: led4 + pin: C + value: 0 + - part-id: led5 + pin: C + value: 0 +- write-serial: '1' +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: led1 + pin: A + value: 1 + - part-id: led2 + pin: A + value: 0 + - part-id: led3 + pin: A + value: 0 + - part-id: led4 + pin: A + value: 0 + - part-id: led5 + pin: A + value: 0 +- write-serial: '7' +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: led1 + pin: A + value: 1 + - part-id: led2 + pin: A + value: 1 + - part-id: led3 + pin: A + value: 1 + - part-id: led4 + pin: A + value: 0 + - part-id: led5 + pin: A + value: 0 +- write-serial: '31' +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: led1 + pin: A + value: 1 + - part-id: led2 + pin: A + value: 1 + - part-id: led3 + pin: A + value: 1 + - part-id: led4 + pin: A + value: 1 + - part-id: led5 + pin: A + value: 1 +- write-serial: '14' +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + interval: 100 + pins: + - part-id: led1 + pin: A + value: 0 + - part-id: led2 + pin: A + value: 1 + - part-id: led3 + pin: A + value: 1 + - part-id: led4 + pin: A + value: 1 + - part-id: led5 + pin: A + value: 0 +version: 1.0 diff --git a/esp32/level4/binary_led/src/main_esp.cpp b/esp32/level4/binary_led/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2c4b5308434fa20aba59c0ddbf5c8cc24d0da81e --- /dev/null +++ b/esp32/level4/binary_led/src/main_esp.cpp @@ -0,0 +1,37 @@ +/** + Use 5 LEDs to display the binary form of a number received over serial + 09 MAY 2025 by Blind Author +*/ +#include + +const int ledPins[5] = {2, 4, 5, 12, 13}; + +void setup() { + Serial.begin(9600); + for (int i = 0; i < 5; i++) { + pinMode(ledPins[i], OUTPUT); + } +} + +void loop() { + if (Serial.available() > 0) { + int number = Serial.parseInt(); + + while (Serial.available()) { + Serial.read(); + } + + for (int i = 0; i < 5; i++) { + int bitValue = (number >> i) & 1; + digitalWrite(ledPins[i], bitValue); + } + + Serial.print("Binary of "); + Serial.print(number); + Serial.print(" is: "); + for (int i = 4; i >= 0; i--) { + Serial.print((number >> i) & 1); + } + Serial.println(); + } +} diff --git a/esp32/level4/binary_led/wokwi.toml b/esp32/level4/binary_led/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level4/binary_led/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level4/calendar_display/.DS_Store b/esp32/level4/calendar_display/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b88cd06c171a6d6832fc043fd03fd2cd657ca877 Binary files /dev/null and b/esp32/level4/calendar_display/.DS_Store differ diff --git a/esp32/level4/calendar_display/description_esp.md b/esp32/level4/calendar_display/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..52de2d7f26aac6da07363e5f10b228043c17d1cf --- /dev/null +++ b/esp32/level4/calendar_display/description_esp.md @@ -0,0 +1,35 @@ +# Calendar Display + +## Project Description +This is a simple ESP32 project that uses an RTC module to display the current date and day of the week on ili9341 LCD, and navigate days with buttons. + +## Hardware Components +- ESP32 DevKit v1 +- RTC module ds1307 +- Ili9341 LCD Display +- Push Button * 2 +- 10kΩ resistor * 2 + +## Circuit Description +RTC module, ili9341 LCD display, two push buttons are connected to ESP32. For LCD display, VCC and GND are connected to ESP32 gnd2 and 3V3. RST, D/C, CS, MOSI, MISO, SCK pin of LCD display is connected to ESP32 pin4, pin2, pin15, pin23, pin19, pin18, respectively. For RTC module, SDA pin and SCL pin are connected to pin21 and pin22, and 5V and GND are connected to ESP32 3V3 and gnd2. Button 1 is connected to ESP32 pin13, and button 2 is connected to pin 12. When the button is not pressed, it is connected to gnd2 by 10kΩ resistor. When the button is pressed, it is connected to ESP32 3V3. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Initialize the RTC module and check if it can begin +2. Set text size as 3, and text color to white. +3. Continuously read the current time, and show YYYY-MM-DD to (10, 30) position. +4. Also show days of the week to (10, 80) position. + +## Success Criteria +The test is successful when: +1. The correct date is displayed on the screen. +2. When a button is pressed, the displayed date changes correctly. + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- Day of the week is one of the "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". +- Button 1 corresponds to the previous date, and Button 2 to the next date. +- Use , , "RTClib.h" libraries. + +## Attributes +- To use 10kΩ resistor, set the property name "value" to "10000 ohm". \ No newline at end of file diff --git a/esp32/level4/calendar_display/diagram_breadboard_esp.json b/esp32/level4/calendar_display/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..dcabc6ed4659228241efd4932d23901b5308089e --- /dev/null +++ b/esp32/level4/calendar_display/diagram_breadboard_esp.json @@ -0,0 +1,472 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Using an RTC, display the current date and day of the week on ili9341 LCD, and navigate days with buttons", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -319.8, + "left": -102.8, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-ili9341", + "id": "ili9341 lcd display1", + "top": -488.8, + "left": 57.3, + "attrs": {} + }, + { + "type": "wokwi-ds1307", + "id": "rtc module1", + "top": -273.5, + "left": 381.2, + "rotate": 270, + "attrs": { + "initTime": "2025-05-10T02:04:00" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -250.2, + "left": -25.8, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button2", + "top": -250.2, + "left": 252.6, + "rotate": 90, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -187.75, + "left": -59, + "rotate": 180, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -187.75, + "left": 296.2, + "rotate": 180, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "ili9341 lcd display1:VCC", + "breadboard1:20b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:GND", + "breadboard1:21b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:CS", + "breadboard1:22b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:RST", + "breadboard1:23b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:D/C", + "breadboard1:24b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:MOSI", + "breadboard1:25b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:SCK", + "breadboard1:26b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:LED", + "breadboard1:27b.f", + "", + [ + "$bb" + ] + ], + [ + "ili9341 lcd display1:MISO", + "breadboard1:28b.f", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:20b.h", + "breadboard1:bp.15", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:21b.h", + "breadboard1:bn.16", + "green", + [ + "v0" + ] + ], + [ + "push button1:1.l", + "breadboard1:11t.b", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.l", + "breadboard1:9t.b", + "", + [ + "$bb" + ] + ], + [ + "push button1:1.r", + "breadboard1:11b.g", + "", + [ + "$bb" + ] + ], + [ + "push button1:2.r", + "breadboard1:9b.g", + "", + [ + "$bb" + ] + ], + [ + "push button2:1.l", + "breadboard1:40t.b", + "", + [ + "$bb" + ] + ], + [ + "push button2:2.l", + "breadboard1:38t.b", + "", + [ + "$bb" + ] + ], + [ + "push button2:1.r", + "breadboard1:40b.g", + "", + [ + "$bb" + ] + ], + [ + "push button2:2.r", + "breadboard1:38b.g", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:9b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:3b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:46b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:40b.h", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:3b.j", + "breadboard1:bn.2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:46b.j", + "breadboard1:bn.36", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:9t.a", + "esp1:D13", + "green", + [ + "v240", + "h211.2" + ] + ], + [ + "breadboard1:40t.a", + "esp1:D12", + "green", + [ + "v240", + "h-86.4" + ] + ], + [ + "breadboard1:38b.h", + "breadboard1:bp.31", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:11b.h", + "breadboard1:bp.8", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:22b.h", + "esp1:D15", + "green", + [ + "v134.4", + "h9.6" + ] + ], + [ + "breadboard1:23b.h", + "esp1:D4", + "green", + [ + "v134.4", + "h19.2" + ] + ], + [ + "breadboard1:24b.h", + "esp1:D2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:25b.h", + "esp1:D23", + "green", + [ + "v163.2", + "h-28.8" + ] + ], + [ + "breadboard1:26b.h", + "esp1:D18", + "green", + [ + "v163.2", + "h-57.6" + ] + ], + [ + "breadboard1:28b.h", + "esp1:D19", + "green", + [ + "v172.8", + "h-67.2" + ] + ], + [ + "rtc module1:GND", + "breadboard1:51b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:5V", + "breadboard1:52b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:SDA", + "breadboard1:53b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:SCL", + "breadboard1:54b.g", + "", + [ + "$bb" + ] + ], + [ + "rtc module1:SQW", + "breadboard1:55b.g", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:51b.i", + "breadboard1:bn.41", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:52b.i", + "breadboard1:bp.42", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:53b.i", + "esp1:D21", + "green", + [ + "v374.4", + "h-201.6" + ] + ], + [ + "breadboard1:54b.i", + "esp1:D22", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:bn.1", + "esp1:GND.2", + "green", + [ + "v334.7", + "h210.4" + ] + ], + [ + "breadboard1:bp.3", + "esp1:3V3", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level4/calendar_display/diagram_esp.json b/esp32/level4/calendar_display/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..d80428af831aaa474e1ec5269e2a9b73e6edb9c5 --- /dev/null +++ b/esp32/level4/calendar_display/diagram_esp.json @@ -0,0 +1,265 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Using an RTC, display the current date and day of the week on ili9341 LCD, and navigate days with buttons", + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": -9, + "left": -19.8, + "attrs": {} + }, + { + "type": "wokwi-ili9341", + "id": "ili9341 lcd display1", + "top": -344.8, + "left": 66.9, + "attrs": {} + }, + { + "type": "wokwi-ds1307", + "id": "rtc module1", + "top": 234.6, + "left": 201.7, + "attrs": { + "initTime": "2025-05-10T02:04:00" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button1", + "top": -205, + "left": -38.4, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-pushbutton", + "id": "push button2", + "top": -205, + "left": 288, + "attrs": { + "color": "green", + "xray": "1" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -129.6, + "left": -77.35, + "rotate": 90, + "attrs": { + "value": "10000" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -129.6, + "left": 335.45, + "rotate": 90, + "attrs": { + "value": "10000" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "rtc module1:GND", + "esp1:GND.2", + "black", + [ + "h0" + ] + ], + [ + "rtc module1:5V", + "esp1:3V3", + "red", + [ + "h0" + ] + ], + [ + "rtc module1:SDA", + "esp1:D21", + "green", + [ + "h0" + ] + ], + [ + "rtc module1:SCL", + "esp1:D22", + "green", + [ + "h0" + ] + ], + [ + "push button1:2.l", + "resistor1:1", + "green", + [ + "h0" + ] + ], + [ + "push button2:2.r", + "resistor2:1", + "green", + [ + "h0" + ] + ], + [ + "resistor1:2", + "esp1:GND.2", + "black", + [ + "h0", + "v344.4", + "h201.6" + ] + ], + [ + "resistor2:2", + "esp1:GND.2", + "black", + [ + "h0", + "v315.6", + "h-211.2" + ] + ], + [ + "push button1:2.r", + "esp1:D13", + "green", + [ + "h19.4", + "v153.8", + "h153.6" + ] + ], + [ + "push button2:2.l", + "esp1:D12", + "green", + [ + "h-28.8", + "v153.8", + "h-48" + ] + ], + [ + "ili9341 lcd display1:VCC", + "esp1:3V3", + "red", + [ + "v28.8", + "h-172.8", + "v288", + "h201.6" + ] + ], + [ + "ili9341 lcd display1:GND", + "esp1:GND.2", + "black", + [ + "v48", + "h-172.8", + "v230.4", + "h201.6" + ] + ], + [ + "ili9341 lcd display1:CS", + "esp1:D15", + "orange", + [ + "v0" + ] + ], + [ + "ili9341 lcd display1:RST", + "esp1:D4", + "green", + [ + "v28.8", + "h9.6" + ] + ], + [ + "ili9341 lcd display1:D/C", + "esp1:D2", + "green", + [ + "v0" + ] + ], + [ + "ili9341 lcd display1:MOSI", + "esp1:D23", + "green", + [ + "v0" + ] + ], + [ + "ili9341 lcd display1:SCK", + "esp1:D18", + "green", + [ + "v0" + ] + ], + [ + "ili9341 lcd display1:MISO", + "esp1:D19", + "green", + [ + "v0" + ] + ], + [ + "push button1:1.l", + "esp1:3V3", + "red", + [ + "h-19.2", + "v451.2", + "h201.6" + ] + ], + [ + "push button2:1.r", + "esp1:3V3", + "red", + [ + "v0", + "h19.4", + "v451.2", + "h-240" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level4/calendar_display/platformio.ini b/esp32/level4/calendar_display/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..8bca5a526a5171dac95b8fffc213e99af7f0a919 --- /dev/null +++ b/esp32/level4/calendar_display/platformio.ini @@ -0,0 +1,30 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno +lib_deps = + Arduino + RTClib + Adafruit ILI9341 + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +lib_deps = + Arduino + RTClib + Adafruit ILI9341 \ No newline at end of file diff --git a/esp32/level4/calendar_display/scenario.yaml b/esp32/level4/calendar_display/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3f3b9bb8e5dd2a03112636316fbb843242344161 --- /dev/null +++ b/esp32/level4/calendar_display/scenario.yaml @@ -0,0 +1,50 @@ +author: Blind Author +description: Using an RTC, display the current date and day of the week on ili9341 + LCD, and navigate days with buttons +name: Calendar Display +test-values: +- part-type: wokwi-ds1307 + attr-name: initTime + value: '2025-05-10T02:04:00' +steps: +- delay: 3000ms +- take-screenshot: + part-id: ili9341 lcd display1 + compare-with: screenshots/0.png +- set-control: + control: pressed + part-id: push button1 + value: 1 +- set-control: + control: pressed + part-id: push button1 + value: 0 +- delay: 2000ms +- take-screenshot: + part-id: ili9341 lcd display1 + compare-with: screenshots/1.png +- set-control: + control: pressed + part-id: push button2 + value: 1 +- set-control: + control: pressed + part-id: push button2 + value: 0 +- delay: 2000ms +- take-screenshot: + part-id: ili9341 lcd display1 + compare-with: screenshots/2.png +- set-control: + control: pressed + part-id: push button2 + value: 1 +- set-control: + control: pressed + part-id: push button2 + value: 0 +- delay: 2000ms +- take-screenshot: + part-id: ili9341 lcd display1 + compare-with: screenshots/3.png +version: 1.0 diff --git a/esp32/level4/calendar_display/screenshots/0.png b/esp32/level4/calendar_display/screenshots/0.png new file mode 100644 index 0000000000000000000000000000000000000000..e1d95f76d422ff4d9e58c04108bcf24a1c4b6d72 --- /dev/null +++ b/esp32/level4/calendar_display/screenshots/0.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9d1526e7cbf8e129ef3dfdf08f08de51a1cd59c0b287f32b02aee187172bf45 +size 1678 diff --git a/esp32/level4/calendar_display/screenshots/1.png b/esp32/level4/calendar_display/screenshots/1.png new file mode 100644 index 0000000000000000000000000000000000000000..40562eda96c86a86814d05c0b565ae6271540d20 --- /dev/null +++ b/esp32/level4/calendar_display/screenshots/1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:05a59359d8fb2305f46c2a5817369579e3d9639a12abc6efa97d0721a772f5f8 +size 1593 diff --git a/esp32/level4/calendar_display/screenshots/2.png b/esp32/level4/calendar_display/screenshots/2.png new file mode 100644 index 0000000000000000000000000000000000000000..e1d95f76d422ff4d9e58c04108bcf24a1c4b6d72 --- /dev/null +++ b/esp32/level4/calendar_display/screenshots/2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9d1526e7cbf8e129ef3dfdf08f08de51a1cd59c0b287f32b02aee187172bf45 +size 1678 diff --git a/esp32/level4/calendar_display/screenshots/3.png b/esp32/level4/calendar_display/screenshots/3.png new file mode 100644 index 0000000000000000000000000000000000000000..13ac04380fa191e944ffe5953085ccca21826090 --- /dev/null +++ b/esp32/level4/calendar_display/screenshots/3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e6fce3f810995563894698db031cd2e0c6ffa72f526b4c83c09b063b6e5efb0f +size 1577 diff --git a/esp32/level4/calendar_display/src/main_esp.cpp b/esp32/level4/calendar_display/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..586aaaa7b122e3a1faa3f6d17a05972908ebb008 --- /dev/null +++ b/esp32/level4/calendar_display/src/main_esp.cpp @@ -0,0 +1,79 @@ +/** + Using an RTC, display the current date and day of the week on ili9341 LCD, and navigate days with buttons + 03 MAY 2025 by Blind Author +*/ +#include +#include +#include "RTClib.h" +#include +#include + +#define TFT_CS 15 +#define TFT_DC 2 +#define TFT_RST 4 + +Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); +RTC_DS3231 rtc; + +#define LEFT_BUTTON_PIN 13 +#define RIGHT_BUTTON_PIN 12 + +DateTime currentDate; +int dayOffset = 0; + +const char* daysOfWeek[] = { + "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" +}; + +void setup() { + Serial.begin(9600); + Wire.begin(); + + pinMode(LEFT_BUTTON_PIN, INPUT); + pinMode(RIGHT_BUTTON_PIN, INPUT); + + if (!rtc.begin()) { + Serial.println("Couldn't find RTC"); + while (1); + } + + if (rtc.lostPower()) { + Serial.println("RTC lost power, setting time!"); + rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); + } + + tft.begin(); + tft.fillScreen(ILI9341_BLACK); + displayDate(); +} + +void loop() { + if (digitalRead(LEFT_BUTTON_PIN) == HIGH) { + dayOffset--; + displayDate(); + delay(300); + } + + if (digitalRead(RIGHT_BUTTON_PIN) == HIGH) { + dayOffset++; + displayDate(); + delay(300); + } +} + +void displayDate() { + DateTime now = rtc.now(); + currentDate = now + TimeSpan(dayOffset, 0, 0, 0); + + tft.fillScreen(ILI9341_BLACK); + tft.setTextSize(3); + tft.setTextColor(ILI9341_WHITE); + tft.setCursor(10, 30); + + char buffer[20]; + sprintf(buffer, "%04d-%02d-%02d", currentDate.year(), currentDate.month(), currentDate.day()); + tft.println(buffer); + + tft.setCursor(10, 80); + tft.println(daysOfWeek[currentDate.dayOfTheWeek()]); +} diff --git a/esp32/level4/calendar_display/wokwi.toml b/esp32/level4/calendar_display/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level4/calendar_display/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level4/dday_counter/description_esp.md b/esp32/level4/dday_counter/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..2cae8db86452017c77d40b669b3a070e7ad61dba --- /dev/null +++ b/esp32/level4/dday_counter/description_esp.md @@ -0,0 +1,35 @@ +# Serial RTC sensor + +## Project Description +This is a simple ESP32 project that compare RTC sensor time and serial input. + +## Hardware Components +- ESP32 DevKit v1 +- ds1307 Real Time Clock module + +## Circuit Description +The RTC sensor is connected to the ESP32. The VCC pin is connected to 3V3, the GND pin to gnd2, the SDA pin to pin21, and the SCL pin to pin22. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Initialize serial communication +2. Check if the RTC module can begin +3. Read current time once with RTC module +4. Continuously read the serial input, which is a target datetime in ISO format +5. Calculate how much day is left until the target time, and print to the serial monitor in the following format: "D-{days}" + +## Success Criteria +The test is successful when: +1. Correct day left to the target datetime is printed in the serial monitor. + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- Get current time with RTC sensor only once, in the setup +- Use RTClib to generate RTC_DS1307 object and read the value. +- RTC module has I2C interface. + +## Variants +There may be variants with GND pin. + +## Test Inputs +Test input values are: "2025-04-11T09:38:00", "2025-06-11T09:38:00", "2025-03-03T09:38:00" \ No newline at end of file diff --git a/esp32/level4/dday_counter/diagram_breadboard_esp.json b/esp32/level4/dday_counter/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..0cb404d5af2dace768e38a7183b6ce8a517301b8 --- /dev/null +++ b/esp32/level4/dday_counter/diagram_breadboard_esp.json @@ -0,0 +1,138 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Compare RTC sensor time and serial input", + "config": { + "gnd_pin": "GND.2", + "vcc_pin": "3V3" + }, + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": 208.2, + "left": -6.8, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": 0, + "left": 20, + "attrs": {} + }, + { + "type": "wokwi-ds1307", + "id": "rtc module1307", + "top": 295.1, + "left": 183.2, + "rotate": 90, + "attrs": { + "initTime": "2024-11-24T04:48:00" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "rtc module1307:GND", + "breadboard1:26t.e", + "", + [ + "$bb" + ] + ], + [ + "rtc module1307:5V", + "breadboard1:25t.e", + "", + [ + "$bb" + ] + ], + [ + "rtc module1307:SDA", + "breadboard1:24t.e", + "", + [ + "$bb" + ] + ], + [ + "rtc module1307:SCL", + "breadboard1:23t.e", + "", + [ + "$bb" + ] + ], + [ + "rtc module1307:SQW", + "breadboard1:22t.e", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:26t.c", + "breadboard1:tn.20", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:tn.19", + "esp1:GND.2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:25t.c", + "breadboard1:tp.17", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:tp.16", + "esp1:3V3", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:24t.c", + "esp1:D21", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:23t.c", + "esp1:D22", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level4/dday_counter/diagram_esp.json b/esp32/level4/dday_counter/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..734409bd01f8d2444cc8b2e80fb430d6cdd8a40e --- /dev/null +++ b/esp32/level4/dday_counter/diagram_esp.json @@ -0,0 +1,79 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Compare RTC sensor time and serial input", + "config": { + "gnd_pin": "GND.2", + "vcc_pin": "3V3" + }, + "parts": [ + { + "id": "esp1", + "type": "wokwi-esp32-devkit-v1", + "top": 0, + "left": 20 + }, + { + "id": "rtc module1307", + "type": "wokwi-ds1307", + "top": 250, + "left": 220, + "attrs": { + "initTime": "2024-11-24T04:48:00" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "esp1:GND.2", + "rtc module1307:GND", + "black", + [ + "v20", + "*", + "v0" + ] + ], + [ + "esp1:3V3", + "rtc module1307:5V", + "red", + [ + "v0" + ] + ], + [ + "esp1:D21", + "rtc module1307:SDA", + "green", + [ + "v16", + "h0", + "*", + "h-34" + ] + ], + [ + "esp1:D22", + "rtc module1307:SCL", + "orange", + [ + "v20", + "*", + "h-30" + ] + ] + ] +} \ No newline at end of file diff --git a/esp32/level4/dday_counter/platformio.ini b/esp32/level4/dday_counter/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..a24c7658ab21a7af113add7869fe9ea87d021e7f --- /dev/null +++ b/esp32/level4/dday_counter/platformio.ini @@ -0,0 +1,28 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno +lib_deps = + Arduino + RTClib + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +lib_deps = + Arduino + RTClib \ No newline at end of file diff --git a/esp32/level4/dday_counter/scenario.yaml b/esp32/level4/dday_counter/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d9f0dbfb4095dde2f2d64fe43a4f2a58e7a05830 --- /dev/null +++ b/esp32/level4/dday_counter/scenario.yaml @@ -0,0 +1,16 @@ +author: Blind Author +description: Compare RTC sensor time and serial input +name: Serial RTC sensor +test-values: +- part-type: wokwi-ds1307 + attr-name: initTime + value: "2024-11-24T04:48:57" +steps: +- wait-serial: Enter target datetime in format YYYY-MM-DDTHH:MM:SS +- write-serial: '2025-04-11T09:38:00' +- wait-serial: D-138 +- write-serial: '2025-06-11T09:38:00' +- wait-serial: D-199 +- write-serial: '2025-03-03T09:38:00' +- wait-serial: D-99 +version: 1.0 diff --git a/esp32/level4/dday_counter/src/main_esp.cpp b/esp32/level4/dday_counter/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bc1178d006bb002b0e93e1b5388b8240730139b3 --- /dev/null +++ b/esp32/level4/dday_counter/src/main_esp.cpp @@ -0,0 +1,45 @@ +/** + Compare RTC sensor time and serial input + 11 APR 2025 by Blind Author +*/ +#include +#include "RTClib.h" + +RTC_DS1307 rtc; +DateTime now; + +void setup () { + Serial.begin(115200); + + if (!rtc.begin()) { + Serial.println("Couldn't find RTC"); + Serial.flush(); + abort(); + } + + now = rtc.now(); + + Serial.println("Enter target datetime in format YYYY-MM-DDTHH:MM:SS"); +} + +void loop () { + + if (Serial.available()) { + String input = Serial.readStringUntil('\n'); + + int year = input.substring(0, 4).toInt(); + int month = input.substring(5, 7).toInt(); + int day = input.substring(8, 10).toInt(); + int hour = input.substring(11, 13).toInt(); + int minute = input.substring(14, 16).toInt(); + int second = input.substring(17, 19).toInt(); + + DateTime target(year, month, day, hour, minute, second); + + TimeSpan diff = target - now; + Serial.print("D-"); + Serial.println(abs(diff.days())); + } + + delay(500); +} diff --git a/esp32/level4/dday_counter/wokwi.toml b/esp32/level4/dday_counter/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level4/dday_counter/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file diff --git a/esp32/level4/parking_spot_monitor/.DS_Store b/esp32/level4/parking_spot_monitor/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b88cd06c171a6d6832fc043fd03fd2cd657ca877 Binary files /dev/null and b/esp32/level4/parking_spot_monitor/.DS_Store differ diff --git a/esp32/level4/parking_spot_monitor/description_esp.md b/esp32/level4/parking_spot_monitor/description_esp.md new file mode 100644 index 0000000000000000000000000000000000000000..77ddcf50b94d97f5c1071d664230109252b17f96 --- /dev/null +++ b/esp32/level4/parking_spot_monitor/description_esp.md @@ -0,0 +1,33 @@ +# Parking Spot Monitor + +## Project Description +This is an parking spot monitor project made with ESP32 that detects vehicle presence using an ultrasonic sensor and shows the status with an RGB LED. + +## Hardware Components +- ESP32 DevKit v1 +- 220Ω resistor * 3 +- RGB LED +- Ultrasonic Distance Sensor + +## Circuit Description +An ultrasonic distance sensor and a RGB led is connected to ESP32. R, G, B pin of RGB led are connected to ESP32 pin5, pin4, pin2, through 220Ω resistor, respectively. COM pin of RGB led is connected to ESP32 gnd2. For ultrasonic distance sensor, GND and VCC pin are connected to ESP32 gnd2 and 3V3, respectively. TRIG and ECHO pin is connected to pin12 and pin13. + +## Expected Behavior +When the ESP32 powers up, it should: +1. Set pin12, pin2, pin4, pin5 as OUTPUT, and pin13 as INPUT +2. Continuously triger and read the distance sensor value +3. Calculate the distance +4. If distance is smaller than 50, turn on the red light of RGB led +5. If distance is greater than or equal to 50, turn on the green light of RGB led + +## Success Criteria +The test is successful when: +1. When the distance is smaller than 50, red light on the RGB led turned on. +2. When the distance is greater than or equal to 50, green light on the RGB led turned on. + +## Notes for Implementation +- Use Arduino.h library for arduino core. +- To convert the distance sensor value to centimeters, divide it by 58. + +## Attributes +- To use 220Ω resistor, set the property name "value" to "220 ohm". \ No newline at end of file diff --git a/esp32/level4/parking_spot_monitor/diagram_breadboard_esp.json b/esp32/level4/parking_spot_monitor/diagram_breadboard_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..20788ec9791e248b5e65fbc8d1840cece956316b --- /dev/null +++ b/esp32/level4/parking_spot_monitor/diagram_breadboard_esp.json @@ -0,0 +1,279 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Detects vehicle presence using an ultrasonic sensor and shows the status with an RGB LED", + "parts": [ + { + "type": "wokwi-breadboard", + "id": "breadboard1", + "top": -271.8, + "left": 70, + "attrs": {} + }, + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": -9, + "left": 105, + "attrs": {} + }, + { + "type": "wokwi-rgb-led", + "id": "rgb led1", + "top": -255.2, + "left": 375.5, + "attrs": { + "common": "cathode" + } + }, + { + "type": "wokwi-hc-sr04", + "id": "ultrasonic distance sensor1", + "top": -228.9, + "left": 159.1, + "attrs": { + "distance": "277" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -168, + "left": 354.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -168, + "left": 373.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -168, + "left": 383.45, + "rotate": 90, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "resistor3:1", + "breadboard1:34t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor3:2", + "breadboard1:34b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor2:1", + "breadboard1:33t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor2:2", + "breadboard1:33b.h", + "", + [ + "$bb" + ] + ], + [ + "resistor1:1", + "breadboard1:31t.d", + "", + [ + "$bb" + ] + ], + [ + "resistor1:2", + "breadboard1:31b.h", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:VCC", + "breadboard1:15b.h", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:TRIG", + "breadboard1:16b.h", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:ECHO", + "breadboard1:17b.h", + "", + [ + "$bb" + ] + ], + [ + "ultrasonic distance sensor1:GND", + "breadboard1:18b.h", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:R", + "breadboard1:31t.b", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:COM", + "breadboard1:32t.c", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:G", + "breadboard1:33t.b", + "", + [ + "$bb" + ] + ], + [ + "rgb led1:B", + "breadboard1:34t.b", + "", + [ + "$bb" + ] + ], + [ + "breadboard1:32t.e", + "breadboard1:bn.26", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:34b.i", + "esp1:D2", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:33b.i", + "esp1:D4", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:31b.i", + "esp1:D5", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:18b.i", + "breadboard1:bn.14", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:15b.i", + "breadboard1:bp.11", + "green", + [ + "v0" + ] + ], + [ + "breadboard1:16b.i", + "esp1:D12", + "green", + [ + "v105.6", + "h38.4" + ] + ], + [ + "breadboard1:17b.i", + "esp1:D13", + "green", + [ + "v115.2", + "h19.2" + ] + ], + [ + "breadboard1:bp.1", + "esp1:3V3", + "green", + [ + "v315.9", + "h152.8" + ] + ], + [ + "breadboard1:bn.1", + "esp1:GND.2", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level4/parking_spot_monitor/diagram_esp.json b/esp32/level4/parking_spot_monitor/diagram_esp.json new file mode 100644 index 0000000000000000000000000000000000000000..387be61a1ea07841e3c623be5195d8eaa634caaf --- /dev/null +++ b/esp32/level4/parking_spot_monitor/diagram_esp.json @@ -0,0 +1,168 @@ +{ + "version": 1.0, + "author": "Blind Author", + "description": "Detects vehicle presence using an ultrasonic sensor and shows the status with an RGB LED", + "parts": [ + { + "type": "wokwi-esp32-devkit-v1", + "id": "esp1", + "top": -9, + "left": 105, + "attrs": {} + }, + { + "type": "wokwi-rgb-led", + "id": "rgb led1", + "top": -236, + "left": 327.5, + "attrs": { + "common": "cathode" + } + }, + { + "type": "wokwi-hc-sr04", + "id": "ultrasonic distance sensor1", + "top": -200.1, + "left": 111.1, + "attrs": { + "distance": "200" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor1", + "top": -158.4, + "left": 306.65, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor2", + "top": -158.4, + "left": 325.85, + "rotate": 90, + "attrs": { + "value": "220" + } + }, + { + "type": "wokwi-resistor", + "id": "resistor3", + "top": -158.4, + "left": 335.45, + "rotate": 90, + "attrs": { + "value": "220" + } + } + ], + "connections": [ + [ + "esp1:TX0", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp1:RX0", + "$serialMonitor:TX", + "", + [] + ], + [ + "rgb led1:COM", + "esp1:GND.2", + "green", + [ + "v76.4", + "h48.1", + "v249.6", + "h-115.2" + ] + ], + [ + "rgb led1:R", + "resistor1:1", + "green", + [ + "v0" + ] + ], + [ + "resistor2:1", + "rgb led1:G", + "green", + [ + "h0" + ] + ], + [ + "rgb led1:B", + "resistor3:1", + "green", + [ + "v0" + ] + ], + [ + "resistor3:2", + "esp1:D2", + "green", + [ + "h0" + ] + ], + [ + "resistor2:2", + "esp1:D4", + "green", + [ + "h0" + ] + ], + [ + "resistor1:2", + "esp1:D5", + "green", + [ + "h0" + ] + ], + [ + "ultrasonic distance sensor1:GND", + "esp1:GND.2", + "black", + [ + "v0" + ] + ], + [ + "ultrasonic distance sensor1:VCC", + "esp1:3V3", + "red", + [ + "v0" + ] + ], + [ + "ultrasonic distance sensor1:TRIG", + "esp1:D12", + "green", + [ + "v0" + ] + ], + [ + "ultrasonic distance sensor1:ECHO", + "esp1:D13", + "green", + [ + "v0" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/esp32/level4/parking_spot_monitor/platformio.ini b/esp32/level4/parking_spot_monitor/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..b684c45c413f1156343277a395e69b64e693c7e5 --- /dev/null +++ b/esp32/level4/parking_spot_monitor/platformio.ini @@ -0,0 +1,24 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +default_envs = uno + +[env:uno] +platform = atmelavr +framework = arduino +board = uno + +[env:esp32doit-devkit-v1] +platform = platformio/espressif32 @ 6.9.0 +board = esp32doit-devkit-v1 +framework = arduino +lib_deps = + Arduino \ No newline at end of file diff --git a/esp32/level4/parking_spot_monitor/scenario.yaml b/esp32/level4/parking_spot_monitor/scenario.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1568e747c61064c1a501c6617f075b5f001342a1 --- /dev/null +++ b/esp32/level4/parking_spot_monitor/scenario.yaml @@ -0,0 +1,95 @@ +author: Blind Author +description: Detects vehicle presence using an ultrasonic sensor and shows the status + with an RGB LED +name: Parking Spot Monitor +test-values: + - part-type: wokwi-rgb-led + attr-name: common + value: "cathode" +steps: +- delay: 1000ms +- set-control: + control: distance + part-id: ultrasonic distance sensor1 + value: 300 +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: rgb led1 + pin: R + value: 0 + - part-id: rgb led1 + pin: G + value: 1 + - part-id: rgb led1 + pin: B + value: 0 + - part-id: rgb led1 + pin: COM + value: 0 +- set-control: + control: distance + part-id: ultrasonic distance sensor1 + value: 60 +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: rgb led1 + pin: R + value: 0 + - part-id: rgb led1 + pin: G + value: 1 + - part-id: rgb led1 + pin: B + value: 0 + - part-id: rgb led1 + pin: COM + value: 0 +- set-control: + control: distance + part-id: ultrasonic distance sensor1 + value: 40 +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: rgb led1 + pin: R + value: 1 + - part-id: rgb led1 + pin: G + value: 0 + - part-id: rgb led1 + pin: B + value: 0 + - part-id: rgb led1 + pin: COM + value: 0 +- set-control: + control: distance + part-id: ultrasonic distance sensor1 + value: 10 +- delay: 1000ms +- wait-multi-pin: + timeout: 1000 + intervel: 100 + pins: + - part-id: rgb led1 + pin: R + value: 1 + - part-id: rgb led1 + pin: G + value: 0 + - part-id: rgb led1 + pin: B + value: 0 + - part-id: rgb led1 + pin: COM + value: 0 +version: 1.0 diff --git a/esp32/level4/parking_spot_monitor/src/main_esp.cpp b/esp32/level4/parking_spot_monitor/src/main_esp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e8db05e5a4e12bfdd2301f5b159b77021f622d3e --- /dev/null +++ b/esp32/level4/parking_spot_monitor/src/main_esp.cpp @@ -0,0 +1,47 @@ +/** + Detects vehicle presence using an ultrasonic sensor and shows the status with an RGB LED + 09 MAY 2025 by Blind Author +*/ +#include + +const int trigPin = 12; +const int echoPin = 13; + +const int redPin = 5; +const int greenPin = 4; +const int bluePin = 2; + +long duration; +int distance; + +void setup() { + pinMode(trigPin, OUTPUT); + pinMode(echoPin, INPUT); + pinMode(redPin, OUTPUT); + pinMode(greenPin, OUTPUT); + pinMode(bluePin, OUTPUT); +} + +void loop() { + digitalWrite(trigPin, LOW); + delayMicroseconds(2); + digitalWrite(trigPin, HIGH); + delayMicroseconds(10); + digitalWrite(trigPin, LOW); + + duration = pulseIn(echoPin, HIGH); + distance = duration / 58; + + if (distance < 50) { + digitalWrite(redPin, HIGH); + digitalWrite(greenPin, LOW); + digitalWrite(bluePin, LOW); + } + else { + digitalWrite(redPin, LOW); + digitalWrite(greenPin, HIGH); + digitalWrite(bluePin, LOW); + } + + delay(500); +} diff --git a/esp32/level4/parking_spot_monitor/wokwi.toml b/esp32/level4/parking_spot_monitor/wokwi.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6387a697119db8c232911cef3587af76a3438d6 --- /dev/null +++ b/esp32/level4/parking_spot_monitor/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1.0 +elf = ".pio/build/uno/firmware.elf" +firmware = ".pio/build/uno/firmware.hex" \ No newline at end of file