Skip to content

Commit

Permalink
Adds EdgeDetection examples
Browse files Browse the repository at this point in the history
  • Loading branch information
nosknut committed Jul 6, 2023
1 parent 2dfd564 commit 3ccf21e
Show file tree
Hide file tree
Showing 23 changed files with 1,671 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Exercises/EdgeDetection/DetectChange/DetectChange.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Change the code so that it only prints once when the button state changes.
// Hint:
// https://docs.arduino.cc/built-in-examples/digital/StateChangeDetection

const int BUTTON_PIN = 2;

void setup()
{
Serial.begin(9600);

pinMode(BUTTON_PIN, INPUT);
}

void loop()
{
bool buttonState = digitalRead(BUTTON_PIN);

if (buttonState)
{
Serial.println("Hello World!");
}
}
197 changes: 197 additions & 0 deletions Exercises/EdgeDetection/DetectChange/diagram.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
{
"version": 1,
"author": "wokwi",
"editor": "wokwi",
"parts": [
{
"type": "wokwi-breadboard-half",
"id": "bb1",
"top": 45,
"left": -74,
"attrs": {}
},
{
"type": "wokwi-arduino-uno",
"id": "uno",
"top": -212.52,
"left": -92.82,
"rotate": 180,
"attrs": {}
},
{
"type": "wokwi-pushbutton",
"id": "btn1",
"top": 143.9,
"left": -63.7,
"rotate": 90,
"attrs": {
"color": "black",
"bounce": "0"
}
},
{
"type": "wokwi-resistor",
"id": "r1",
"top": 91.2,
"left": -67.75,
"rotate": 90,
"attrs": {
"value": "1000"
}
},
{
"type": "wokwi-led",
"id": "led1",
"top": 126.4,
"left": -5.4,
"rotate": 180,
"attrs": {
"color": "red"
}
},
{
"type": "wokwi-resistor",
"id": "r2",
"top": 91.2,
"left": -10.15,
"rotate": 90,
"attrs": {
"value": "1000"
}
}
],
"connections": [
[
"uno:5V",
"bb1:tp.24",
"red",
[
"v-21.57",
"h185.23"
]
],
[
"uno:GND.2",
"bb1:tn.25",
"black",
[
"v-33.17",
"h191.11"
]
],
[
"r1:2",
"uno:2",
"orange",
[
"h0"
]
],
[
"bb1:4t.a",
"bb1:tp.3",
"red",
[
"v0"
]
],
[
"bb1:29t.a",
"bb1:tp.24",
"red",
[
"v0"
]
],
[
"led1:A",
"bb1:7t.e",
"",
[
"$bb"
]
],
[
"led1:C",
"bb1:8t.e",
"",
[
"$bb"
]
],
[
"r2:1",
"bb1:tn.6",
"",
[
"$bb"
]
],
[
"r2:2",
"bb1:8t.d",
"",
[
"$bb"
]
],
[
"btn1:1.l",
"bb1:4t.e",
"",
[
"$bb"
]
],
[
"btn1:2.l",
"bb1:2t.e",
"",
[
"$bb"
]
],
[
"btn1:1.r",
"bb1:4b.j",
"",
[
"$bb"
]
],
[
"btn1:2.r",
"bb1:2b.j",
"",
[
"$bb"
]
],
[
"r1:1",
"bb1:tn.1",
"",
[
"$bb"
]
],
[
"r1:2",
"bb1:2t.d",
"",
[
"$bb"
]
],
[
"bb1:7t.a",
"uno:5",
"green",
[
"v-59.27",
"h-25.93"
]
]
],
"dependencies": {}
}
4 changes: 4 additions & 0 deletions Exercises/EdgeDetection/DetectChange/wokwi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[wokwi]
version = 1
firmware = "../../../.build/DetectChange.ino.hex"
elf = "../../../.build/DetectChange.ino.elf"
22 changes: 22 additions & 0 deletions Exercises/EdgeDetection/DetectPress/DetectPress.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Change the code so that it only prints once when the button is pressed.
// Hint:
// https://docs.arduino.cc/built-in-examples/digital/StateChangeDetection

const int BUTTON_PIN = 2;

void setup()
{
Serial.begin(9600);

pinMode(BUTTON_PIN, INPUT);
}

void loop()
{
bool buttonState = digitalRead(BUTTON_PIN);

if (buttonState)
{
Serial.println("Hello World!");
}
}
Loading

0 comments on commit 3ccf21e

Please sign in to comment.