Skip to content

Commit

Permalink
Day 02
Browse files Browse the repository at this point in the history
  • Loading branch information
JosepMartiElias committed Dec 2, 2024
1 parent 800e266 commit 36fc9d8
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 3 deletions.
Binary file added docs/images/Day02-2023.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/Day02.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ hide:
1. :light_bulb:

!!! tip annotate "2. Say cheeeeese! :cheese: (1)"
Day 02
[](solutions/02/02.md)
[Day 02](solutions/02/02.md)
1. Be creative

!!! bug annotate "3. Sticker Challenge (1)"
Expand Down
57 changes: 57 additions & 0 deletions docs/solutions/01/01.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Day one:

Use the Barduino to blink an LED.

Blinking an LED is the *Hello World* of electronics, the first program you upload to check that everything is up and running. No better way to start the challenge than making sure everyting is ok! Easy one to start the challnge :winking_face:

You can always got to Arduino/File/Examples/01.Basic/Blink, but if you feel a bit more adventurous here you can check a possible solution:

## Possible solution!

### Arduino code

```c++
// constants won't change. Used here to set a pin number:
const int led = 48; // the LED of the Barduino is connected to pin 48

// Variables will change:
int ledState = LOW; // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0; // will store last time LED was updated

// constants won't change:
const long interval = 1000; // interval at which to blink (milliseconds)

void setup() {
// set the digital pin as output:
pinMode(led, OUTPUT);
}

void loop() {
// check to see if it's time to blink the LED; that is, if the difference
// between the current time and last time you blinked the LED is bigger than
// the interval at which you want to blink the LED.
unsigned long currentMillis = millis();

if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
// set the LED with the ledState of the variable:
digitalWrite(led, ledState);
}
}
```

## Hero shot

<video controls autoplay loop style="display: block; margin: auto;">
<source src="../../../video/day01.mp4" type="video/mp4">
</video>
9 changes: 9 additions & 0 deletions docs/solutions/02/02.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Day two:

Take a selfie with the Barduino.

We don't want to stress you..! Keep it simple and have a nice monday! :party_popper:

## Hero shot

![Day02](../../images/Day02.jpg)
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ nav:
- howto.md
- Solutions:
- Day 1: solutions/01/01.md
#- Day 2: solutions/02/02.md
- Day 2: solutions/02/02.md
#- Day 3: solutions/03/03.md
#- Day 4: solutions/04/04.md
#- Day 5: solutions/05/05.md
Expand Down

0 comments on commit 36fc9d8

Please sign in to comment.