forked from IELS1001-23-24/programming-course
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,671 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!"); | ||
} | ||
} |
Oops, something went wrong.